Skip to content

Commit 69f5167

Browse files
authored
refactor(resource): change weights type from u32 to u64 (#1483)
Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent 504b7de commit 69f5167

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ members = [
1313
]
1414

1515
[workspace.package]
16-
version = "1.1.1"
16+
version = "1.1.2"
1717
authors = ["The Dragonfly Developers"]
1818
homepage = "https://d7y.io/"
1919
repository = "https://github.com/dragonflyoss/client.git"
@@ -23,14 +23,14 @@ readme = "README.md"
2323
edition = "2021"
2424

2525
[workspace.dependencies]
26-
dragonfly-client = { path = "dragonfly-client", version = "1.1.1" }
27-
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.1.1" }
28-
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.1.1" }
29-
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.1.1" }
30-
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.1.1" }
31-
dragonfly-client-metric = { path = "dragonfly-client-metric", version = "1.1.1" }
32-
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.1.1" }
33-
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.1.1" }
26+
dragonfly-client = { path = "dragonfly-client", version = "1.1.2" }
27+
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.1.2" }
28+
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.1.2" }
29+
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.1.2" }
30+
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.1.2" }
31+
dragonfly-client-metric = { path = "dragonfly-client-metric", version = "1.1.2" }
32+
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.1.2" }
33+
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.1.2" }
3434
dragonfly-api = "=2.1.81"
3535
thiserror = "2.0"
3636
futures = "0.3.31"

dragonfly-client/src/resource/parent_selector.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub struct ParentSelector {
111111
id_generator: Arc<IDGenerator>,
112112

113113
/// Maps parent host IDs to their current bandwidth weights.
114-
weights: Arc<DashMap<String, u32>>,
114+
weights: Arc<DashMap<String, u64>>,
115115

116116
/// Active connections indexed by parent host ID and each connection tracks usage and manages its sync task.
117117
connections: Arc<DashMap<String, Connection>>,
@@ -149,7 +149,7 @@ impl ParentSelector {
149149
/// (better idle bandwidth) have a higher probability of being selected. If weight
150150
/// calculation fails, falls back to uniform random selection.
151151
pub fn select(&self, parents: Vec<CollectedParent>) -> CollectedParent {
152-
let weights: Vec<u32> = parents
152+
let weights: Vec<u64> = parents
153153
.iter()
154154
.map(|parent| {
155155
let Some(parent_host) = parent.host.as_ref() else {
@@ -304,7 +304,7 @@ impl ParentSelector {
304304
host_id: String,
305305
peer_id: String,
306306
parent_host_id: String,
307-
weights: Arc<DashMap<String, u32>>,
307+
weights: Arc<DashMap<String, u64>>,
308308
dfdaemon_upload_client: DfdaemonUploadClient,
309309
mut shutdown: Shutdown,
310310
mut dfdaemon_shutdown: Shutdown,
@@ -332,7 +332,7 @@ impl ParentSelector {
332332
let idle_tx_bandwidth = Self::get_idle_tx_bandwidth(&message);
333333

334334
info!("update host {} idle TX bandwidth to {}", parent_host_id, idle_tx_bandwidth);
335-
weights.insert(parent_host_id.clone(), idle_tx_bandwidth as u32);
335+
weights.insert(parent_host_id.clone(), idle_tx_bandwidth);
336336
}
337337
None => break,
338338
}
@@ -406,7 +406,7 @@ pub struct PersistentCacheParentSelector {
406406
id_generator: Arc<IDGenerator>,
407407

408408
/// Maps parent host IDs to their current bandwidth weights.
409-
weights: Arc<DashMap<String, u32>>,
409+
weights: Arc<DashMap<String, u64>>,
410410

411411
/// Active connections indexed by parent host ID and each connection tracks usage and manages its sync task.
412412
connections: Arc<DashMap<String, Connection>>,
@@ -444,7 +444,7 @@ impl PersistentCacheParentSelector {
444444
/// (better idle bandwidth) have a higher probability of being selected. If weight
445445
/// calculation fails, falls back to uniform random selection.
446446
pub fn select(&self, parents: Vec<CollectedParent>) -> CollectedParent {
447-
let weights: Vec<u32> = parents
447+
let weights: Vec<u64> = parents
448448
.iter()
449449
.map(|parent| {
450450
let Some(parent_host) = parent.host.as_ref() else {
@@ -605,7 +605,7 @@ impl PersistentCacheParentSelector {
605605
host_id: String,
606606
peer_id: String,
607607
parent_host_id: String,
608-
weights: Arc<DashMap<String, u32>>,
608+
weights: Arc<DashMap<String, u64>>,
609609
dfdaemon_upload_client: DfdaemonUploadClient,
610610
mut shutdown: Shutdown,
611611
mut dfdaemon_shutdown: Shutdown,
@@ -636,7 +636,7 @@ impl PersistentCacheParentSelector {
636636
let idle_tx_bandwidth = Self::get_idle_tx_bandwidth(&message);
637637

638638
info!("update host {} idle TX bandwidth to {}", parent_host_id, idle_tx_bandwidth);
639-
weights.insert(parent_host_id.clone(), idle_tx_bandwidth as u32);
639+
weights.insert(parent_host_id.clone(), idle_tx_bandwidth);
640640
}
641641
None => break,
642642
}

0 commit comments

Comments
 (0)