~clint-fewbar/drizzle/regex-policy-cache-limiter

« back to all changes in this revision

Viewing changes to plugin/slave/queue_consumer.h

  • Committer: Clint Byrum
  • Date: 2012-03-15 18:05:43 UTC
  • mfrom: (2224.1.302 workspace)
  • Revision ID: clint@ubuntu.com-20120315180543-9jxxm4q10k3np2ws
merging with latest trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#ifndef PLUGIN_SLAVE_QUEUE_CONSUMER_H
22
 
#define PLUGIN_SLAVE_QUEUE_CONSUMER_H
 
21
#pragma once
23
22
 
24
23
#include <plugin/slave/queue_thread.h>
25
24
#include <plugin/slave/sql_executor.h>
26
25
#include <drizzled/session.h>
 
26
#include <string>
27
27
 
28
28
namespace drizzled
29
29
{
42
42
  QueueConsumer() :
43
43
    QueueThread(),
44
44
    SQLExecutor("slave", "replication"),
45
 
    _check_interval(5)
 
45
    _check_interval(5),
 
46
    _ignore_errors(false)
46
47
  { }
47
48
 
48
49
  bool init();
60
61
  }
61
62
  
62
63
  /**
 
64
   * Determines if we should ignore errors from statements pulled from masters.
 
65
   */
 
66
  void setIgnoreErrors(bool value)
 
67
  {
 
68
    _ignore_errors= value;
 
69
  }
 
70
 
 
71
  /**
63
72
   * Update applier status in state table.
64
73
   *
65
74
   * @param err_msg Error message string
67
76
   */
68
77
  void setApplierState(const std::string &err_msg, bool status);
69
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
 
70
86
private:
71
87
  typedef std::vector<uint64_t> TrxIdList;
72
88
 
73
89
  /** Number of seconds to sleep between checking queue for messages */
74
90
  uint32_t _check_interval;
75
91
 
76
 
  bool getListOfCompletedTransactions(TrxIdList &list);
 
92
  std::vector<uint32_t> _master_ids;
 
93
 
 
94
  bool _ignore_errors;
 
95
 
 
96
  /**
 
97
   * Get a list of transaction IDs from the queue that are complete.
 
98
   *
 
99
   * A "complete" transaction is one in which we have received the end
 
100
   * segment of the transaction.
 
101
   *
 
102
   * @param[in] master_id Identifier of the master we are interested in.
 
103
   * @param[out] list The list to populate with transaction IDs.
 
104
   *
 
105
   * @retval true Success
 
106
   * @retval false Error
 
107
   */
 
108
  bool getListOfCompletedTransactions(const std::string &master_id,
 
109
                                      TrxIdList &list);
77
110
 
78
111
  bool getMessage(drizzled::message::Transaction &transaction,
79
112
                  std::string &commit_id,
 
113
                  const std::string &master_id,
80
114
                  uint64_t trx_id,
 
115
                  std::string &originating_server_uuid,
 
116
                  uint64_t &originating_commit_id,
81
117
                  uint32_t segment_id);
82
118
 
83
119
  /**
99
135
   *
100
136
   * @param sql Batch of SQL statements to execute.
101
137
   * @param commit_id Commit ID value to store in state table.
 
138
   * @param originating_server_uuid Server ID of the master where
 
139
   *   this SQL was originally applied.
 
140
   * @param originating_commit_id Commit ID of the master where
 
141
   *   this SQL was originally applied.
102
142
   *
103
143
   * @retval true Success
104
144
   * @retval false Failure
105
145
   */
106
146
  bool executeSQLWithCommitId(std::vector<std::string> &sql,
107
 
                              const std::string &commit_id);
 
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);
108
151
  
109
152
  /**
110
153
   * Remove messages for a given transaction from the queue.
114
157
   * @retval true Success
115
158
   * @retval false Failure
116
159
   */
117
 
  bool deleteFromQueue(uint64_t trx_id);
 
160
  bool deleteFromQueue(const std::string &master_id, uint64_t trx_id);
118
161
 
119
162
  /**
120
163
   * Determine if a Statement message is an end message.
127
170
 
128
171
} /* namespace slave */
129
172
 
130
 
#endif /* PLUGIN_SLAVE_QUEUE_CONSUMER_H */