00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #pragma once
00022
00023 #include <plugin/slave/queue_thread.h>
00024 #include <plugin/slave/sql_executor.h>
00025 #include <drizzled/session.h>
00026 #include <string>
00027
00028 namespace drizzled
00029 {
00030 namespace message
00031 {
00032 class Transaction;
00033 }
00034 }
00035
00036 namespace slave
00037 {
00038
00039 class QueueConsumer : public QueueThread, public SQLExecutor
00040 {
00041 public:
00042 QueueConsumer() :
00043 QueueThread(),
00044 SQLExecutor("slave", "replication"),
00045 _check_interval(5),
00046 _ignore_errors(false)
00047 { }
00048
00049 bool init();
00050 bool process();
00051 void shutdown();
00052
00053 void setSleepInterval(uint32_t seconds)
00054 {
00055 _check_interval= seconds;
00056 }
00057
00058 uint32_t getSleepInterval()
00059 {
00060 return _check_interval;
00061 }
00062
00066 void setIgnoreErrors(bool value)
00067 {
00068 _ignore_errors= value;
00069 }
00070
00077 void setApplierState(const std::string &err_msg, bool status);
00078
00079 void addMasterId(uint32_t id)
00080 {
00081 _master_ids.push_back(id);
00082 }
00083
00084 bool processSingleMaster(const std::string &master_id);
00085
00086 private:
00087 typedef std::vector<uint64_t> TrxIdList;
00088
00090 uint32_t _check_interval;
00091
00092 std::vector<uint32_t> _master_ids;
00093
00094 bool _ignore_errors;
00095
00108 bool getListOfCompletedTransactions(const std::string &master_id,
00109 TrxIdList &list);
00110
00111 bool getMessage(drizzled::message::Transaction &transaction,
00112 std::string &commit_id,
00113 const std::string &master_id,
00114 uint64_t trx_id,
00115 std::string &originating_server_uuid,
00116 uint64_t &originating_commit_id,
00117 uint32_t segment_id);
00118
00129 bool convertToSQL(const drizzled::message::Transaction &transaction,
00130 std::vector<std::string> &aggregate_sql,
00131 std::vector<std::string> &segmented_sql);
00132
00146 bool executeSQLWithCommitId(std::vector<std::string> &sql,
00147 const std::string &commit_id,
00148 const std::string &originating_server_uuid,
00149 uint64_t originating_commit_id,
00150 const std::string &master_id);
00151
00160 bool deleteFromQueue(const std::string &master_id, uint64_t trx_id);
00161
00168 bool isEndStatement(const drizzled::message::Statement &statement);
00169 };
00170
00171 }
00172