mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 16:28:15 +00:00
refactor(app): collapse transition stats boundary (#4100)
This commit is contained in:
@@ -42,7 +42,7 @@ migration PR removes or replaces each item.
|
||||
| `GLOBAL_OBJECT_API`, `GLOBAL_OBJECT_STORE_RESOLVER` | `crates/ecstore/src/runtime/global.rs` | Runtime migration target | Do not migrate first; it is tied to storage startup, IAM-after-storage AppContext publication, and data-plane resolver compatibility. |
|
||||
| `GLOBAL_ENDPOINTS`, `GLOBAL_IS_ERASURE`, `GLOBAL_IS_DIST_ERASURE`, `GLOBAL_IS_ERASURE_SD`, `GLOBAL_ROOT_DISK_THRESHOLD` | `crates/ecstore/src/runtime/global.rs` and `crates/ecstore/src/runtime/sources.rs` | Runtime migration target | Endpoint, setup-type, and root-disk-threshold access now stays behind ECStore runtime helpers; move endpoint ownership only after readiness and quorum behavior have explicit coverage. |
|
||||
| `GLOBAL_LOCAL_DISK_MAP`, `GLOBAL_LOCAL_DISK_ID_MAP`, `GLOBAL_LOCAL_DISK_SET_DRIVES` | `crates/ecstore/src/runtime/global.rs` and `crates/ecstore/src/runtime/sources.rs` | Runtime migration target | Local disk map, disk-id cache, and set-drive access now stay behind ECStore runtime-source helpers instead of direct global access; preserve disk lookup, remote/local classification, and test reset hooks in later ownership changes. |
|
||||
| `GLOBAL_EXPIRY_STATE`, `GLOBAL_TRANSITION_STATE`, `GLOBAL_LIFECYCLE_SYS` | `crates/ecstore/src/bucket/lifecycle/*`, `crates/ecstore/src/runtime/global.rs`, and `crates/ecstore/src/runtime/sources.rs` | Runtime migration target | Lifecycle state globals now stay behind ECStore lifecycle owner helpers and ECStore runtime-source helpers; RustFS AppContext has expiry/transition state interfaces and resolver coverage; scanner expiry-state access still uses the ECStore runtime `expiry_state_handle` boundary until scanner gets an injected provider. |
|
||||
| `GLOBAL_EXPIRY_STATE`, `GLOBAL_TRANSITION_STATE`, `GLOBAL_LIFECYCLE_SYS` | `crates/ecstore/src/bucket/lifecycle/*`, `crates/ecstore/src/runtime/global.rs`, and `crates/ecstore/src/runtime/sources.rs` | Runtime migration target | Lifecycle state globals now stay behind ECStore lifecycle owner helpers and ECStore runtime-source helpers; RustFS AppContext has expiry/transition state interfaces and resolver coverage, and daily tier stats derive from the transition-state handle instead of a separate context boundary; scanner expiry-state access still uses the ECStore runtime `expiry_state_handle` boundary until scanner gets an injected provider. |
|
||||
| `GLOBAL_REPLICATION_POOL`, `GLOBAL_REPLICATION_STATS`, `GLOBAL_BUCKET_MONITOR` | `crates/ecstore/src/bucket/replication/*`, `crates/ecstore/src/runtime/global.rs` | Runtime migration target | Replication pool/stat access now stays behind replication owner and ECStore runtime-source helpers; bucket-monitor direct access now stays behind ECStore runtime helpers while AppContext/runtime-source resolvers remain the caller boundary. |
|
||||
| `GLOBAL_TIER_CONFIG_MGR`, `GLOBAL_STORAGE_CLASS`, `GLOBAL_CONFIG_SYS`, `GLOBAL_SERVER_CONFIG` | `crates/ecstore/src/config`, `crates/config`, `rustfs/src/app/context/runtime_sources.rs` | Runtime migration target | Tier config manager reads and reloads now use the ECStore runtime-source helper; move remaining config state through config/runtime-source owners only, without combining storage-class behavior or persistence changes. |
|
||||
| `GLOBAL_EVENT_NOTIFIER`, `GLOBAL_NOTIFICATION_SYS` | `crates/ecstore/src/runtime/global.rs`, `crates/ecstore/src/runtime/sources.rs`, and `crates/ecstore/src/services/*` | Runtime migration target | `GLOBAL_EVENT_NOTIFIER` and `GLOBAL_NOTIFICATION_SYS` access now stay behind ECStore runtime-source and notification owner helpers; move remaining notification ownership only through notify/runtime-source boundaries. |
|
||||
|
||||
+10
-17
@@ -356,7 +356,7 @@ fn resolve_boot_time_with(context: Option<Arc<AppContext>>) -> Option<SystemTime
|
||||
}
|
||||
|
||||
fn resolve_daily_tier_stats_with(context: Option<Arc<AppContext>>) -> Option<DailyAllTierStats> {
|
||||
context.map(|context| context.tier_stats().daily_all())
|
||||
context.map(|context| context.transition_state().daily_tier_stats())
|
||||
}
|
||||
|
||||
async fn resolve_scanner_metrics_report_with(context: Option<Arc<AppContext>>) -> Option<ScannerMetricsReport> {
|
||||
@@ -494,7 +494,7 @@ mod tests {
|
||||
EndpointsInterface, IamInterface, InternodeMetricsInterface, KmsInterface, KmsRuntimeInterface, LocalNodeNameInterface,
|
||||
LockClientInterface, LockClientsInterface, OidcInterface, OutboundTlsRuntimeInterface, PerformanceMetricsInterface,
|
||||
RegionInterface, ReplicationStatsInterface, RuntimePortInterface, S3SelectDbInterface, ScannerMetricsInterface,
|
||||
ServerConfigInterface, StorageClassInterface, TierConfigInterface, TierStatsInterface, TransitionStateInterface,
|
||||
ServerConfigInterface, StorageClassInterface, TierConfigInterface, TransitionStateInterface,
|
||||
};
|
||||
use crate::config::{RustFSBufferConfig, WorkloadProfile};
|
||||
use async_trait::async_trait;
|
||||
@@ -625,16 +625,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
struct TestTierStatsInterface {
|
||||
daily_stats: DailyAllTierStats,
|
||||
}
|
||||
|
||||
impl TierStatsInterface for TestTierStatsInterface {
|
||||
fn daily_all(&self) -> DailyAllTierStats {
|
||||
self.daily_stats.clone()
|
||||
}
|
||||
}
|
||||
|
||||
struct TestScannerMetricsInterface {
|
||||
report: ScannerMetricsReport,
|
||||
}
|
||||
@@ -809,12 +799,17 @@ mod tests {
|
||||
|
||||
struct TestTransitionStateInterface {
|
||||
transition_state: Arc<TransitionState>,
|
||||
daily_stats: DailyAllTierStats,
|
||||
}
|
||||
|
||||
impl TransitionStateInterface for TestTransitionStateInterface {
|
||||
fn handle(&self) -> Arc<TransitionState> {
|
||||
self.transition_state.clone()
|
||||
}
|
||||
|
||||
fn daily_tier_stats(&self) -> DailyAllTierStats {
|
||||
self.daily_stats.clone()
|
||||
}
|
||||
}
|
||||
|
||||
struct TestServerConfigInterface {
|
||||
@@ -948,8 +943,6 @@ mod tests {
|
||||
let bucket_metadata = Arc::new(RwLock::new(BucketMetadataSys::new(object_store.clone())));
|
||||
let context_replication_stats = Arc::new(ReplicationStats::new());
|
||||
let context_boot_time = SystemTime::UNIX_EPOCH + Duration::from_secs(10);
|
||||
let mut context_daily_tier_stats = DailyAllTierStats::new();
|
||||
context_daily_tier_stats.insert("CONTEXT".to_string(), Default::default());
|
||||
let context_scanner_metrics = ScannerMetricsReport {
|
||||
current_cycle: 7,
|
||||
..Default::default()
|
||||
@@ -957,6 +950,8 @@ mod tests {
|
||||
let tier_config = TierConfigMgr::new();
|
||||
let context_expiry_state = ExpiryState::new();
|
||||
let context_transition_state = TransitionState::new();
|
||||
let mut context_daily_tier_stats = DailyAllTierStats::new();
|
||||
context_daily_tier_stats.insert("CONTEXT".to_string(), Default::default());
|
||||
let server_config = Config::new();
|
||||
let context_server_config_published = Arc::new(AtomicUsize::new(0));
|
||||
let context_storage_class_published = Arc::new(AtomicUsize::new(0));
|
||||
@@ -1022,9 +1017,6 @@ mod tests {
|
||||
boot_time: Arc::new(TestBootTimeInterface {
|
||||
boot_time: Some(context_boot_time),
|
||||
}),
|
||||
tier_stats: Arc::new(TestTierStatsInterface {
|
||||
daily_stats: context_daily_tier_stats.clone(),
|
||||
}),
|
||||
scanner_metrics: Arc::new(TestScannerMetricsInterface {
|
||||
report: context_scanner_metrics.clone(),
|
||||
}),
|
||||
@@ -1069,6 +1061,7 @@ mod tests {
|
||||
}),
|
||||
transition_state: Arc::new(TestTransitionStateInterface {
|
||||
transition_state: context_transition_state.clone(),
|
||||
daily_stats: context_daily_tier_stats.clone(),
|
||||
}),
|
||||
server_config: Arc::new(TestServerConfigInterface {
|
||||
config: Some(server_config.clone()),
|
||||
|
||||
@@ -23,8 +23,7 @@ use super::handles::{
|
||||
default_outbound_tls_runtime_interface, default_performance_metrics_interface, default_region_interface,
|
||||
default_replication_pool_interface, default_replication_stats_interface, default_runtime_port_interface,
|
||||
default_s3select_db_interface, default_scanner_metrics_interface, default_server_config_interface,
|
||||
default_storage_class_interface, default_tier_config_interface, default_tier_stats_interface,
|
||||
default_transition_state_interface, oidc_interface,
|
||||
default_storage_class_interface, default_tier_config_interface, default_transition_state_interface, oidc_interface,
|
||||
};
|
||||
use super::interfaces::{
|
||||
ActionCredentialInterface, BootTimeInterface, BucketMetadataInterface, BucketMonitorInterface, BufferConfigInterface,
|
||||
@@ -32,7 +31,7 @@ use super::interfaces::{
|
||||
KmsRuntimeInterface, LocalNodeNameInterface, LockClientInterface, LockClientsInterface, NotificationSystemInterface,
|
||||
NotifyInterface, OidcInterface, OutboundTlsRuntimeInterface, PerformanceMetricsInterface, RegionInterface,
|
||||
ReplicationPoolInterface, ReplicationStatsInterface, RuntimePortInterface, S3SelectDbInterface, ScannerMetricsInterface,
|
||||
ServerConfigInterface, StorageClassInterface, TierConfigInterface, TierStatsInterface, TransitionStateInterface,
|
||||
ServerConfigInterface, StorageClassInterface, TierConfigInterface, TransitionStateInterface,
|
||||
};
|
||||
use rustfs_iam::{oidc::OidcSys, store::object::ObjectStore, sys::IamSys};
|
||||
use rustfs_kms::KmsServiceManager;
|
||||
@@ -55,7 +54,6 @@ pub struct AppContext {
|
||||
replication_pool: Arc<dyn ReplicationPoolInterface>,
|
||||
replication_stats: Arc<dyn ReplicationStatsInterface>,
|
||||
boot_time: Arc<dyn BootTimeInterface>,
|
||||
tier_stats: Arc<dyn TierStatsInterface>,
|
||||
scanner_metrics: Arc<dyn ScannerMetricsInterface>,
|
||||
endpoints: Arc<dyn EndpointsInterface>,
|
||||
deployment_id: Arc<dyn DeploymentIdInterface>,
|
||||
@@ -92,7 +90,6 @@ impl AppContext {
|
||||
replication_pool: default_replication_pool_interface(),
|
||||
replication_stats: default_replication_stats_interface(),
|
||||
boot_time: default_boot_time_interface(),
|
||||
tier_stats: default_tier_stats_interface(),
|
||||
scanner_metrics: default_scanner_metrics_interface(),
|
||||
endpoints: default_endpoints_interface(),
|
||||
deployment_id: default_deployment_id_interface(),
|
||||
@@ -181,10 +178,6 @@ impl AppContext {
|
||||
self.boot_time.clone()
|
||||
}
|
||||
|
||||
pub fn tier_stats(&self) -> Arc<dyn TierStatsInterface> {
|
||||
self.tier_stats.clone()
|
||||
}
|
||||
|
||||
pub fn scanner_metrics(&self) -> Arc<dyn ScannerMetricsInterface> {
|
||||
self.scanner_metrics.clone()
|
||||
}
|
||||
@@ -272,7 +265,6 @@ pub(super) struct AppContextTestInterfaces {
|
||||
pub(super) replication_pool: Arc<dyn ReplicationPoolInterface>,
|
||||
pub(super) replication_stats: Arc<dyn ReplicationStatsInterface>,
|
||||
pub(super) boot_time: Arc<dyn BootTimeInterface>,
|
||||
pub(super) tier_stats: Arc<dyn TierStatsInterface>,
|
||||
pub(super) scanner_metrics: Arc<dyn ScannerMetricsInterface>,
|
||||
pub(super) endpoints: Arc<dyn EndpointsInterface>,
|
||||
pub(super) deployment_id: Arc<dyn DeploymentIdInterface>,
|
||||
@@ -310,7 +302,6 @@ impl AppContext {
|
||||
replication_pool: interfaces.replication_pool,
|
||||
replication_stats: interfaces.replication_stats,
|
||||
boot_time: interfaces.boot_time,
|
||||
tier_stats: interfaces.tier_stats,
|
||||
scanner_metrics: interfaces.scanner_metrics,
|
||||
endpoints: interfaces.endpoints,
|
||||
deployment_id: interfaces.deployment_id,
|
||||
|
||||
@@ -24,7 +24,7 @@ use super::interfaces::{
|
||||
KmsRuntimeInterface, LocalNodeNameInterface, LockClientInterface, LockClientsInterface, NotificationSystemInterface,
|
||||
NotifyInterface, OidcInterface, OutboundTlsRuntimeInterface, PerformanceMetricsInterface, RegionInterface,
|
||||
ReplicationPoolInterface, ReplicationStatsInterface, RuntimePortInterface, S3SelectDbInterface, ScannerMetricsInterface,
|
||||
ServerConfigInterface, StorageClassInterface, TierConfigInterface, TierStatsInterface, TransitionStateInterface,
|
||||
ServerConfigInterface, StorageClassInterface, TierConfigInterface, TransitionStateInterface,
|
||||
};
|
||||
use super::runtime_sources;
|
||||
use crate::config::RustFSBufferConfig;
|
||||
@@ -233,16 +233,6 @@ impl BootTimeInterface for BootTimeHandle {
|
||||
}
|
||||
}
|
||||
|
||||
/// Default tier transition statistics interface adapter.
|
||||
#[derive(Default)]
|
||||
pub struct TierStatsHandle;
|
||||
|
||||
impl TierStatsInterface for TierStatsHandle {
|
||||
fn daily_all(&self) -> DailyAllTierStats {
|
||||
runtime_sources::daily_tier_stats()
|
||||
}
|
||||
}
|
||||
|
||||
/// Default scanner metrics report interface adapter.
|
||||
#[derive(Default)]
|
||||
pub struct ScannerMetricsHandle;
|
||||
@@ -398,6 +388,10 @@ impl TransitionStateInterface for TransitionStateHandle {
|
||||
fn handle(&self) -> Arc<TransitionState> {
|
||||
runtime_sources::transition_state()
|
||||
}
|
||||
|
||||
fn daily_tier_stats(&self) -> DailyAllTierStats {
|
||||
runtime_sources::daily_tier_stats()
|
||||
}
|
||||
}
|
||||
|
||||
/// Default server config interface adapter.
|
||||
@@ -470,10 +464,6 @@ pub fn default_boot_time_interface() -> Arc<dyn BootTimeInterface> {
|
||||
Arc::new(BootTimeHandle)
|
||||
}
|
||||
|
||||
pub fn default_tier_stats_interface() -> Arc<dyn TierStatsInterface> {
|
||||
Arc::new(TierStatsHandle)
|
||||
}
|
||||
|
||||
pub fn default_scanner_metrics_interface() -> Arc<dyn ScannerMetricsInterface> {
|
||||
Arc::new(ScannerMetricsHandle)
|
||||
}
|
||||
|
||||
@@ -115,11 +115,6 @@ pub trait BootTimeInterface: Send + Sync {
|
||||
fn get(&self) -> Option<SystemTime>;
|
||||
}
|
||||
|
||||
/// Tier transition statistics interface for admin metric integration.
|
||||
pub trait TierStatsInterface: Send + Sync {
|
||||
fn daily_all(&self) -> DailyAllTierStats;
|
||||
}
|
||||
|
||||
/// Scanner metrics report interface for admin status integration.
|
||||
#[async_trait]
|
||||
pub trait ScannerMetricsInterface: Send + Sync {
|
||||
@@ -200,6 +195,7 @@ pub trait ExpiryStateInterface: Send + Sync {
|
||||
/// Lifecycle transition state interface for transition queues and tier stats.
|
||||
pub trait TransitionStateInterface: Send + Sync {
|
||||
fn handle(&self) -> Arc<TransitionState>;
|
||||
fn daily_tier_stats(&self) -> DailyAllTierStats;
|
||||
}
|
||||
|
||||
/// Server config interface for application-layer and server modules.
|
||||
|
||||
@@ -19,10 +19,10 @@ use super::super::storage_api::context::bucket::metadata_sys::BucketMetadataSys;
|
||||
use super::super::storage_api::context::runtime::{
|
||||
BucketBandwidthMonitor, DailyAllTierStats, DynReplicationPool, ExpiryState, NotificationSys, ReplicationStats,
|
||||
ScannerMetricsReport, StorageClassConfig, TierConfigMgr, TransitionState, collect_scanner_metrics_report,
|
||||
get_daily_all_tier_stats, get_global_boot_time, get_global_bucket_monitor, get_global_deployment_id,
|
||||
get_global_endpoints_opt, get_global_expiry_state, get_global_lock_client, get_global_lock_clients,
|
||||
get_global_notification_sys, get_global_region, get_global_replication_pool, get_global_replication_stats,
|
||||
get_global_tier_config_mgr, get_global_transition_state, global_rustfs_port, set_global_storage_class,
|
||||
get_global_boot_time, get_global_bucket_monitor, get_global_deployment_id, get_global_endpoints_opt, get_global_expiry_state,
|
||||
get_global_lock_client, get_global_lock_clients, get_global_notification_sys, get_global_region, get_global_replication_pool,
|
||||
get_global_replication_stats, get_global_tier_config_mgr, get_global_transition_state, global_rustfs_port,
|
||||
set_global_storage_class,
|
||||
};
|
||||
use crate::config::{RustFSBufferConfig, get_global_buffer_config};
|
||||
use rustfs_config::server_config::{Config, get_global_server_config, set_global_server_config};
|
||||
@@ -119,7 +119,7 @@ pub fn boot_time() -> Option<SystemTime> {
|
||||
}
|
||||
|
||||
pub fn daily_tier_stats() -> DailyAllTierStats {
|
||||
get_daily_all_tier_stats()
|
||||
get_global_transition_state().get_daily_all_tier_stats()
|
||||
}
|
||||
|
||||
pub async fn scanner_metrics_report() -> ScannerMetricsReport {
|
||||
|
||||
@@ -205,10 +205,6 @@ pub(crate) mod runtime {
|
||||
crate::storage::storage_api::get_global_boot_time()
|
||||
}
|
||||
|
||||
pub(crate) fn get_daily_all_tier_stats() -> DailyAllTierStats {
|
||||
crate::storage::storage_api::get_daily_all_tier_stats()
|
||||
}
|
||||
|
||||
pub(crate) async fn collect_scanner_metrics_report() -> ScannerMetricsReport {
|
||||
rustfs_common::metrics::global_metrics().report().await
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ pub(crate) use storage_api::{
|
||||
ecstore_set_disk, ecstore_storage, ecstore_tier, encode_tags, find_local_disk_by_ref, get_bucket_accelerate_config,
|
||||
get_bucket_cors_config, get_bucket_logging_config, get_bucket_metadata, get_bucket_notification_config,
|
||||
get_bucket_object_lock_config, get_bucket_policy_raw, get_bucket_replication_config, get_bucket_request_payment_config,
|
||||
get_bucket_sse_config, get_bucket_website_config, get_daily_all_tier_stats, get_global_boot_time, get_global_bucket_monitor,
|
||||
get_global_deployment_id, get_global_endpoints_opt, get_global_expiry_state, get_global_lock_client, get_global_lock_clients,
|
||||
get_bucket_sse_config, get_bucket_website_config, get_global_boot_time, get_global_bucket_monitor, get_global_deployment_id,
|
||||
get_global_endpoints_opt, get_global_expiry_state, get_global_lock_client, get_global_lock_clients,
|
||||
get_global_notification_sys, get_global_region, get_global_replication_pool, get_global_replication_stats,
|
||||
get_global_tier_config_mgr, get_local_server_property, get_lock_acquire_timeout, get_public_access_block_config,
|
||||
global_rustfs_port, head_prefix_consumer, helper_consumer, init_background_replication, init_bucket_metadata_sys,
|
||||
|
||||
@@ -575,10 +575,6 @@ pub(crate) fn get_global_boot_time() -> Option<std::time::SystemTime> {
|
||||
ecstore_runtime::boot_time()
|
||||
}
|
||||
|
||||
pub(crate) fn get_daily_all_tier_stats() -> DailyAllTierStats {
|
||||
ecstore_bucket::lifecycle::bucket_lifecycle_ops::get_global_transition_state().get_daily_all_tier_stats()
|
||||
}
|
||||
|
||||
pub(crate) fn get_global_expiry_state() -> Arc<tokio::sync::RwLock<ExpiryState>> {
|
||||
ecstore_bucket::lifecycle::bucket_lifecycle_ops::get_global_expiry_state()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user