quantrs2_anneal/realtime_hardware_monitoring/
alerts.rs1use super::types::*;
4use std::collections::{HashMap, VecDeque};
5use std::sync::Arc;
6use std::time::Duration;
7
8pub struct AlertSystem {
10 pub config: AlertConfig,
12 pub active_alerts: HashMap<String, Alert>,
14 pub alert_history: VecDeque<Alert>,
16 pub handlers: Vec<Box<dyn AlertHandler>>,
18 pub statistics: AlertStatistics,
20}
21
22impl AlertSystem {
23 pub(crate) fn new() -> Self {
24 Self {
25 config: AlertConfig::default(),
26 active_alerts: HashMap::new(),
27 alert_history: VecDeque::new(),
28 handlers: vec![],
29 statistics: AlertStatistics::default(),
30 }
31 }
32}
33
34impl Default for AlertConfig {
35 fn default() -> Self {
36 Self {
37 max_active_alerts: 100,
38 aggregation_window: Duration::from_secs(60),
39 suppression_rules: vec![],
40 escalation_rules: vec![],
41 }
42 }
43}
44
45impl Default for AlertStatistics {
46 fn default() -> Self {
47 Self {
48 total_alerts: 0,
49 alerts_by_level: HashMap::new(),
50 alerts_by_device: HashMap::new(),
51 avg_resolution_time: Duration::from_secs(0),
52 false_positive_rate: 0.0,
53 }
54 }
55}
56
57pub struct PredictiveFailureDetector {
59 pub config: FailureDetectionConfig,
61 pub models: HashMap<String, PredictionModel>,
63 pub failure_history: VecDeque<FailureEvent>,
65 pub current_predictions: HashMap<String, FailurePrediction>,
67 pub model_performance: HashMap<String, ModelPerformance>,
69}
70
71impl PredictiveFailureDetector {
72 pub(crate) fn new() -> Self {
73 Self {
74 config: FailureDetectionConfig::default(),
75 models: HashMap::new(),
76 failure_history: VecDeque::new(),
77 current_predictions: HashMap::new(),
78 model_performance: HashMap::new(),
79 }
80 }
81}
82
83impl Default for FailureDetectionConfig {
84 fn default() -> Self {
85 Self {
86 prediction_horizon: Duration::from_secs(3600),
87 confidence_threshold: 0.8,
88 model_update_frequency: Duration::from_secs(1800),
89 feature_window: Duration::from_secs(600),
90 }
91 }
92}
93
94pub struct RealTimePerformanceOptimizer {
96 pub config: OptimizerConfig,
98 pub strategies: Vec<OptimizationStrategy>,
100 pub baselines: HashMap<String, PerformanceBaseline>,
102 pub active_optimizations: HashMap<String, ActiveOptimization>,
104 pub optimization_history: VecDeque<OptimizationResult>,
106}
107
108impl RealTimePerformanceOptimizer {
109 pub(crate) fn new() -> Self {
110 Self {
111 config: OptimizerConfig::default(),
112 strategies: vec![],
113 baselines: HashMap::new(),
114 active_optimizations: HashMap::new(),
115 optimization_history: VecDeque::new(),
116 }
117 }
118}
119
120impl Default for OptimizerConfig {
121 fn default() -> Self {
122 Self {
123 optimization_frequency: Duration::from_secs(300),
124 improvement_threshold: 0.05,
125 max_concurrent_optimizations: 3,
126 optimization_timeout: Duration::from_secs(600),
127 }
128 }
129}