support distribute lock

Signed-off-by: junxiang Mu <1948535941@qq.com>
This commit is contained in:
junxiang Mu
2024-09-26 11:30:56 +08:00
parent 5e70d8b841
commit ca3dac9a25
41 changed files with 2161 additions and 1275 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
use crate::error::{Error, Result};
use crate::utils::net;
use common::error::{Error, Result};
use path_absolutize::Absolutize;
use path_clean::PathClean;
use std::{fmt::Display, path::Path};
+1 -1
View File
@@ -1,4 +1,4 @@
use crate::error::{Error, Result};
use common::error::{Error, Result};
#[derive(Debug, thiserror::Error)]
pub enum DiskError {
+1 -1
View File
@@ -1,5 +1,5 @@
use super::error::DiskError;
use crate::error::{Error, Result};
use common::error::{Error, Result};
use serde::{Deserialize, Serialize};
use serde_json::Error as JsonError;
use uuid::Uuid;
+1 -1
View File
@@ -5,12 +5,12 @@ use super::{
};
use crate::disk::{LocalFileReader, LocalFileWriter, STORAGE_FORMAT_FILE};
use crate::{
error::{Error, Result},
file_meta::FileMeta,
store_api::{FileInfo, RawFileInfo},
utils,
};
use bytes::Bytes;
use common::error::{Error, Result};
use path_absolutize::Absolutize;
use std::{
fs::Metadata,
+2 -2
View File
@@ -2,7 +2,7 @@ pub mod endpoint;
pub mod error;
pub mod format;
mod local;
mod remote;
pub mod remote;
pub const RUSTFS_META_BUCKET: &str = ".rustfs.sys";
pub const RUSTFS_META_MULTIPART_BUCKET: &str = ".rustfs.sys/multipart";
@@ -14,11 +14,11 @@ const STORAGE_FORMAT_FILE: &str = "xl.meta";
use crate::{
erasure::{ReadAt, Write},
error::{Error, Result},
file_meta::FileMeta,
store_api::{FileInfo, RawFileInfo},
};
use bytes::Bytes;
use common::error::{Error, Result};
use futures::StreamExt;
use protos::proto_gen::node_service::{
node_service_client::NodeServiceClient, ReadAtRequest, ReadAtResponse, WriteRequest, WriteResponse,
+7 -6
View File
@@ -1,6 +1,7 @@
use std::{path::PathBuf, sync::Arc, time::Duration};
use bytes::Bytes;
use common::error::{Error, Result};
use futures::lock::Mutex;
use protos::{
node_service_time_out_client,
@@ -12,7 +13,7 @@ use protos::{
},
DEFAULT_GRPC_SERVER_MESSAGE_LEN,
};
use tokio::{fs, sync::RwLock};
use tokio::sync::RwLock;
use tonic::{
transport::{Channel, Endpoint as tonic_Endpoint},
Request,
@@ -23,7 +24,6 @@ use uuid::Uuid;
use crate::{
disk::error::DiskError,
error::{Error, Result},
store_api::{FileInfo, RawFileInfo},
};
@@ -35,15 +35,16 @@ use super::{
#[derive(Debug)]
pub struct RemoteDisk {
id: Mutex<Option<Uuid>>,
channel: Arc<RwLock<Option<Channel>>>,
url: url::Url,
pub id: Mutex<Option<Uuid>>,
pub channel: Arc<RwLock<Option<Channel>>>,
pub url: url::Url,
pub root: PathBuf,
}
impl RemoteDisk {
pub async fn new(ep: &Endpoint, _opt: &DiskOption) -> Result<Self> {
let root = fs::canonicalize(ep.url.path()).await?;
// let root = fs::canonicalize(ep.url.path()).await?;
let root = PathBuf::from(ep.url.path());
Ok(Self {
channel: Arc::new(RwLock::new(None)),