~drizzle-trunk/drizzle/development

636.1.1 by Mark Atwood
add replicator plugin type
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
5
 *  Copyright (C) 2009-2010 Jay Pipes <jaypipes@gmail.com>
636.1.1 by Mark Atwood
add replicator plugin type
6
 *
1039.5.11 by Jay Pipes
Adds multi-value INSERT test, modifies TransactionServices to support UPDATE statements (though WHERE clause still not done...)
7
 *  Authors:
8
 *
1308.2.2 by Jay Pipes
Fixes transaction log/replication for multi-column primary keys. Changes CREATE SCHEMA to not use statement-base RAW_SQL and instead use a derived message::Statement subclass.
9
 *    Jay Pipes <jaypipes@gmail.com>
1039.5.11 by Jay Pipes
Adds multi-value INSERT test, modifies TransactionServices to support UPDATE statements (though WHERE clause still not done...)
10
 *
636.1.1 by Mark Atwood
add replicator plugin type
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
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
25
#pragma once
636.1.1 by Mark Atwood
add replicator plugin type
26
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
27
#include <drizzled/atomics.h>
28
#include <drizzled/plugin/replication.h>
1143.2.10 by Jay Pipes
Phase 2 new replication work:
29
1405.6.1 by Jay Pipes
This patch adds the following functionality:
30
#include <string>
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
31
#include <vector>
1405.6.1 by Jay Pipes
This patch adds the following functionality:
32
#include <utility>
636.1.1 by Mark Atwood
add replicator plugin type
33
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
34
#include <drizzled/visibility.h>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
35
2252.1.16 by Olaf van der Spek
Common fwd
36
namespace drizzled {
1130.1.2 by Monty Taylor
Re-org'd the replication stuff into slots.
37
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
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
 */
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
43
class DRIZZLED_API ReplicationServices
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
44
{
1039.5.19 by Jay Pipes
Per Stew's suggestions in code review:
45
public:
1039.5.39 by Jay Pipes
This patch does a couple things in preparation for publisher and
46
  typedef uint64_t GlobalTransactionId;
1143.2.15 by Jay Pipes
This patch does the following:
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
  };
1405.6.1 by Jay Pipes
This patch adds the following functionality:
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
   */
2318.6.72 by Olaf van der Spek
Refactor
72
  static bool evaluateRegisteredPlugins();
1336.2.2 by Jay Pipes
NO CODE CHANGES - Simply moves pieces of ReplicationServices to TransactionServices. Preparation for making the ReplicationServices component only responsible for communication between replicators, appliers, publishers, and subscribers.
73
  /** 
74
   * Helper method which pushes a constructed message out to the registered
75
   * replicator and applier plugins.
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
76
   *
1405.3.3 by Jay Pipes
Adds Session reference to replication API
77
   * @param Session descriptor
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
78
   * @param Message to push out
79
   */
2318.6.72 by Olaf van der Spek
Refactor
80
  static plugin::ReplicationReturnCode pushTransactionMessage(Session &in_session, message::Transaction &to_push);
1130.1.2 by Monty Taylor
Re-org'd the replication stuff into slots.
81
1039.5.5 by Jay Pipes
This commit does two things:
82
  /**
1039.5.31 by Jay Pipes
This patch does a few things:
83
   * Returns whether the ReplicationServices object
1039.5.5 by Jay Pipes
This commit does two things:
84
   * is active.  In other words, does it have both
85
   * a replicator and an applier that are *active*?
86
   */
2318.6.72 by Olaf van der Spek
Refactor
87
  static bool isActive();
1405.6.1 by Jay Pipes
This patch adds the following functionality:
88
89
  /**
90
   * Returns the list of replication streams
91
   */
2318.6.72 by Olaf van der Spek
Refactor
92
  static ReplicationStreams &getReplicationStreams();
1405.6.1 by Jay Pipes
This patch adds the following functionality:
93
1039.5.5 by Jay Pipes
This commit does two things:
94
  /**
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
95
   * Attaches a replicator to our internal collection of
96
   * replicators.
97
   *
98
   * @param Pointer to a replicator to attach/register
99
   */
2318.6.72 by Olaf van der Spek
Refactor
100
  static void attachReplicator(plugin::TransactionReplicator *in_replicator);
1405.6.1 by Jay Pipes
This patch adds the following functionality:
101
  
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
102
  /**
103
   * Detaches/unregisters a replicator with our internal
104
   * collection of replicators.
105
   *
106
   * @param Pointer to the replicator to detach
107
   */
2318.6.72 by Olaf van der Spek
Refactor
108
  static void detachReplicator(plugin::TransactionReplicator *in_replicator);
1405.6.1 by Jay Pipes
This patch adds the following functionality:
109
  
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
110
  /**
111
   * Attaches a applier to our internal collection of
112
   * appliers.
113
   *
114
   * @param Pointer to a applier to attach/register
1405.6.1 by Jay Pipes
This patch adds the following functionality:
115
   * @param The name of the replicator to pair with
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
116
   */
2318.6.72 by Olaf van der Spek
Refactor
117
  static void attachApplier(plugin::TransactionApplier *in_applier, const std::string &requested_replicator);
1405.6.1 by Jay Pipes
This patch adds the following functionality:
118
  
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
119
  /**
120
   * Detaches/unregisters a applier with our internal
121
   * collection of appliers.
122
   *
123
   * @param Pointer to the applier to detach
124
   */
2318.6.72 by Olaf van der Spek
Refactor
125
  static void detachApplier(plugin::TransactionApplier *in_applier);
1405.6.1 by Jay Pipes
This patch adds the following functionality:
126
127
  /** 
128
   * Returns the timestamp of the last Transaction which was sent to an
1336.2.2 by Jay Pipes
NO CODE CHANGES - Simply moves pieces of ReplicationServices to TransactionServices. Preparation for making the ReplicationServices component only responsible for communication between replicators, appliers, publishers, and subscribers.
129
   * applier.
1039.5.31 by Jay Pipes
This patch does a few things:
130
   */
2318.6.72 by Olaf van der Spek
Refactor
131
  static uint64_t getLastAppliedTimestamp();
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
132
};
133
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
134
} /* namespace drizzled */
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
135