~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>
2462.1.2 by Brian Aker
Remove common_fwd.h from visibility.h
35
#include <drizzled/common_fwd.h>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
36
2252.1.16 by Olaf van der Spek
Common fwd
37
namespace drizzled {
1130.1.2 by Monty Taylor
Re-org'd the replication stuff into slots.
38
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
39
/**
40
 * This is a class which manages transforming internal 
41
 * transactional events into GPB messages and sending those
42
 * events out through registered replicators and appliers.
43
 */
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
44
class DRIZZLED_API ReplicationServices
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
45
{
1039.5.19 by Jay Pipes
Per Stew's suggestions in code review:
46
public:
1039.5.39 by Jay Pipes
This patch does a couple things in preparation for publisher and
47
  typedef uint64_t GlobalTransactionId;
1143.2.15 by Jay Pipes
This patch does the following:
48
  /**
49
   * Types of messages that can go in the transaction
50
   * log file.  Every time something is written into the
51
   * transaction log, it is preceded by a header containing
52
   * the type of message which follows.
53
   */
54
  enum MessageType
55
  {
56
    TRANSACTION= 1, /* A GPB Transaction Message */
57
    BLOB= 2 /* A BLOB value */
58
  };
1405.6.1 by Jay Pipes
This patch adds the following functionality:
59
  typedef std::pair<plugin::TransactionReplicator *, plugin::TransactionApplier *> ReplicationPair;
60
  typedef std::vector<ReplicationPair> ReplicationStreams;
61
  /**
62
   * Method which is called after plugins have been loaded but
63
   * before the first client connects.  It determines if the registration
64
   * of applier and replicator plugins is proper and pairs
65
   * the applier and requested replicator plugins into the replication
66
   * streams.
67
   *
68
   * @todo
69
   *
70
   * This is only necessary because we don't yet have plugin dependency
71
   * tracking...
72
   */
2318.6.72 by Olaf van der Spek
Refactor
73
  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.
74
  /** 
75
   * Helper method which pushes a constructed message out to the registered
76
   * replicator and applier plugins.
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
77
   *
1405.3.3 by Jay Pipes
Adds Session reference to replication API
78
   * @param Session descriptor
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
79
   * @param Message to push out
80
   */
2318.6.72 by Olaf van der Spek
Refactor
81
  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.
82
1039.5.5 by Jay Pipes
This commit does two things:
83
  /**
1039.5.31 by Jay Pipes
This patch does a few things:
84
   * Returns whether the ReplicationServices object
1039.5.5 by Jay Pipes
This commit does two things:
85
   * is active.  In other words, does it have both
86
   * a replicator and an applier that are *active*?
87
   */
2318.6.72 by Olaf van der Spek
Refactor
88
  static bool isActive();
1405.6.1 by Jay Pipes
This patch adds the following functionality:
89
90
  /**
91
   * Returns the list of replication streams
92
   */
2318.6.72 by Olaf van der Spek
Refactor
93
  static ReplicationStreams &getReplicationStreams();
1405.6.1 by Jay Pipes
This patch adds the following functionality:
94
1039.5.5 by Jay Pipes
This commit does two things:
95
  /**
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
96
   * Attaches a replicator to our internal collection of
97
   * replicators.
98
   *
99
   * @param Pointer to a replicator to attach/register
100
   */
2318.6.72 by Olaf van der Spek
Refactor
101
  static void attachReplicator(plugin::TransactionReplicator *in_replicator);
1405.6.1 by Jay Pipes
This patch adds the following functionality:
102
  
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
103
  /**
104
   * Detaches/unregisters a replicator with our internal
105
   * collection of replicators.
106
   *
107
   * @param Pointer to the replicator to detach
108
   */
2318.6.72 by Olaf van der Spek
Refactor
109
  static void detachReplicator(plugin::TransactionReplicator *in_replicator);
1405.6.1 by Jay Pipes
This patch adds the following functionality:
110
  
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
111
  /**
112
   * Attaches a applier to our internal collection of
113
   * appliers.
114
   *
115
   * @param Pointer to a applier to attach/register
1405.6.1 by Jay Pipes
This patch adds the following functionality:
116
   * @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
117
   */
2318.6.72 by Olaf van der Spek
Refactor
118
  static void attachApplier(plugin::TransactionApplier *in_applier, const std::string &requested_replicator);
1405.6.1 by Jay Pipes
This patch adds the following functionality:
119
  
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
120
  /**
121
   * Detaches/unregisters a applier with our internal
122
   * collection of appliers.
123
   *
124
   * @param Pointer to the applier to detach
125
   */
2318.6.72 by Olaf van der Spek
Refactor
126
  static void detachApplier(plugin::TransactionApplier *in_applier);
1405.6.1 by Jay Pipes
This patch adds the following functionality:
127
128
  /** 
129
   * 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.
130
   * applier.
1039.5.31 by Jay Pipes
This patch does a few things:
131
   */
2318.6.72 by Olaf van der Spek
Refactor
132
  static uint64_t getLastAppliedTimestamp();
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
133
};
134
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
135
} /* namespace drizzled */
988.1.5 by Jay Pipes
Removal of log.cc (binlog), added Applier plugin and fixed up Replicator
136