1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2011 David Shrewsbury
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.
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.
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
21
#ifndef PLUGIN_SLAVE_QUEUE_PRODUCER_H
22
#define PLUGIN_SLAVE_QUEUE_PRODUCER_H
24
#include <plugin/slave/queue_thread.h>
25
#include <plugin/slave/sql_executor.h>
26
#include <client/client_priv.h>
33
class QueueProducer : public QueueThread, public SQLExecutor
37
SQLExecutor("slave", "replication"),
40
_last_return(DRIZZLE_RETURN_OK),
42
_saved_max_commit_id(0),
44
_seconds_between_reconnects(30)
47
virtual ~QueueProducer();
53
void setSleepInterval(uint32_t seconds)
55
_check_interval= seconds;
58
uint32_t getSleepInterval()
60
return _check_interval;
63
void setMasterHost(const std::string &host)
68
void setMasterPort(uint16_t port)
73
void setMasterUser(const std::string &user)
78
void setMasterPassword(const std::string &password)
80
_master_pass= password;
83
void setMaxReconnectAttempts(uint32_t max)
88
void setSecondsBetweenReconnects(uint32_t seconds)
90
_seconds_between_reconnects= seconds;
94
/** Number of seconds to sleep between checking queue for messages */
95
uint32_t _check_interval;
97
/* Master server connection parameters */
98
std::string _master_host;
99
uint16_t _master_port;
100
std::string _master_user;
101
std::string _master_pass;
104
drizzle_con_st _connection;
105
drizzle_return_t _last_return;
108
uint64_t _saved_max_commit_id;
109
uint32_t _max_reconnects;
110
uint32_t _seconds_between_reconnects;
112
std::string _last_error_message;
115
* Open connection to the master server.
117
bool openConnection();
120
* Close connection to the master server.
122
bool closeConnection();
125
* Attempt to reconnect to the master server.
127
* This method does not return until reconnect succeeds, or we exceed our
128
* maximum number of retries defined by _max_reconnects.
130
* @retval true Reconnect succeeded
131
* @retval false Reconnect failed
135
bool queryForMaxCommitId(uint64_t *max_commit_id);
136
bool queryForReplicationEvents(uint64_t max_commit_id);
137
bool queryForTrxIdList(uint64_t max_commit_id, std::vector<uint64_t> &list);
138
bool queueInsert(const char *trx_id,
140
const char *commit_id,
142
const char *msg_length);
145
* Update IO thread status in state table.
147
* @param err_msg Error message string
148
* @param status false = STOPPED, true = RUNNING
150
void setIOState(const std::string &err_msg, bool status);
154
} /* namespace slave */
156
#endif /* PLUGIN_SLAVE_QUEUE_PRODUCER_H */