~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/replication_services.h

  • Committer: Daniel Nichter
  • Date: 2011-10-23 16:01:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2448.
  • Revision ID: daniel@percona.com-20111023160137-7ac3blgz8z4tf8za
Add Administration Getting Started and Logging.  Capitalize SQL clause keywords.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
 
5
 *  Copyright (C) 2009-2010 Jay Pipes <jaypipes@gmail.com>
 
6
 *
 
7
 *  Authors:
 
8
 *
 
9
 *    Jay Pipes <jaypipes@gmail.com>
 
10
 *
 
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.
 
14
 *
 
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.
 
19
 *
 
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
 
23
 */
 
24
 
 
25
#pragma once
 
26
 
 
27
#include <drizzled/atomics.h>
 
28
#include <drizzled/plugin/replication.h>
 
29
 
 
30
#include <string>
 
31
#include <vector>
 
32
#include <utility>
 
33
 
 
34
#include <drizzled/visibility.h>
 
35
 
 
36
namespace drizzled {
 
37
 
 
38
/**
 
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.
 
42
 */
 
43
class DRIZZLED_API ReplicationServices
 
44
{
 
45
public:
 
46
  typedef uint64_t GlobalTransactionId;
 
47
  /**
 
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.
 
52
   */
 
53
  enum MessageType
 
54
  {
 
55
    TRANSACTION= 1, /* A GPB Transaction Message */
 
56
    BLOB= 2 /* A BLOB value */
 
57
  };
 
58
  typedef std::pair<plugin::TransactionReplicator *, plugin::TransactionApplier *> ReplicationPair;
 
59
  typedef std::vector<ReplicationPair> ReplicationStreams;
 
60
  /**
 
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
 
65
   * streams.
 
66
   *
 
67
   * @todo
 
68
   *
 
69
   * This is only necessary because we don't yet have plugin dependency
 
70
   * tracking...
 
71
   */
 
72
  static bool evaluateRegisteredPlugins();
 
73
  /** 
 
74
   * Helper method which pushes a constructed message out to the registered
 
75
   * replicator and applier plugins.
 
76
   *
 
77
   * @param Session descriptor
 
78
   * @param Message to push out
 
79
   */
 
80
  static plugin::ReplicationReturnCode pushTransactionMessage(Session &in_session, message::Transaction &to_push);
 
81
 
 
82
  /**
 
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*?
 
86
   */
 
87
  static bool isActive();
 
88
 
 
89
  /**
 
90
   * Returns the list of replication streams
 
91
   */
 
92
  static ReplicationStreams &getReplicationStreams();
 
93
 
 
94
  /**
 
95
   * Attaches a replicator to our internal collection of
 
96
   * replicators.
 
97
   *
 
98
   * @param Pointer to a replicator to attach/register
 
99
   */
 
100
  static void attachReplicator(plugin::TransactionReplicator *in_replicator);
 
101
  
 
102
  /**
 
103
   * Detaches/unregisters a replicator with our internal
 
104
   * collection of replicators.
 
105
   *
 
106
   * @param Pointer to the replicator to detach
 
107
   */
 
108
  static void detachReplicator(plugin::TransactionReplicator *in_replicator);
 
109
  
 
110
  /**
 
111
   * Attaches a applier to our internal collection of
 
112
   * appliers.
 
113
   *
 
114
   * @param Pointer to a applier to attach/register
 
115
   * @param The name of the replicator to pair with
 
116
   */
 
117
  static void attachApplier(plugin::TransactionApplier *in_applier, const std::string &requested_replicator);
 
118
  
 
119
  /**
 
120
   * Detaches/unregisters a applier with our internal
 
121
   * collection of appliers.
 
122
   *
 
123
   * @param Pointer to the applier to detach
 
124
   */
 
125
  static void detachApplier(plugin::TransactionApplier *in_applier);
 
126
 
 
127
  /** 
 
128
   * Returns the timestamp of the last Transaction which was sent to an
 
129
   * applier.
 
130
   */
 
131
  static uint64_t getLastAppliedTimestamp();
 
132
};
 
133
 
 
134
} /* namespace drizzled */
 
135