mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-31 17:28:12 +00:00
feat(lock): Add support for disabling lock manager (#511)
* feat(lock): Add support for disabling lock manager Implement control of lock system activation and deactivation via environment variables Add DisabledLockManager for lock-free operation scenarios Introduce LockManager trait to uniformly manage different lock managers Signed-off-by: junxiang Mu <1948535941@qq.com> * refactor(lock): Optimize implementation of global lock manager and parsing of boolean environment variables Refactor the implementation of the global lock manager: wrap FastObjectLockManager with Arc and add the as_fast_lock_manager method Extract the boolean environment variable parsing logic into an independent function parse_bool_env_var Signed-off-by: junxiang Mu <1948535941@qq.com> --------- Signed-off-by: junxiang Mu <1948535941@qq.com>
This commit is contained in:
@@ -142,6 +142,20 @@ pub struct MetricsSnapshot {
|
||||
}
|
||||
|
||||
impl MetricsSnapshot {
|
||||
/// Create empty snapshot (for disabled lock manager)
|
||||
pub fn empty() -> Self {
|
||||
Self {
|
||||
fast_path_success: 0,
|
||||
slow_path_success: 0,
|
||||
timeouts: 0,
|
||||
releases: 0,
|
||||
cleanups: 0,
|
||||
contention_events: 0,
|
||||
total_wait_time_ns: 0,
|
||||
max_wait_time_ns: 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn total_acquisitions(&self) -> u64 {
|
||||
self.fast_path_success + self.slow_path_success
|
||||
}
|
||||
@@ -251,6 +265,22 @@ pub struct AggregatedMetrics {
|
||||
}
|
||||
|
||||
impl AggregatedMetrics {
|
||||
/// Create empty metrics (for disabled lock manager)
|
||||
pub fn empty() -> Self {
|
||||
Self {
|
||||
shard_metrics: MetricsSnapshot::empty(),
|
||||
shard_count: 0,
|
||||
uptime: Duration::ZERO,
|
||||
cleanup_runs: 0,
|
||||
total_objects_cleaned: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if metrics are empty (indicates disabled or no activity)
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.shard_count == 0 && self.shard_metrics.total_acquisitions() == 0 && self.shard_metrics.releases == 0
|
||||
}
|
||||
|
||||
/// Get operations per second
|
||||
pub fn ops_per_second(&self) -> f64 {
|
||||
let total_ops = self.shard_metrics.total_acquisitions() + self.shard_metrics.releases;
|
||||
|
||||
Reference in New Issue
Block a user