#include <replication_services.h>
Public Types | |
enum | MessageType { TRANSACTION = 1, BLOB = 2 } |
typedef uint64_t | GlobalTransactionId |
typedef std::pair < plugin::TransactionReplicator *, plugin::TransactionApplier * > | ReplicationPair |
typedef std::vector < ReplicationPair > | ReplicationStreams |
Public Member Functions | |
bool | evaluateRegisteredPlugins () |
plugin::ReplicationReturnCode | pushTransactionMessage (Session &in_session, message::Transaction &to_push) |
ReplicationServices () | |
bool | isActive () const |
ReplicationStreams & | getReplicationStreams () |
void | attachReplicator (plugin::TransactionReplicator *in_replicator) |
void | detachReplicator (plugin::TransactionReplicator *in_replicator) |
void | attachApplier (plugin::TransactionApplier *in_applier, const std::string &requested_replicator) |
void | detachApplier (plugin::TransactionApplier *in_applier) |
uint64_t | getLastAppliedTimestamp () const |
Static Public Member Functions | |
static ReplicationServices & | singleton () |
Private Types | |
typedef std::vector < plugin::TransactionReplicator * > | Replicators |
typedef std::vector< std::pair < std::string, plugin::TransactionApplier * > > | Appliers |
Private Member Functions | |
void | normalizeReplicatorName (std::string &name) |
Private Attributes | |
bool | is_active |
atomic< uint64_t > | last_applied_timestamp |
Replicators | replicators |
Appliers | appliers |
ReplicationStreams | replication_streams |
This is a class which manages transforming internal transactional events into GPB messages and sending those events out through registered replicators and appliers.
Definition at line 58 of file replication_services.h.
Types of messages that can go in the transaction log file. Every time something is written into the transaction log, it is preceded by a header containing the type of message which follows.
Definition at line 68 of file replication_services.h.
Constructor
Definition at line 55 of file replication_services.cc.
void drizzled::ReplicationServices::attachApplier | ( | plugin::TransactionApplier * | in_applier, |
const std::string & | requested_replicator | ||
) |
Attaches a applier to our internal collection of appliers.
Pointer | to a applier to attach/register |
The | name of the replicator to pair with |
Definition at line 153 of file replication_services.cc.
References appliers.
void drizzled::ReplicationServices::attachReplicator | ( | plugin::TransactionReplicator * | in_replicator | ) |
Attaches a replicator to our internal collection of replicators.
Pointer | to a replicator to attach/register |
Definition at line 143 of file replication_services.cc.
References replicators.
void drizzled::ReplicationServices::detachApplier | ( | plugin::TransactionApplier * | in_applier | ) |
Detaches/unregisters a applier with our internal collection of appliers.
Pointer | to the applier to detach |
Definition at line 158 of file replication_services.cc.
void drizzled::ReplicationServices::detachReplicator | ( | plugin::TransactionReplicator * | in_replicator | ) |
Detaches/unregisters a replicator with our internal collection of replicators.
Pointer | to the replicator to detach |
Definition at line 148 of file replication_services.cc.
References replicators.
Method which is called after plugins have been loaded but before the first client connects. It determines if the registration of applier and replicator plugins is proper and pairs the applier and requested replicator plugins into the replication streams.
This is only necessary because we don't yet have plugin dependency tracking...
Definition at line 78 of file replication_services.cc.
References appliers, is_active, normalizeReplicatorName(), replication_streams, and replicators.
uint64_t drizzled::ReplicationServices::getLastAppliedTimestamp | ( | ) | const |
Returns the timestamp of the last Transaction which was sent to an applier.
ReplicationServices::ReplicationStreams & drizzled::ReplicationServices::getReplicationStreams | ( | ) |
Returns the list of replication streams
Definition at line 197 of file replication_services.cc.
References replication_streams.
bool drizzled::ReplicationServices::isActive | ( | ) | const |
Returns whether the ReplicationServices object is active. In other words, does it have both a replicator and an applier that are *active*?
Definition at line 162 of file replication_services.cc.
References is_active.
Referenced by drizzled::TransactionServices::alterSchema(), drizzled::TransactionServices::commitTransactionMessage(), drizzled::TransactionServices::createSchema(), drizzled::TransactionServices::createTable(), drizzled::TransactionServices::deleteRecord(), drizzled::TransactionServices::dropSchema(), drizzled::TransactionServices::dropTable(), drizzled::TransactionServices::insertRecord(), drizzled::TransactionServices::rollbackStatementMessage(), drizzled::TransactionServices::rollbackTransactionMessage(), drizzled::TransactionServices::sendEvent(), drizzled::TransactionServices::shouldConstructMessages(), drizzled::TransactionServices::truncateTable(), and drizzled::TransactionServices::updateRecord().
void drizzled::ReplicationServices::normalizeReplicatorName | ( | std::string & | name | ) | [private] |
Strips underscores and lowercases supplied replicator name or requested name, and appends the suffix "replicator" if missing...
Definition at line 60 of file replication_services.cc.
Referenced by evaluateRegisteredPlugins().
plugin::ReplicationReturnCode drizzled::ReplicationServices::pushTransactionMessage | ( | Session & | in_session, |
message::Transaction & | to_push | ||
) |
Helper method which pushes a constructed message out to the registered replicator and applier plugins.
Session | descriptor |
Message | to push out |
Definition at line 167 of file replication_services.cc.
References last_applied_timestamp, drizzled::plugin::TransactionReplicator::replicate(), and replication_streams.
Referenced by drizzled::TransactionServices::alterSchema(), drizzled::TransactionServices::commitTransactionMessage(), drizzled::TransactionServices::createSchema(), drizzled::TransactionServices::createTable(), drizzled::TransactionServices::dropSchema(), drizzled::TransactionServices::dropTable(), drizzled::TransactionServices::rollbackTransactionMessage(), drizzled::TransactionServices::sendEvent(), and drizzled::TransactionServices::truncateTable().
static ReplicationServices& drizzled::ReplicationServices::singleton | ( | ) | [inline, static] |
Singleton method Returns the singleton instance of ReplicationServices
Definition at line 106 of file replication_services.h.
Appliers drizzled::ReplicationServices::appliers [private] |
Our collection of registered applier plugins and their requested replicator plugin names
Definition at line 178 of file replication_services.h.
Referenced by attachApplier(), and evaluateRegisteredPlugins().
bool drizzled::ReplicationServices::is_active [private] |
Atomic boolean set to true if any *active* replicators or appliers are actually registered.
Definition at line 169 of file replication_services.h.
Referenced by evaluateRegisteredPlugins(), and isActive().
atomic<uint64_t> drizzled::ReplicationServices::last_applied_timestamp [private] |
The timestamp of the last time a Transaction message was successfully applied (sent to an Applier)
Definition at line 174 of file replication_services.h.
Referenced by pushTransactionMessage().
ReplicationStreams drizzled::ReplicationServices::replication_streams [private] |
Our replication streams
Definition at line 180 of file replication_services.h.
Referenced by evaluateRegisteredPlugins(), getReplicationStreams(), and pushTransactionMessage().
Replicators drizzled::ReplicationServices::replicators [private] |
Our collection of registered replicator plugins
Definition at line 176 of file replication_services.h.
Referenced by attachReplicator(), detachReplicator(), and evaluateRegisteredPlugins().