drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
slave::QueueProducer Class Reference
Inheritance diagram for slave::QueueProducer:
[legend]
Collaboration diagram for slave::QueueProducer:
[legend]

Public Member Functions

bool init ()
bool process ()
void shutdown ()
void setSleepInterval (uint32_t seconds)
uint32_t getSleepInterval ()
void setMasterHost (const std::string &host)
void setMasterPort (uint16_t port)
void setMasterUser (const std::string &user)
void setMasterPassword (const std::string &password)
void setMaxReconnectAttempts (uint32_t max)
void setSecondsBetweenReconnects (uint32_t seconds)
void setCachedMaxCommitId (uint64_t value)
uint64_t cachedMaxCommitId ()
void setMasterId (uint32_t value)
uint32_t masterId ()
Public Member Functions inherited from slave::QueueThread
void run (void)
Public Member Functions inherited from slave::SQLExecutor
 SQLExecutor (const std::string &user, const std::string &schema)
void markInErrorState ()
void clearErrorState ()
const std::string & getErrorMessage () const
bool executeSQL (std::vector< std::string > &sql)

Private Member Functions

bool openConnection ()
bool closeConnection ()
bool reconnect (bool initial_connection)
bool queryForMaxCommitId (uint64_t *max_commit_id)
enum drizzled::error_t queryForReplicationEvents (uint64_t max_commit_id)
bool queryForTrxIdList (uint64_t max_commit_id, std::vector< uint64_t > &list)
bool queueInsert (const char *trx_id, const char *seg_id, const char *commit_id, const char *originating_server_uuid, const char *originating_commit_id, const char *msg, size_t msg_size)
void setIOState (const std::string &err_msg, bool status)

Private Attributes

uint32_t _check_interval
std::string _master_host
uint16_t _master_port
std::string _master_user
std::string _master_pass
uint32_t _master_id
std::unique_ptr< drizzle_st, decltype(&drizzle_free)> _drizzle
drizzle_con_st * _connection
drizzle_return_t _last_return
bool _is_connected
uint64_t _saved_max_commit_id
uint32_t _max_reconnects
uint32_t _seconds_between_reconnects
std::string _last_error_message

Additional Inherited Members

Protected Attributes inherited from slave::SQLExecutor
drizzled::Session::shared_ptr _session

Detailed Description

Definition at line 33 of file queue_producer.h.

Constructor & Destructor Documentation

◆ QueueProducer()

slave::QueueProducer::QueueProducer ( )
inline

Definition at line 36 of file queue_producer.h.

◆ ~QueueProducer()

slave::QueueProducer::~QueueProducer ( )
virtual

Definition at line 42 of file queue_producer.cc.

Member Function Documentation

◆ cachedMaxCommitId()

uint64_t slave::QueueProducer::cachedMaxCommitId ( )
inline

Definition at line 101 of file queue_producer.h.

◆ closeConnection()

bool slave::QueueProducer::closeConnection ( )
private

Close connection to the master server.

Definition at line 197 of file queue_producer.cc.

◆ getSleepInterval()

uint32_t slave::QueueProducer::getSleepInterval ( )
inlinevirtual

Implements slave::QueueThread.

Definition at line 61 of file queue_producer.h.

◆ init()

bool slave::QueueProducer::init ( )
virtual

Do any initialization work.

Return values
trueSuccess
falseFailure

Reimplemented from slave::QueueThread.

Definition at line 48 of file queue_producer.cc.

◆ masterId()

uint32_t slave::QueueProducer::masterId ( )
inline

Definition at line 111 of file queue_producer.h.

◆ openConnection()

bool slave::QueueProducer::openConnection ( )
private

Open connection to the master server.

Definition at line 148 of file queue_producer.cc.

◆ process()

bool slave::QueueProducer::process ( )
virtual

Method that actually does the work around the queue.

Returning 'false' from this method currently causes the thread to shutdown.

Return values
trueSuccess
falseFailure

Implements slave::QueueThread.

Definition at line 54 of file queue_producer.cc.

◆ queryForMaxCommitId()

bool slave::QueueProducer::queryForMaxCommitId ( uint64_t * max_commit_id)
private

Get maximum commit ID that we have stored locally on the slave.

This method determines where this slave is in relation to the master, or, in other words, how "caught up" we are.

Parameters
[out]max_commit_idMaximum commit ID we have on this slave.

Definition at line 208 of file queue_producer.cc.

◆ queryForReplicationEvents()

enum drizzled::error_t slave::QueueProducer::queryForReplicationEvents ( uint64_t max_commit_id)
private

Get replication events/messages from the master.

Calling this method will a limited number of events from the master. It should be repeatedly called until it returns -1, which means there were no more events to retrieve.

Parameters
[in]max_commit_idLargest commit ID we have stored locally.
Return values
EE_OKSuccessfully retrieved events
ER_NONo errors, but no more events to retrieve
ER_YESError

