Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ members = [
]

[workspace.package]
version = "1.3.1"
version = "1.3.2"
authors = ["The Dragonfly Developers"]
homepage = "https://d7y.io/"
repository = "https://github.com/dragonflyoss/client.git"
Expand All @@ -23,14 +23,14 @@ readme = "README.md"
edition = "2021"

[workspace.dependencies]
dragonfly-client = { path = "dragonfly-client", version = "1.3.1" }
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.3.1" }
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.3.1" }
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.3.1" }
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.3.1" }
dragonfly-client-metric = { path = "dragonfly-client-metric", version = "1.3.1" }
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.3.1" }
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.3.1" }
dragonfly-client = { path = "dragonfly-client", version = "1.3.2" }
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.3.2" }
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.3.2" }
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.3.2" }
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.3.2" }
dragonfly-client-metric = { path = "dragonfly-client-metric", version = "1.3.2" }
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.3.2" }
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.3.2" }
dragonfly-api = "=2.2.28"
thiserror = "2.0"
futures = "0.3.32"
Expand Down
2 changes: 1 addition & 1 deletion dragonfly-client/src/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub const CONNECT_TIMEOUT: Duration = Duration::from_secs(2);
/// scheduling, refer to https://d7y.io/docs/next/reference/configuration/scheduler/.
/// Scheduler'configure `scheduler.retryInterval`, `scheduler.retryBackToSourceLimit` and `scheduler.retryLimit`
/// is used for the scheduler to schedule the task.
pub const REQUEST_TIMEOUT: Duration = Duration::from_secs(15);
pub const REQUEST_TIMEOUT: Duration = Duration::from_secs(10);

/// TCP_KEEPALIVE is the keepalive duration for TCP connection.
pub const TCP_KEEPALIVE: Duration = Duration::from_secs(3600);
Expand Down
102 changes: 69 additions & 33 deletions dragonfly-client/src/resource/parent_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,30 @@ impl ParentSelector {
error!("parent {} has no host info, skipping", parent.id);
continue;
};

let parent_host_id = parent_host.id.clone();
if let Some(connection) = self.connections.get(&parent_host_id) {
connection.increment_request();
continue;
}

let dfdaemon_upload_client = match DfdaemonUploadClient::new(
self.config.clone(),
format_url(
"http",
IpAddr::from_str(&parent_host.ip)?,
parent_host.port as u16,
),
false,
)
.await
{
Ok(client) => client,
Err(err) => {
error!("failed to connect to parent {}: {}", parent_host_id, err);
continue;
}
};

// Calculate initial weight based on parent's network info if available, otherwise use default weight.
let weight = match parent_host.network.as_ref() {
Expand All @@ -227,17 +250,6 @@ impl ParentSelector {
continue;
}
dashmap::mapref::entry::Entry::Vacant(entry) => {
let dfdaemon_upload_client = DfdaemonUploadClient::new(
self.config.clone(),
format_url(
"http",
IpAddr::from_str(&parent_host.ip)?,
parent_host.port as u16,
),
false,
)
.await?;

let connection = Connection::new();
connection.increment_request();
let shutdown = connection.shutdown.clone();
Expand Down Expand Up @@ -522,7 +534,30 @@ impl PersistentParentSelector {
warn!("persistent parent {} has no host info, skipping", parent.id);
continue;
};

let parent_host_id = parent_host.id.clone();
if let Some(connection) = self.connections.get(&parent_host_id) {
connection.increment_request();
continue;
}

let dfdaemon_upload_client = match DfdaemonUploadClient::new(
self.config.clone(),
format_url(
"http",
IpAddr::from_str(&parent_host.ip)?,
parent_host.port as u16,
),
false,
)
.await
{
Ok(client) => client,
Err(err) => {
error!("failed to connect to parent {}: {}", parent_host_id, err);
continue;
}
};

// Calculate initial weight based on parent's network info if available, otherwise use default weight.
let weight = match parent_host.network.as_ref() {
Expand All @@ -537,17 +572,6 @@ impl PersistentParentSelector {
continue;
}
dashmap::mapref::entry::Entry::Vacant(entry) => {
let dfdaemon_upload_client = DfdaemonUploadClient::new(
self.config.clone(),
format_url(
"http",
IpAddr::from_str(&parent_host.ip)?,
parent_host.port as u16,
),
false,
)
.await?;

let connection = Connection::new();
connection.increment_request();
let shutdown = connection.shutdown.clone();
Expand Down Expand Up @@ -835,7 +859,30 @@ impl PersistentCacheParentSelector {
);
continue;
};

let parent_host_id = parent_host.id.clone();
if let Some(connection) = self.connections.get(&parent_host_id) {
connection.increment_request();
continue;
}

let dfdaemon_upload_client = match DfdaemonUploadClient::new(
self.config.clone(),
format_url(
"http",
IpAddr::from_str(&parent_host.ip)?,
parent_host.port as u16,
),
false,
)
.await
{
Ok(client) => client,
Err(err) => {
error!("failed to connect to parent {}: {}", parent_host_id, err);
continue;
}
};

// Calculate initial weight based on parent's network info if available, otherwise use default weight.
let weight = match parent_host.network.as_ref() {
Expand All @@ -850,17 +897,6 @@ impl PersistentCacheParentSelector {
continue;
}
dashmap::mapref::entry::Entry::Vacant(entry) => {
let dfdaemon_upload_client = DfdaemonUploadClient::new(
self.config.clone(),
format_url(
"http",
IpAddr::from_str(&parent_host.ip)?,
parent_host.port as u16,
),
false,
)
.await?;

let connection = Connection::new();
connection.increment_request();
let shutdown = connection.shutdown.clone();
Expand Down
Loading