1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems, Inc.
5
* Copyright (C) 2009-2010 Jay Pipes <jaypipes@gmail.com>
9
* Jay Pipes <jaypipes@gmail.com>
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; version 2 of the License.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
#include <drizzled/atomics.h>
28
#include <drizzled/plugin/replication.h>
34
#include <drizzled/visibility.h>
39
* This is a class which manages transforming internal
40
* transactional events into GPB messages and sending those
41
* events out through registered replicators and appliers.
43
class DRIZZLED_API ReplicationServices
46
typedef uint64_t GlobalTransactionId;
48
* Types of messages that can go in the transaction
49
* log file. Every time something is written into the
50
* transaction log, it is preceded by a header containing
51
* the type of message which follows.
55
TRANSACTION= 1, /* A GPB Transaction Message */
56
BLOB= 2 /* A BLOB value */
58
typedef std::pair<plugin::TransactionReplicator *, plugin::TransactionApplier *> ReplicationPair;
59
typedef std::vector<ReplicationPair> ReplicationStreams;
61
* Method which is called after plugins have been loaded but
62
* before the first client connects. It determines if the registration
63
* of applier and replicator plugins is proper and pairs
64
* the applier and requested replicator plugins into the replication
69
* This is only necessary because we don't yet have plugin dependency
72
static bool evaluateRegisteredPlugins();
74
* Helper method which pushes a constructed message out to the registered
75
* replicator and applier plugins.
77
* @param Session descriptor
78
* @param Message to push out
80
static plugin::ReplicationReturnCode pushTransactionMessage(Session &in_session, message::Transaction &to_push);
83
* Returns whether the ReplicationServices object
84
* is active. In other words, does it have both
85
* a replicator and an applier that are *active*?
87
static bool isActive();
90
* Returns the list of replication streams
92
static ReplicationStreams &getReplicationStreams();
95
* Attaches a replicator to our internal collection of
98
* @param Pointer to a replicator to attach/register
100
static void attachReplicator(plugin::TransactionReplicator *in_replicator);
103
* Detaches/unregisters a replicator with our internal
104
* collection of replicators.
106
* @param Pointer to the replicator to detach
108
static void detachReplicator(plugin::TransactionReplicator *in_replicator);
111
* Attaches a applier to our internal collection of
114
* @param Pointer to a applier to attach/register
115
* @param The name of the replicator to pair with
117
static void attachApplier(plugin::TransactionApplier *in_applier, const std::string &requested_replicator);
120
* Detaches/unregisters a applier with our internal
121
* collection of appliers.
123
* @param Pointer to the applier to detach
125
static void detachApplier(plugin::TransactionApplier *in_applier);
128
* Returns the timestamp of the last Transaction which was sent to an
131
static uint64_t getLastAppliedTimestamp();
134
} /* namespace drizzled */