Definition at line 406 of file queue_producer.cc.

◆ queryForTrxIdList()

bool slave::QueueProducer::queryForTrxIdList ( uint64_t max_commit_id,
std::vector< uint64_t > & list )
private

Definition at line 254 of file queue_producer.cc.

◆ queueInsert()

bool slave::QueueProducer::queueInsert ( const char * trx_id,
const char * seg_id,
const char * commit_id,
const char * originating_server_uuid,
const char * originating_commit_id,
const char * msg,
size_t msg_size )
private

Definition at line 306 of file queue_producer.cc.

◆ reconnect()

bool slave::QueueProducer::reconnect ( bool initial_connection)
private

Attempt to reconnect to the master server.

This method does not return until reconnect succeeds, or we exceed our maximum number of retries defined by _max_reconnects.

Return values
trueReconnect succeeded
falseReconnect failed

Definition at line 116 of file queue_producer.cc.

◆ setCachedMaxCommitId()

void slave::QueueProducer::setCachedMaxCommitId ( uint64_t value)
inline

Definition at line 96 of file queue_producer.h.

◆ setIOState()

void slave::QueueProducer::setIOState ( const std::string & err_msg,
bool status )
private

Update IO thread status in state table.

Parameters
err_msgError message string
statusfalse = STOPPED, true = RUNNING

Definition at line 488 of file queue_producer.cc.

◆ setMasterHost()

void slave::QueueProducer::setMasterHost ( const std::string & host)
inline

Definition at line 66 of file queue_producer.h.

◆ setMasterId()

void slave::QueueProducer::setMasterId ( uint32_t value)
inline

Definition at line 106 of file queue_producer.h.

◆ setMasterPassword()

void slave::QueueProducer::setMasterPassword ( const std::string & password)
inline

Definition at line 81 of file queue_producer.h.

◆ setMasterPort()

void slave::QueueProducer::setMasterPort ( uint16_t port)
inline

Definition at line 71 of file queue_producer.h.

◆ setMasterUser()

void slave::QueueProducer::setMasterUser ( const std::string & user)
inline

Definition at line 76 of file queue_producer.h.

◆ setMaxReconnectAttempts()

void slave::QueueProducer::setMaxReconnectAttempts ( uint32_t max)
inline

Definition at line 86 of file queue_producer.h.

◆ setSecondsBetweenReconnects()

void slave::QueueProducer::setSecondsBetweenReconnects ( uint32_t seconds)
inline

Definition at line 91 of file queue_producer.h.

◆ setSleepInterval()

void slave::QueueProducer::setSleepInterval ( uint32_t seconds)
inline

Definition at line 56 of file queue_producer.h.

◆ shutdown()

void slave::QueueProducer::shutdown ( )
virtual

Work to do at thread shutdown time.

Reimplemented from slave::QueueThread.

Definition at line 109 of file queue_producer.cc.

Member Data Documentation

◆ _check_interval

uint32_t slave::QueueProducer::_check_interval
private

Number of seconds to sleep between checking queue for messages

Definition at line 118 of file queue_producer.h.

◆ _connection

drizzle_con_st* slave::QueueProducer::_connection
private

Definition at line 129 of file queue_producer.h.

◆ _drizzle

std::unique_ptr<drizzle_st, decltype(&drizzle_free)> slave::QueueProducer::_drizzle
private

Definition at line 128 of file queue_producer.h.

◆ _is_connected

bool slave::QueueProducer::_is_connected
private

Definition at line 132 of file queue_producer.h.

◆ _last_error_message

std::string slave::QueueProducer::_last_error_message
private

Definition at line 137 of file queue_producer.h.

◆ _last_return

drizzle_return_t slave::QueueProducer::_last_return
private

Definition at line 130 of file queue_producer.h.

◆ _master_host

std::string slave::QueueProducer::_master_host
private

Definition at line 121 of file queue_producer.h.

◆ _master_id

uint32_t slave::QueueProducer::_master_id
private

Definition at line 126 of file queue_producer.h.

◆ _master_pass

std::string slave::QueueProducer::_master_pass
private

Definition at line 124 of file queue_producer.h.

◆ _master_port

uint16_t slave::QueueProducer::_master_port
private

Definition at line 122 of file queue_producer.h.

◆ _master_user

std::string slave::QueueProducer::_master_user
private

Definition at line 123 of file queue_producer.h.

◆ _max_reconnects

uint32_t slave::QueueProducer::_max_reconnects
private

Definition at line 134 of file queue_producer.h.

◆ _saved_max_commit_id

uint64_t slave::QueueProducer::_saved_max_commit_id
private

Definition at line 133 of file queue_producer.h.

◆ _seconds_between_reconnects

uint32_t slave::QueueProducer::_seconds_between_reconnects
private

Definition at line 135 of file queue_producer.h.


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