review feedbacks

This commit is contained in:
haoran 2022-11-29 17:42:18 +00:00 committed by HaoranYi
parent b090bb4f56
commit 75fc87f330
1 changed files with 26 additions and 34 deletions

View File

@ -290,25 +290,21 @@ impl BucketStorage {
.create(true) .create(true)
.open(file.clone()) .open(file.clone())
.map_err(|e| { .map_err(|e| {
if let Some((mmap_count, num_open_files, max_open_files_limit)) = Self::get_mmap_fd_stats() { let mmap_msg = Self::get_mmap_fd_stats()
panic!( .map(|(mmap_count, num_open_files, max_open_files_limit)| {
"Unable to create data file {} in current dir({:?}): {:?}, current mmap_count: {}, current number of open files: {}, max limit of open files: {:?}", format!("current mmap_count: {}, current number of open files: {}, max limit of open files: {:?}",
file.display(), mmap_count,
std::env::current_dir(), num_open_files,
e, max_open_files_limit,
mmap_count, )
num_open_files, }).unwrap_or_default();
max_open_files_limit, panic!(
); "Unable to create data file {} in current dir({:?}): {:?}. {}",
} file.display(),
else { std::env::current_dir(),
panic!( e,
"Unable to create data file {} in current dir({:?}): {:?}", mmap_msg,
file.display(), );
std::env::current_dir(),
e,
);
}
}) })
.unwrap(); .unwrap();
@ -437,23 +433,19 @@ mod test {
assert_eq!(storage.uid(ix), None); assert_eq!(storage.uid(ix), None);
// test get_mmap_fd_stats // test get_mmap_fd_stats
if let Some((mmap_count, num_open_files, max_open_files_limit)) = let (mmap_count, num_open_files, max_open_files_limit) =
BucketStorage::get_mmap_fd_stats() BucketStorage::get_mmap_fd_stats().unwrap();
{
assert!(mmap_count > 0);
assert!(num_open_files > 0);
match max_open_files_limit.soft_limit {
LimitValue::Unlimited => {}
LimitValue::Value(x) => assert!(x > 0),
}
match max_open_files_limit.hard_limit { assert!(mmap_count > 0);
LimitValue::Unlimited => {} assert!(num_open_files > 0);
LimitValue::Value(x) => assert!(x > 0), match max_open_files_limit.soft_limit {
} LimitValue::Unlimited => {}
LimitValue::Value(x) => assert!(x > 0),
}
println!("{:?}", num_open_files); match max_open_files_limit.hard_limit {
println!("{:?}", max_open_files_limit); LimitValue::Unlimited => {}
LimitValue::Value(x) => assert!(x > 0),
} }
} }
} }