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