mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-30 08:49:26 +00:00
Merge remote-tracking branch 'origin/main' into bucketmeta
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#![allow(clippy::map_entry)]
|
||||
use crate::disk::endpoint::EndpointType;
|
||||
use crate::{
|
||||
bucket::BucketMetadata,
|
||||
disk::{error::DiskError, new_disk, DiskOption, DiskStore, WalkDirOptions, BUCKET_META_PREFIX, RUSTFS_META_BUCKET},
|
||||
@@ -15,6 +16,7 @@ use crate::{
|
||||
store_init, utils,
|
||||
};
|
||||
use backon::{ExponentialBuilder, Retryable};
|
||||
use common::globals::{GLOBAL_Local_Node_Name, GLOBAL_Rustfs_Host, GLOBAL_Rustfs_Port};
|
||||
use futures::future::join_all;
|
||||
use http::HeaderMap;
|
||||
use s3s::{dto::StreamingBlob, Body};
|
||||
@@ -173,6 +175,13 @@ impl ECStore {
|
||||
|
||||
let mut local_disks = Vec::new();
|
||||
|
||||
init_local_peer(
|
||||
&endpoint_pools,
|
||||
&GLOBAL_Rustfs_Host.read().await.to_string(),
|
||||
&GLOBAL_Rustfs_Port.read().await.to_string(),
|
||||
)
|
||||
.await;
|
||||
|
||||
debug!("endpoint_pools: {:?}", endpoint_pools);
|
||||
|
||||
for (i, pool_eps) in endpoint_pools.as_ref().iter().enumerate() {
|
||||
@@ -805,3 +814,26 @@ impl StorageAPI for ECStore {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
async fn init_local_peer(endpoint_pools: &EndpointServerPools, host: &String, port: &String) {
|
||||
let mut peer_set = Vec::new();
|
||||
endpoint_pools.as_ref().iter().for_each(|endpoints| {
|
||||
endpoints.endpoints.as_ref().iter().for_each(|endpoint| {
|
||||
if endpoint.get_type() == EndpointType::Url && endpoint.is_local && endpoint.url.has_host() {
|
||||
peer_set.push(endpoint.url.host_str().unwrap().to_string());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if peer_set.is_empty() {
|
||||
if !host.is_empty() {
|
||||
*GLOBAL_Local_Node_Name.write().await = format!("{}:{}", host, port);
|
||||
return;
|
||||
}
|
||||
|
||||
*GLOBAL_Local_Node_Name.write().await = format!("127.0.0.1:{}", port);
|
||||
return;
|
||||
}
|
||||
|
||||
*GLOBAL_Local_Node_Name.write().await = peer_set[0].clone();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user