|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Graceful degradation manager. More...
#include <graceful_degradation.h>

Public Member Functions | |
| graceful_degradation_manager () | |
| graceful_degradation_manager (const std::string &name) | |
| common::VoidResult | register_service (const service_config &config) |
| Register a service for management. | |
| common::VoidResult | unregister_service (const std::string &name) |
| Unregister a service. | |
| common::VoidResult | degrade_service (const std::string &name, degradation_level level, const std::string &reason) |
| Degrade a specific service. | |
| common::VoidResult | recover_service (const std::string &name) |
| Recover a specific service to normal operation. | |
| common::VoidResult | recover_all_services () |
| Recover all services to normal operation. | |
| degradation_level | get_service_level (const std::string &name) const |
| Get current degradation level for a service. | |
| common::VoidResult | add_degradation_plan (const degradation_plan &plan) |
| Add a degradation plan. | |
| common::VoidResult | execute_plan (const std::string &plan_name, const std::string &reason) |
| Execute a degradation plan. | |
| common::Result< bool > | is_healthy () const |
| Check if the manager is healthy (more than 50% services at normal level) | |
| graceful_degradation_metrics | get_metrics () const |
| Get metrics. | |
| const std::string & | get_name () const |
| Get manager name. | |
| std::vector< std::string > | get_service_names () const |
| Get all registered service names. | |
Private Attributes | |
| std::string | name_ |
| std::mutex | mutex_ |
| std::unordered_map< std::string, service_state > | services_ |
| std::unordered_map< std::string, degradation_plan > | plans_ |
| graceful_degradation_metrics | metrics_ |
Graceful degradation manager.
Manages service degradation and recovery in a coordinated manner.
Definition at line 118 of file graceful_degradation.h.
|
inline |
Definition at line 120 of file graceful_degradation.h.
|
inlineexplicit |
Definition at line 122 of file graceful_degradation.h.
|
inline |
Add a degradation plan.
Definition at line 233 of file graceful_degradation.h.
References kcenon::monitoring::invalid_configuration, mutex_, kcenon::monitoring::degradation_plan::name, plans_, and kcenon::monitoring::degradation_plan::validate().

|
inline |
Degrade a specific service.
Definition at line 164 of file graceful_degradation.h.
References kcenon::monitoring::graceful_degradation_metrics::failed_degradations, metrics_, mutex_, kcenon::monitoring::not_found, services_, kcenon::monitoring::graceful_degradation_metrics::successful_degradations, and kcenon::monitoring::graceful_degradation_metrics::total_degradations.
|
inline |
Execute a degradation plan.
Definition at line 246 of file graceful_degradation.h.
References kcenon::monitoring::emergency, metrics_, mutex_, kcenon::monitoring::not_found, plans_, services_, kcenon::monitoring::graceful_degradation_metrics::successful_degradations, and kcenon::monitoring::graceful_degradation_metrics::total_degradations.
|
inline |
|
inline |
Get manager name.
Definition at line 313 of file graceful_degradation.h.
References name_.
Referenced by TEST_F().

|
inline |
Get current degradation level for a service.
Definition at line 221 of file graceful_degradation.h.
References mutex_, kcenon::monitoring::normal, and services_.
|
inline |
Get all registered service names.
Definition at line 320 of file graceful_degradation.h.
|
inline |
Check if the manager is healthy (more than 50% services at normal level)
Definition at line 286 of file graceful_degradation.h.
References mutex_, kcenon::monitoring::normal, and services_.
|
inline |
Recover all services to normal operation.
Definition at line 206 of file graceful_degradation.h.
References metrics_, mutex_, kcenon::monitoring::normal, kcenon::monitoring::graceful_degradation_metrics::recovery_attempts, services_, and kcenon::monitoring::graceful_degradation_metrics::successful_recoveries.
|
inline |
Recover a specific service to normal operation.
Definition at line 186 of file graceful_degradation.h.
References metrics_, mutex_, kcenon::monitoring::normal, kcenon::monitoring::not_found, kcenon::monitoring::graceful_degradation_metrics::recovery_attempts, services_, and kcenon::monitoring::graceful_degradation_metrics::successful_recoveries.
|
inline |
Register a service for management.
Definition at line 127 of file graceful_degradation.h.
References kcenon::monitoring::already_exists, kcenon::monitoring::service_state::config, kcenon::monitoring::service_state::current_level, kcenon::monitoring::invalid_configuration, kcenon::monitoring::service_state::last_state_change, mutex_, kcenon::monitoring::service_config::name, kcenon::monitoring::normal, services_, and kcenon::monitoring::service_config::validate().

|
inline |
Unregister a service.
Definition at line 150 of file graceful_degradation.h.
References mutex_, kcenon::monitoring::not_found, and services_.
|
mutableprivate |
Definition at line 335 of file graceful_degradation.h.
Referenced by degrade_service(), execute_plan(), get_metrics(), recover_all_services(), and recover_service().
|
mutableprivate |
Definition at line 332 of file graceful_degradation.h.
Referenced by add_degradation_plan(), degrade_service(), execute_plan(), get_service_level(), get_service_names(), is_healthy(), recover_all_services(), recover_service(), register_service(), and unregister_service().
|
private |
Definition at line 331 of file graceful_degradation.h.
Referenced by get_name().
|
private |
Definition at line 334 of file graceful_degradation.h.
Referenced by add_degradation_plan(), and execute_plan().
|
private |
Definition at line 333 of file graceful_degradation.h.
Referenced by degrade_service(), execute_plan(), get_service_level(), get_service_names(), is_healthy(), recover_all_services(), recover_service(), register_service(), and unregister_service().