Removed to_be_replaced vector

This commit is contained in:
onyinyang 2024-01-29 13:19:27 -05:00
parent 11c09efed4
commit 3f4f79c5b7
5 changed files with 3 additions and 26 deletions

File diff suppressed because one or more lines are too long

View File

@ -77,7 +77,6 @@ impl DB {
db: Arc::new(Mutex::new(new_db)), db: Arc::new(Mutex::new(new_db)),
ba: Arc::new(Mutex::new(new_ba)), ba: Arc::new(Mutex::new(new_ba)),
extra_bridges: Arc::new(Mutex::new(Vec::new())), extra_bridges: Arc::new(Mutex::new(Vec::new())),
to_be_replaced_bridges: Arc::new(Mutex::new(Vec::new())),
metrics, metrics,
}; };
} }

View File

@ -26,7 +26,6 @@ pub struct LoxServerContext {
pub db: Arc<Mutex<BridgeDb>>, pub db: Arc<Mutex<BridgeDb>>,
pub ba: Arc<Mutex<BridgeAuth>>, pub ba: Arc<Mutex<BridgeAuth>>,
pub extra_bridges: Arc<Mutex<Vec<BridgeLine>>>, pub extra_bridges: Arc<Mutex<Vec<BridgeLine>>>,
pub to_be_replaced_bridges: Arc<Mutex<Vec<BridgeLine>>>,
#[serde(skip)] #[serde(skip)]
pub metrics: Metrics, pub metrics: Metrics,
} }
@ -155,7 +154,6 @@ impl LoxServerContext {
"Failing BridgeLine {:?} NOT replaced, saved for next update!", "Failing BridgeLine {:?} NOT replaced, saved for next update!",
bridge.uid_fingerprint bridge.uid_fingerprint
); );
self.new_to_be_replaced_bridge(bridge);
self.metrics.existing_or_updated_bridges.inc(); self.metrics.existing_or_updated_bridges.inc();
accounted_for_bridges.push(bridge.uid_fingerprint); accounted_for_bridges.push(bridge.uid_fingerprint);
} else { } else {
@ -203,11 +201,9 @@ impl LoxServerContext {
self.metrics.removed_bridges.inc(); self.metrics.removed_bridges.inc();
} }
lox_library::ReplaceSuccess::NotReplaced => { lox_library::ReplaceSuccess::NotReplaced => {
// Add the bridge to the list of to_be_replaced bridges in the Lox context and try // Try again to replace at the next update (nothing changes in the Lox Authority)
// again to replace at the next update (nothing changes in the Lox Authority)
println!("BridgeLine {:?} not found in rdsys update NOT replaced, saved for next update!", println!("BridgeLine {:?} not found in rdsys update NOT replaced, saved for next update!",
bridgeline.uid_fingerprint); bridgeline.uid_fingerprint);
self.new_to_be_replaced_bridge(bridgeline);
self.metrics.existing_or_updated_bridges.inc(); self.metrics.existing_or_updated_bridges.inc();
} }
lox_library::ReplaceSuccess::NotFound => println!( lox_library::ReplaceSuccess::NotFound => println!(
@ -261,11 +257,6 @@ impl LoxServerContext {
_ = extra_bridges.remove(length - 1) _ = extra_bridges.remove(length - 1)
} }
pub fn new_to_be_replaced_bridge(&self, bridge: BridgeLine) {
let mut to_be_replaced_bridges = self.to_be_replaced_bridges.lock().unwrap();
to_be_replaced_bridges.push(bridge);
}
// Add extra_bridges to the Lox bridge table as open invitation bridges // Add extra_bridges to the Lox bridge table as open invitation bridges
// TODO: Add some consideration for whether or not bridges should be sorted as // TODO: Add some consideration for whether or not bridges should be sorted as
// open invitation buckets or hot spare buckets // open invitation buckets or hot spare buckets

View File

@ -240,7 +240,6 @@ mod tests {
db: Arc::new(Mutex::new(bridgedb)), db: Arc::new(Mutex::new(bridgedb)),
ba: Arc::new(Mutex::new(lox_auth)), ba: Arc::new(Mutex::new(lox_auth)),
extra_bridges: Arc::new(Mutex::new(Vec::new())), extra_bridges: Arc::new(Mutex::new(Vec::new())),
to_be_replaced_bridges: Arc::new(Mutex::new(Vec::new())),
metrics: Metrics::default(), metrics: Metrics::default(),
}; };
Self { context } Self { context }

View File

@ -112,18 +112,6 @@ pub fn sort_for_parsing(
for resource in resources { for resource in resources {
// TODO: Maybe filter for untested resources first if last_passed alone would skew // TODO: Maybe filter for untested resources first if last_passed alone would skew
// the filter in an unintended direction // the filter in an unintended direction
println!(
"Resource {:?} last passed test: {:?}",
resource.fingerprint, resource.test_result.last_passed
);
println!(
"Time + hours of accepted failure: {:?}",
resource.test_result.last_passed + Duration::hours(ACCEPTED_HOURS_OF_FAILURE)
);
println!(
"Greater than Utc::now? {:?}",
resource.test_result.last_passed + Duration::hours(ACCEPTED_HOURS_OF_FAILURE)
);
if resource.test_result.last_passed + Duration::hours(ACCEPTED_HOURS_OF_FAILURE) if resource.test_result.last_passed + Duration::hours(ACCEPTED_HOURS_OF_FAILURE)
>= Utc::now() >= Utc::now()
{ {
@ -270,7 +258,7 @@ mod tests {
"434.777.212.100".to_owned(), "434.777.212.100".to_owned(),
10112, 10112,
"7B4DE04A22130470A1C77839954392BA979F7AE2".to_owned(), "7B4DE04A22130470A1C77839954392BA979F7AE2".to_owned(),
ACCEPTED_HOURS_OF_FAILURE-ACCEPTED_HOURS_OF_FAILURE, 0,
); );
let resource_seven = make_resource( let resource_seven = make_resource(
"https".to_owned(), "https".to_owned(),