test rename_data

This commit is contained in:
weisd
2024-09-23 14:32:48 +08:00
parent f1004a1324
commit a920204f3e
4 changed files with 37 additions and 4 deletions
+11
View File
@@ -742,6 +742,7 @@ impl DiskAPI for LocalDisk {
Ok(RenameDataResp {
old_data_dir: old_data_dir,
sign: None, // TODO:
})
}
@@ -872,6 +873,16 @@ impl DiskAPI for LocalDisk {
Ok(RawFileInfo { buf })
}
async fn delete_version(
&self,
volume: &str,
path: &str,
fi: FileInfo,
force_del_marker: bool,
opts: DeleteOptions,
) -> Result<RawFileInfo> {
unimplemented!()
}
async fn delete_versions(
&self,
volume: &str,
+12
View File
@@ -79,6 +79,14 @@ pub trait DiskAPI: Debug + Send + Sync + 'static {
opts: &ReadOptions,
) -> Result<FileInfo>;
async fn read_xl(&self, volume: &str, path: &str, read_data: bool) -> Result<RawFileInfo>;
async fn delete_version(
&self,
volume: &str,
path: &str,
fi: FileInfo,
force_del_marker: bool,
opts: DeleteOptions,
) -> Result<RawFileInfo>;
async fn delete_versions(
&self,
volume: &str,
@@ -206,14 +214,18 @@ pub struct DiskOption {
pub health_check: bool,
}
#[derive(Debug, Default)]
pub struct RenameDataResp {
pub old_data_dir: Option<Uuid>,
pub sign: Option<Vec<u8>>,
}
#[derive(Debug, Clone, Default)]
pub struct DeleteOptions {
pub recursive: bool,
pub immediate: bool,
pub undo_write: bool,
pub old_data_dir: Option<Uuid>,
}
#[derive(Debug, Clone)]
+2 -2
View File
@@ -1,5 +1,5 @@
use crate::error::{Error, Result, StdError};
use crate::quorum::{object_ignored_errs, reduce_write_quorum_errs};
use crate::quorum::{object_op_ignored_errs, reduce_write_quorum_errs};
use bytes::Bytes;
use futures::future::join_all;
use futures::{Stream, StreamExt};
@@ -94,7 +94,7 @@ impl Erasure {
warn!("Erasure encode errs {:?}", errs);
let err_idx = reduce_write_quorum_errs(&errs, object_ignored_errs().as_ref(), write_quorum)?;
let err_idx = reduce_write_quorum_errs(&errs, object_op_ignored_errs().as_ref(), write_quorum)?;
if errs[err_idx].is_some() {
let err = errs[err_idx].take().unwrap();
return Err(err);
+12 -2
View File
@@ -27,8 +27,16 @@ pub fn base_ignored_errs() -> Vec<Box<dyn CheckErrorFn>> {
]
}
pub fn object_ignored_errs() -> Vec<Box<dyn CheckErrorFn>> {
vec![Box::new(DiskError::FileNotFound)]
// object_op_ignored_errs
pub fn object_op_ignored_errs() -> Vec<Box<dyn CheckErrorFn>> {
vec![
Box::new(DiskError::DiskNotFound),
Box::new(DiskError::FaultyDisk),
Box::new(DiskError::FaultyRemoteDisk),
Box::new(DiskError::DiskAccessDenied),
Box::new(DiskError::UnformattedDisk),
Box::new(DiskError::DiskOngoingReq),
]
}
// 用于检查错误是否被忽略的函数
@@ -91,6 +99,7 @@ fn reduce_quorum_errs(errs: &Vec<Option<Error>>, ignored_errs: &Vec<Box<dyn Chec
}
// 根据读quorum验证错误数量
// 返回最大错误数量的下标,或QuorumError
pub fn reduce_read_quorum_errs(
errs: &mut Vec<Option<Error>>,
ignored_errs: &Vec<Box<dyn CheckErrorFn>>,
@@ -105,6 +114,7 @@ pub fn reduce_read_quorum_errs(
}
// 根据写quorum验证错误数量
// 返回最大错误数量的下标,或QuorumError
pub fn reduce_write_quorum_errs(
errs: &Vec<Option<Error>>,
ignored_errs: &Vec<Box<dyn CheckErrorFn>>,