41
42
ReplicationSlave(const std::string &config)
42
43
: drizzled::plugin::Daemon("Replication Slave"),
44
_initial_max_commit_id(0)
47
47
~ReplicationSlave()
49
49
_consumer_thread.interrupt();
50
_producer_thread.interrupt();
51
boost::unordered_map<uint32_t, Master *>::const_iterator it;
53
for (it= _masters.begin(); it != _masters.end(); ++it)
55
it->second->thread().interrupt();
59
/** Gets called after all plugins are initialized */
53
60
void startup(drizzled::Session &session);
56
* Get the error message describing what went wrong during setup.
58
const std::string &getError() const
64
* Set the initial value for the slave's maximum commit ID.
66
* This value basically determines where to start retrieving events from
67
* the master. Normally this is computed automatically based on the
68
* contents of the queue and/or the last applied commit ID. This allows
69
* us to override those values and start from another point. E.g., new
70
* slave provisioning or skipping a trouble statement.
72
* @param[in] value The commit ID value.
74
void setMaxCommitId(uint64_t value)
76
/* must tell producer to set its cached value */
77
_producer.setCachedMaxCommitId(value);
78
/* setting this indicates that we should store it permanently */
79
_initial_max_commit_id= value;
65
* Class representing a master server.
72
_producer.setMasterId(id);
75
QueueProducer &producer()
80
boost::thread &thread()
82
return _producer_thread;
87
_producer_thread= boost::thread(&QueueProducer::run, &_producer);
91
/** Manages a single master */
92
QueueProducer _producer;
94
/** I/O thread that will populate the work queue */
95
boost::thread _producer_thread;
98
/** Configuration file containing master info */
83
99
std::string _config_file;
84
101
std::string _error;
103
/** Object to use with the consumer thread */
86
104
QueueConsumer _consumer;
87
QueueProducer _producer;
89
/** Applier thread that will drain the work queue */
107
* Applier thread that will drain the work queue.
108
* @todo Support more than one consumer thread.
90
110
boost::thread _consumer_thread;
92
/** I/O thread that will populate the work queue */
93
boost::thread _producer_thread;
112
/** List of master objects, one per master */
113
boost::unordered_map<uint32_t, Master *> _masters;
95
uint64_t _initial_max_commit_id;
115
/** Convenience method to get object reference */
116
Master &master(size_t index)
118
return *(_masters[index]);
98
122
* Initialize slave services with the given configuration file.
100
* In case of an error during initialization, you can call the getError()
101
* method to get a string describing what went wrong.
124
* In case of an error during initialization, _error contains a
125
* string describing what went wrong.
103
127
* @retval true Success
104
128
* @retval false Failure