mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 16:28:15 +00:00
fix: 解决依赖endpoint出现的问题
This commit is contained in:
+12
-4
@@ -52,7 +52,7 @@ pub struct Node {
|
||||
}
|
||||
|
||||
/// any type of endpoint.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub struct Endpoint {
|
||||
pub url: url::Url,
|
||||
pub is_local: bool,
|
||||
@@ -221,7 +221,7 @@ impl Endpoint {
|
||||
}
|
||||
|
||||
/// list of same type of endpoint.
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct Endpoints(Vec<Endpoint>);
|
||||
|
||||
impl AsRef<Vec<Endpoint>> for Endpoints {
|
||||
@@ -546,7 +546,7 @@ impl PoolEndpointList {
|
||||
|
||||
/// represent endpoints in a given pool
|
||||
/// along with its setCount and setDriveCount.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PoolEndpoints {
|
||||
// indicates if endpoints are provided in non-ellipses style
|
||||
pub legacy: bool,
|
||||
@@ -558,7 +558,7 @@ pub struct PoolEndpoints {
|
||||
}
|
||||
|
||||
/// list of list of endpoints
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EndpointServerPools(Vec<PoolEndpoints>);
|
||||
|
||||
impl From<Vec<PoolEndpoints>> for EndpointServerPools {
|
||||
@@ -631,6 +631,14 @@ impl EndpointServerPools {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// returns true if the first endpoint is local.
|
||||
pub fn first_local(&self) -> bool {
|
||||
self.0
|
||||
.first()
|
||||
.and_then(|v| v.endpoints.as_ref().first())
|
||||
.map_or(false, |v| v.is_local)
|
||||
}
|
||||
|
||||
/// returns a sorted list of nodes in this cluster
|
||||
pub fn get_nodes(&self) -> Vec<Node> {
|
||||
let mut node_map = HashMap::new();
|
||||
|
||||
+3
-3
@@ -9,9 +9,9 @@ mod erasure;
|
||||
pub mod error;
|
||||
mod file_meta;
|
||||
mod format;
|
||||
// mod peer;
|
||||
// mod sets;
|
||||
// pub mod store;
|
||||
mod peer;
|
||||
mod sets;
|
||||
pub mod store;
|
||||
pub mod store_api;
|
||||
mod store_init;
|
||||
mod utils;
|
||||
|
||||
+9
-9
@@ -14,7 +14,7 @@ type Client = Arc<Box<dyn PeerS3Client>>;
|
||||
#[async_trait]
|
||||
pub trait PeerS3Client: Debug + Sync + Send + 'static {
|
||||
async fn make_bucket(&self, bucket: &str, opts: &MakeBucketOptions) -> Result<()>;
|
||||
fn get_pools(&self) -> Vec<i32>;
|
||||
fn get_pools(&self) -> Vec<usize>;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -53,7 +53,7 @@ impl S3PeerSys {
|
||||
|
||||
#[async_trait]
|
||||
impl PeerS3Client for S3PeerSys {
|
||||
fn get_pools(&self) -> Vec<i32> {
|
||||
fn get_pools(&self) -> Vec<usize> {
|
||||
unimplemented!()
|
||||
}
|
||||
async fn make_bucket(&self, bucket: &str, opts: &MakeBucketOptions) -> Result<()> {
|
||||
@@ -80,7 +80,7 @@ impl PeerS3Client for S3PeerSys {
|
||||
let mut per_pool_errs = Vec::with_capacity(self.clients.len());
|
||||
for (j, cli) in self.clients.iter().enumerate() {
|
||||
let pools = cli.get_pools();
|
||||
let idx = i as i32;
|
||||
let idx = i;
|
||||
if pools.contains(&idx) {
|
||||
per_pool_errs.push(errors[j].as_ref());
|
||||
}
|
||||
@@ -99,11 +99,11 @@ impl PeerS3Client for S3PeerSys {
|
||||
pub struct LocalPeerS3Client {
|
||||
pub local_disks: Vec<DiskStore>,
|
||||
pub node: Node,
|
||||
pub pools: Vec<i32>,
|
||||
pub pools: Vec<usize>,
|
||||
}
|
||||
|
||||
impl LocalPeerS3Client {
|
||||
fn new(local_disks: Vec<DiskStore>, node: Node, pools: Vec<i32>) -> Self {
|
||||
fn new(local_disks: Vec<DiskStore>, node: Node, pools: Vec<usize>) -> Self {
|
||||
Self {
|
||||
local_disks,
|
||||
node,
|
||||
@@ -114,7 +114,7 @@ impl LocalPeerS3Client {
|
||||
|
||||
#[async_trait]
|
||||
impl PeerS3Client for LocalPeerS3Client {
|
||||
fn get_pools(&self) -> Vec<i32> {
|
||||
fn get_pools(&self) -> Vec<usize> {
|
||||
self.pools.clone()
|
||||
}
|
||||
async fn make_bucket(&self, bucket: &str, opts: &MakeBucketOptions) -> Result<()> {
|
||||
@@ -154,18 +154,18 @@ impl PeerS3Client for LocalPeerS3Client {
|
||||
#[derive(Debug)]
|
||||
pub struct RemotePeerS3Client {
|
||||
pub node: Node,
|
||||
pub pools: Vec<i32>,
|
||||
pub pools: Vec<usize>,
|
||||
}
|
||||
|
||||
impl RemotePeerS3Client {
|
||||
fn new(node: Node, pools: Vec<i32>) -> Self {
|
||||
fn new(node: Node, pools: Vec<usize>) -> Self {
|
||||
Self { node, pools }
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl PeerS3Client for RemotePeerS3Client {
|
||||
fn get_pools(&self) -> Vec<i32> {
|
||||
fn get_pools(&self) -> Vec<usize> {
|
||||
unimplemented!()
|
||||
}
|
||||
async fn make_bucket(&self, _bucket: &str, _opts: &MakeBucketOptions) -> Result<()> {
|
||||
|
||||
@@ -29,20 +29,21 @@ pub struct ECStore {
|
||||
|
||||
impl ECStore {
|
||||
pub async fn new(address: String, endpoints: Vec<String>) -> Result<Self> {
|
||||
let layouts = DisksLayout::try_from(endpoints.as_slice())?;
|
||||
let layouts = DisksLayout::try_from(endpoints.as_slice()).map_err(|v| Error::msg(v))?;
|
||||
|
||||
let mut deployment_id = None;
|
||||
|
||||
let (endpoint_pools, _) = EndpointServerPools::create_server_endpoints(address.as_str(), &layouts)?;
|
||||
let (endpoint_pools, _) =
|
||||
EndpointServerPools::create_server_endpoints(address.as_str(), &layouts).map_err(|v| Error::msg(v))?;
|
||||
|
||||
let mut pools = Vec::with_capacity(endpoint_pools.len());
|
||||
let mut disk_map = HashMap::with_capacity(endpoint_pools.len());
|
||||
let mut pools = Vec::with_capacity(endpoint_pools.as_ref().len());
|
||||
let mut disk_map = HashMap::with_capacity(endpoint_pools.as_ref().len());
|
||||
|
||||
let first_is_local = endpoint_pools.first_is_local();
|
||||
let first_is_local = endpoint_pools.first_local();
|
||||
|
||||
let mut local_disks = Vec::new();
|
||||
|
||||
for (i, pool_eps) in endpoint_pools.iter().enumerate() {
|
||||
for (i, pool_eps) in endpoint_pools.as_ref().iter().enumerate() {
|
||||
// TODO: read from config parseStorageClass
|
||||
let partiy_count = store_init::default_partiy_count(pool_eps.drives_per_set);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user