~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/transaction_replicator.h

  • Committer: Brian Aker
  • Date: 2010-05-27 01:25:56 UTC
  • mfrom: (1567.1.4 new-staging)
  • Revision ID: brian@gaz-20100527012556-5zgkirkl7swbigd6
Merge of Brian, Paul. PBXT compile issue, and test framework cleanup. 

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
 
5
 *  Copyright (c) 2010 Jay Pipes
 
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
#ifndef DRIZZLED_PLUGIN_TRANSACTION_REPLICATOR_H
 
26
#define DRIZZLED_PLUGIN_TRANSACTION_REPLICATOR_H
 
27
 
 
28
#include "drizzled/plugin/replication.h"
 
29
#include "drizzled/plugin/plugin.h"
 
30
 
 
31
/**
 
32
 * @file Defines the API for a TransactionReplicator.  
 
33
 *
 
34
 * All a replicator does is replicate/reproduce
 
35
 * events, optionally transforming them before sending them off to a TransactionApplier.
 
36
 *
 
37
 * An applier is responsible for applying events, not a replicator...
 
38
 */
 
39
 
 
40
namespace drizzled
 
41
{
 
42
namespace message
 
43
 
44
  class Transaction;
 
45
  class Statement;
 
46
}
 
47
 
 
48
class Session;
 
49
 
 
50
namespace plugin
 
51
{
 
52
 
 
53
class TransactionApplier;
 
54
 
 
55
/**
 
56
 * Class which replicates Transaction messages
 
57
 */
 
58
class TransactionReplicator : public Plugin
 
59
{
 
60
  TransactionReplicator();
 
61
  TransactionReplicator(const TransactionReplicator &);
 
62
  TransactionReplicator& operator=(const TransactionReplicator &);
 
63
public:
 
64
  explicit TransactionReplicator(std::string name_arg)
 
65
    : Plugin(name_arg, "TransactionReplicator")
 
66
  {
 
67
  }
 
68
  virtual ~TransactionReplicator() {}
 
69
 
 
70
  /**
 
71
   * Replicate a Transaction message to a TransactionApplier.
 
72
   *
 
73
   * @note
 
74
   *
 
75
   * It is important to note that memory allocation for the 
 
76
   * supplied pointer is not guaranteed after the completion 
 
77
   * of this function -- meaning the caller can dispose of the
 
78
   * supplied message.  Therefore, replicators and appliers 
 
79
   * implementing an asynchronous replication system must copy
 
80
   * the supplied message to their own controlled memory storage
 
81
   * area.
 
82
   *
 
83
   * @param Pointer to the applier of the command message
 
84
   * @param Transaction message to be replicated
 
85
   */
 
86
  virtual ReplicationReturnCode replicate(TransactionApplier *in_applier, 
 
87
                                          Session &session,
 
88
                                          message::Transaction &to_replicate)= 0;
 
89
  static bool addPlugin(TransactionReplicator *replicator);
 
90
  static void removePlugin(TransactionReplicator *replicator);
 
91
};
 
92
 
 
93
} /* namespace plugin */
 
94
} /* namespace drizzled */
 
95
 
 
96
#endif /* DRIZZLED_PLUGIN_TRANSACTION_REPLICATOR_H */