Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
kcenon::monitoring::data_consistency_manager Class Reference

Data consistency manager coordinating transaction managers and validators. More...

#include <data_consistency.h>

Collaboration diagram for kcenon::monitoring::data_consistency_manager:
Collaboration graph

Public Member Functions

 data_consistency_manager (const std::string &name)
 
common::VoidResult add_transaction_manager (const std::string &name, const transaction_config &config)
 
transaction_managerget_transaction_manager (const std::string &name)
 
common::VoidResult add_state_validator (const std::string &name, const validation_config &config)
 
state_validatorget_state_validator (const std::string &name)
 
common::VoidResult start_all_validators ()
 
common::VoidResult stop_all_validators ()
 
common::Result< bool > is_healthy () const
 
std::unordered_map< std::string, std::string > get_all_metrics () const
 

Private Attributes

std::string name_
 
std::mutex mutex_
 
std::unordered_map< std::string, std::shared_ptr< transaction_manager > > transaction_managers_
 
std::unordered_map< std::string, std::shared_ptr< state_validator > > state_validators_
 

Detailed Description

Data consistency manager coordinating transaction managers and validators.

Definition at line 477 of file data_consistency.h.

Constructor & Destructor Documentation

◆ data_consistency_manager()

kcenon::monitoring::data_consistency_manager::data_consistency_manager ( const std::string & name)
inlineexplicit

Definition at line 479 of file data_consistency.h.

Member Function Documentation

◆ add_state_validator()

common::VoidResult kcenon::monitoring::data_consistency_manager::add_state_validator ( const std::string & name,
const validation_config & config )
inline

Definition at line 507 of file data_consistency.h.

508 {
509 std::unique_lock<std::mutex> lock(mutex_);
510
511 if (state_validators_.find(name) != state_validators_.end()) {
512 return common::VoidResult::err(common::error_info(
514 "State validator '" + name + "' already exists",
515 "monitoring_system"));
516 }
517
518 state_validators_[name] = std::make_shared<state_validator>(name, config);
519 return common::ok();
520 }
std::unordered_map< std::string, std::shared_ptr< state_validator > > state_validators_

References kcenon::monitoring::already_exists, mutex_, and state_validators_.

Referenced by TEST_F(), TEST_F(), TEST_F(), and TEST_F().

Here is the caller graph for this function:

◆ add_transaction_manager()

common::VoidResult kcenon::monitoring::data_consistency_manager::add_transaction_manager ( const std::string & name,
const transaction_config & config )
inline

Definition at line 482 of file data_consistency.h.

483 {
484 std::unique_lock<std::mutex> lock(mutex_);
485
486 if (transaction_managers_.find(name) != transaction_managers_.end()) {
487 return common::VoidResult::err(common::error_info(
489 "Transaction manager '" + name + "' already exists",
490 "monitoring_system"));
491 }
492
493 transaction_managers_[name] = std::make_shared<transaction_manager>(name, config);
494 return common::ok();
495 }
std::unordered_map< std::string, std::shared_ptr< transaction_manager > > transaction_managers_

References kcenon::monitoring::already_exists, mutex_, and transaction_managers_.

Referenced by TEST_F(), TEST_F(), and TEST_F().

Here is the caller graph for this function:

◆ get_all_metrics()

std::unordered_map< std::string, std::string > kcenon::monitoring::data_consistency_manager::get_all_metrics ( ) const
inline

Definition at line 557 of file data_consistency.h.

557 {
558 std::unordered_map<std::string, std::string> all_metrics;
559
560 for (const auto& [name, manager] : transaction_managers_) {
561 all_metrics[name + "_transactions"] = std::to_string(manager->get_metrics().total_transactions.load());
562 }
563
564 for (const auto& [name, validator] : state_validators_) {
565 all_metrics[name + "_validation"] = std::to_string(validator->get_metrics().validation_runs.load());
566 }
567
568 return all_metrics;
569 }

References state_validators_, and transaction_managers_.

Referenced by TEST_F().

Here is the caller graph for this function:

◆ get_state_validator()

state_validator * kcenon::monitoring::data_consistency_manager::get_state_validator ( const std::string & name)
inline

Definition at line 522 of file data_consistency.h.

522 {
523 std::unique_lock<std::mutex> lock(mutex_);
524
525 auto it = state_validators_.find(name);
526 if (it == state_validators_.end()) {
527 return nullptr;
528 }
529 return it->second.get();
530 }

References mutex_, and state_validators_.

Referenced by TEST_F().

Here is the caller graph for this function:

◆ get_transaction_manager()

transaction_manager * kcenon::monitoring::data_consistency_manager::get_transaction_manager ( const std::string & name)
inline

Definition at line 497 of file data_consistency.h.

497 {
498 std::unique_lock<std::mutex> lock(mutex_);
499
500 auto it = transaction_managers_.find(name);
501 if (it == transaction_managers_.end()) {
502 return nullptr;
503 }
504 return it->second.get();
505 }

References mutex_, and transaction_managers_.

Referenced by TEST_F().

Here is the caller graph for this function:

◆ is_healthy()

common::Result< bool > kcenon::monitoring::data_consistency_manager::is_healthy ( ) const
inline

Definition at line 553 of file data_consistency.h.

553 {
554 return common::ok(true);
555 }

Referenced by TEST_F().

Here is the caller graph for this function:

◆ start_all_validators()

common::VoidResult kcenon::monitoring::data_consistency_manager::start_all_validators ( )
inline

Definition at line 532 of file data_consistency.h.

532 {
533 std::unique_lock<std::mutex> lock(mutex_);
534
535 for (auto& [name, validator] : state_validators_) {
536 auto result = validator->start();
537 if (!result.is_ok()) {
538 return result;
539 }
540 }
541 return common::ok();
542 }

References mutex_, and state_validators_.

Referenced by TEST_F().

Here is the caller graph for this function:

◆ stop_all_validators()

common::VoidResult kcenon::monitoring::data_consistency_manager::stop_all_validators ( )
inline

Definition at line 544 of file data_consistency.h.

544 {
545 std::unique_lock<std::mutex> lock(mutex_);
546
547 for (auto& [name, validator] : state_validators_) {
548 validator->stop();
549 }
550 return common::ok();
551 }

References mutex_, and state_validators_.

Referenced by TEST_F().

Here is the caller graph for this function:

Member Data Documentation

◆ mutex_

std::mutex kcenon::monitoring::data_consistency_manager::mutex_
private

◆ name_

std::string kcenon::monitoring::data_consistency_manager::name_
private

Definition at line 572 of file data_consistency.h.

◆ state_validators_

std::unordered_map<std::string, std::shared_ptr<state_validator> > kcenon::monitoring::data_consistency_manager::state_validators_
private

◆ transaction_managers_

std::unordered_map<std::string, std::shared_ptr<transaction_manager> > kcenon::monitoring::data_consistency_manager::transaction_managers_
private

The documentation for this class was generated from the following file: