drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
replication_slave.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_consumer.h>
24
#include <plugin/slave/queue_producer.h>
25
#include <plugin/slave/replication_schema.h>
26
#include <drizzled/plugin/daemon.h>
27
#include <boost/thread.hpp>
28
#include <unordered_map>
29
30
namespace
drizzled
31
{
32
class
Session
;
33
}
34
35
namespace
slave
36
{
37
38
class
ReplicationSlave :
public
drizzled::plugin::Daemon
39
{
40
public
:
41
42
ReplicationSlave(
const
std::string &config)
43
:
drizzled::plugin::Daemon
(
"replication_slave"
),
44
_config_file
(config)
45
{}
46
47
~ReplicationSlave()
48
{
49
_consumer_thread
.interrupt();
50
51
std::unordered_map<uint32_t, Master *>::const_iterator it;
52
53
for
(it=
_masters
.begin(); it !=
_masters
.end(); ++it)
54
{
55
it->second->thread().interrupt();
56
}
57
}
58
60
void
startup
(
drizzled::Session
&session);
61
62
private
:
63
67
class
Master
68
{
69
public
:
70
Master(uint32_t
id
)
71
{
72
_producer
.setMasterId(
id
);
73
}
74
75
QueueProducer
&producer()
76
{
77
return
_producer
;
78
}
79
80
boost::thread &thread()
81
{
82
return
_producer_thread
;
83
}
84
85
void
start()
86
{
87
_producer_thread
= boost::thread(&QueueProducer::run, &
_producer
);
88
}
89
90
private
:
92
QueueProducer
_producer
;
93
95
boost::thread
_producer_thread
;
96
};
97
99
std::string
_config_file
;
100
101
std::string _error;
102
104
QueueConsumer
_consumer
;
105
110
boost::thread
_consumer_thread
;
111
113
std::unordered_map<uint32_t, Master *>
_masters
;
114
116
Master
&
master
(
size_t
index)
117
{
118
return
*(
_masters
[index]);
119
}
120
130
bool
initWithConfig
();
131
};
132
133
}
/* namespace slave */
134
drizzled::Session
Definition
session.h:82
drizzled::plugin::Daemon
Definition
daemon.h:32
slave::QueueConsumer
Definition
queue_consumer.h:40
slave::QueueProducer
Definition
queue_producer.h:34
slave::ReplicationSlave::Master
Definition
replication_slave.h:68
slave::ReplicationSlave::Master::_producer
QueueProducer _producer
Definition
replication_slave.h:92
slave::ReplicationSlave::Master::_producer_thread
boost::thread _producer_thread
Definition
replication_slave.h:95
slave::ReplicationSlave::_masters
std::unordered_map< uint32_t, Master * > _masters
Definition
replication_slave.h:113
slave::ReplicationSlave::initWithConfig
bool initWithConfig()
Definition
replication_slave.cc:61
slave::ReplicationSlave::_config_file
std::string _config_file
Definition
replication_slave.h:99
slave::ReplicationSlave::master
Master & master(size_t index)
Definition
replication_slave.h:116
slave::ReplicationSlave::startup
void startup(drizzled::Session &session)
Definition
replication_slave.cc:38
slave::ReplicationSlave::_consumer_thread
boost::thread _consumer_thread
Definition
replication_slave.h:110
slave::ReplicationSlave::_consumer
QueueConsumer _consumer
Definition
replication_slave.h:104
drizzled
TODO: Rename this file - func.h is stupid.
Definition
abort_exception.h:27
← Back to Drizzle docs
plugin
slave
replication_slave.h
Generated by
1.15.0