22 #ifndef _PLUGINS_MONGODB_MONGODB_REPLICASET_CONFIG_H_ 23 #define _PLUGINS_MONGODB_MONGODB_REPLICASET_CONFIG_H_ 25 #include <aspect/blackboard.h> 26 #include <aspect/clock.h> 27 #include <aspect/logging.h> 28 #include <core/threading/thread.h> 29 #include <interfaces/MongoDBManagedReplicaSetInterface.h> 30 #include <mongo/bson/bson.h> 31 #include <mongo/client/dbclient.h> 55 std::string bootstrap_database);
56 void bootstrap(std::shared_ptr<mongo::DBClientBase> bootstrap_client);
72 bool leader_elect(
bool force =
false);
75 struct ReplicaSetStatus
77 fawkes::MongoDBManagedReplicaSetInterface::ReplicaSetMemberStatus member_status;
78 fawkes::MongoDBManagedReplicaSetInterface::ReplicaSetPrimaryStatus primary_status;
79 std::string error_msg;
82 operator!=(
const ReplicaSetStatus &other)
const 84 return member_status != other.member_status || primary_status != other.primary_status
85 || error_msg != other.error_msg;
89 ReplicaSetStatus rs_status(mongo::BSONObj &reply);
91 void rs_monitor(
const mongo::BSONObj &reply);
92 bool check_alive(
const std::string &h);
93 bool rs_get_config(mongo::BSONObj &rs_config);
106 std::string config_name_;
108 std::shared_ptr<mongo::DBClientBase> bootstrap_client_;
109 mongo::BSONObj leader_elec_query_;
110 mongo::BSONObj leader_elec_query_force_;
111 mongo::BSONObj leader_elec_update_;
112 std::string bootstrap_database_;
113 std::string bootstrap_collection_;
114 std::string bootstrap_ns_;
116 std::string local_client_cfg_;
117 std::shared_ptr<mongo::DBClientBase> local_client_;
118 std::string local_hostport_;
119 std::set<std::string> hosts_;
122 float loop_interval_;
123 int leader_expiration_;
126 ReplicaSetStatus last_status_;
128 fawkes::MongoDBManagedReplicaSetInterface *rs_status_if_;
Thread aspect to access to BlackBoard.
Thread aspect that allows to obtain the current time from the clock.
Fawkes library namespace.
Thread class encapsulation of pthreads.
MongoDBReplicaSetConfig(fawkes::Configuration *config, std::string cfgname, std::string prefix, std::string bootstrap_database)
Constructor.
bool is_enabled() const
Check if configuration is enabled.
virtual void loop()
Code to execute in the thread.
MongoDB replica set configuration.
Thread aspect to log output.
void bootstrap(std::shared_ptr< mongo::DBClientBase > bootstrap_client)
Setup replicaset bootstrap client.
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual void init()
Initialize the thread.
Interface for configuration handling.
virtual void finalize()
Finalize the thread.