drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
queue_consumer.h
1/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2011 David Shrewsbury
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#pragma once
22
23#include <plugin/slave/queue_thread.h>
24#include <plugin/slave/sql_executor.h>
25#include <drizzled/session.h>
26#include <string>
27
28namespace drizzled
29{
30 namespace message
31 {
32 class Transaction;
33 }
34}
35
36namespace slave
37{
38
39class QueueConsumer : public QueueThread, public SQLExecutor
40{
41public:
42 QueueConsumer() :
44 SQLExecutor("slave", "replication"),
46 _ignore_errors(false)
47 { }
48
49 bool init();
50 bool process();
51 void shutdown();
52
53 void setSleepInterval(uint32_t seconds)
54 {
55 _check_interval= seconds;
56 }
57
58 uint32_t getSleepInterval()
59 {
60 return _check_interval;
61 }
62
66 void setIgnoreErrors(bool value)
67 {
68 _ignore_errors= value;
69 }
70
77 void setApplierState(const std::string &err_msg, bool status);
78
79 void addMasterId(uint32_t id)
80 {
81 _master_ids.push_back(id);
82 }
83
84 bool processSingleMaster(const std::string &master_id);
85
86private:
87 typedef std::vector<uint64_t> TrxIdList;
88
91
92 std::vector<uint32_t> _master_ids;
93
94 bool _ignore_errors;
95
108 bool getListOfCompletedTransactions(const std::string &master_id,
109 TrxIdList &list);
110
111 bool getMessage(drizzled::message::Transaction &transaction,
112 std::string &commit_id,
113 const std::string &master_id,
114 uint64_t trx_id,
115 std::string &originating_server_uuid,
116 uint64_t &originating_commit_id,
117 uint32_t segment_id);
118
129 bool convertToSQL(const drizzled::message::Transaction &transaction,
130 std::vector<std::string> &aggregate_sql,
131 std::vector<std::string> &segmented_sql);
132
146 bool executeSQLWithCommitId(std::vector<std::string> &sql,
147 const std::string &commit_id,
148 const std::string &originating_server_uuid,
149 uint64_t originating_commit_id,
150 const std::string &master_id);
151
160 bool deleteFromQueue(const std::string &master_id, uint64_t trx_id);
161
168 bool isEndStatement(const drizzled::message::Statement &statement);
169};
170
171} /* namespace slave */
172
bool convertToSQL(const drizzled::message::Transaction &transaction, std::vector< std::string > &aggregate_sql, std::vector< std::string > &segmented_sql)
bool executeSQLWithCommitId(std::vector< std::string > &sql, const std::string &commit_id, const std::string &originating_server_uuid, uint64_t originating_commit_id, const std::string &master_id)
bool deleteFromQueue(const std::string &master_id, uint64_t trx_id)
bool getListOfCompletedTransactions(const std::string &master_id, TrxIdList &list)
void setApplierState(const std::string &err_msg, bool status)
bool isEndStatement(const drizzled::message::Statement &statement)
void setIgnoreErrors(bool value)
TODO: Rename this file - func.h is stupid.