MySQL 8.0.40
Source Code Documentation
mysql_harness::EventStateTracker Class Reference

EventStateTracker singleton object keeps track of the current known state of selected event. More...

#include <event_state_tracker.h>

Public Types

enum class  EventId : size_t {
  MetadataServerConnectedOk , MetadataRefreshOk , GRMemberConnectedOk , MetadataNodeInGR ,
  GRNodeInMetadata , TargetClusterPresentInOptions , ClusterInvalidatedInMetadata , ClusterWasBootstrappedAgainstClusterset ,
  NoRightsToUpdateRouterAttributes
}
 List of the events that can currently be tracked. More...
 

Public Member Functions

bool state_changed (const int state, const EventId event_id, const std::string &additional_tag="")
 Returns information about the selected event state change (and sets the new state of event if changed). More...
 
void remove_tag (const std::string &tag)
 Remove the state for a given tag for all event_id that it has registered. More...
 
void clear ()
 Remove stored state for all events. More...
 

Static Public Member Functions

static EventStateTrackerinstance ()
 Get the singleton object of EventStateTracker. More...
 

Private Types

using Key = std::pair< size_t, size_t >
 

Private Member Functions

 EventStateTracker ()=default
 
 EventStateTracker (const EventStateTracker &)=delete
 
EventStateTracker operator= (const EventStateTracker &)=delete
 

Private Attributes

std::map< Key, int > events_
 
std::mutex events_mtx_
 

Detailed Description

EventStateTracker singleton object keeps track of the current known state of selected event.

Can be used to track the changes of the state of selected event (for conditional logging etc.)

Member Typedef Documentation

◆ Key

using mysql_harness::EventStateTracker::Key = std::pair<size_t, size_t>
private

Member Enumeration Documentation

◆ EventId

enum class mysql_harness::EventStateTracker::EventId : size_t
strong

List of the events that can currently be tracked.

Enumerator
MetadataServerConnectedOk 
MetadataRefreshOk 
GRMemberConnectedOk 
MetadataNodeInGR 
GRNodeInMetadata 
TargetClusterPresentInOptions 
ClusterInvalidatedInMetadata 
ClusterWasBootstrappedAgainstClusterset 
NoRightsToUpdateRouterAttributes 

Constructor & Destructor Documentation

◆ EventStateTracker() [1/2]

mysql_harness::EventStateTracker::EventStateTracker ( )
privatedefault

◆ EventStateTracker() [2/2]

mysql_harness::EventStateTracker::EventStateTracker ( const EventStateTracker )
privatedelete

Member Function Documentation

◆ clear()

void mysql_harness::EventStateTracker::clear ( )

Remove stored state for all events.

◆ instance()

EventStateTracker & mysql_harness::EventStateTracker::instance ( )
static

Get the singleton object of EventStateTracker.

◆ operator=()

EventStateTracker mysql_harness::EventStateTracker::operator= ( const EventStateTracker )
privatedelete

◆ remove_tag()

void mysql_harness::EventStateTracker::remove_tag ( const std::string &  tag)

Remove the state for a given tag for all event_id that it has registered.

Parameters
tagtag of the events being removed

◆ state_changed()

bool mysql_harness::EventStateTracker::state_changed ( const int  state,
const EventId  event_id,
const std::string &  additional_tag = "" 
)

Returns information about the selected event state change (and sets the new state of event if changed).

Parameters
statecurrent state of the event
event_idid of the event
additional_tagoptional tag
Returns
information about the event state change
Return values
truethe event state has changed since the last call
falsethe event state has NOT changed since the last call

Member Data Documentation

◆ events_

std::map<Key, int> mysql_harness::EventStateTracker::events_
private

◆ events_mtx_

std::mutex mysql_harness::EventStateTracker::events_mtx_
private

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