~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin_replicator.h

  • Committer: Lee
  • Date: 2009-01-01 03:07:33 UTC
  • mto: (758.1.3 devel)
  • mto: This revision was merged to the branch mainline in revision 759.
  • Revision ID: lbieber@lbieber-desktop-20090101030733-fb411b55f07vij8q
more header file 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, Inc.
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
 
#include <drizzled/visibility.h>
32
 
 
33
 
/**
34
 
 * @file Defines the API for a TransactionReplicator.  
35
 
 *
36
 
 * All a replicator does is replicate/reproduce
37
 
 * events, optionally transforming them before sending them off to a TransactionApplier.
38
 
 *
39
 
 * An applier is responsible for applying events, not a replicator...
40
 
 */
41
 
 
42
 
namespace drizzled
43
 
{
44
 
namespace message
45
 
46
 
  class Transaction;
47
 
  class Statement;
48
 
}
49
 
 
50
 
class Session;
51
 
 
52
 
namespace plugin
53
 
{
54
 
 
55
 
class TransactionApplier;
56
 
 
57
 
/**
58
 
 * Class which replicates Transaction messages
59
 
 */
60
 
class DRIZZLED_API TransactionReplicator : public Plugin
61
 
{
62
 
  TransactionReplicator();
63
 
  TransactionReplicator(const TransactionReplicator &);
64
 
  TransactionReplicator& operator=(const TransactionReplicator &);
65
 
public:
66
 
  explicit TransactionReplicator(std::string name_arg)
67
 
    : Plugin(name_arg, "TransactionReplicator")
68
 
  {
69
 
  }
70
 
  virtual ~TransactionReplicator() {}
71
 
 
72
 
  /**
73
 
   * Replicate a Transaction message to a TransactionApplier.
74
 
   *
75
 
   * @note
76
 
   *
77
 
   * It is important to note that memory allocation for the 
78
 
   * supplied pointer is not guaranteed after the completion 
79
 
   * of this function -- meaning the caller can dispose of the
80
 
   * supplied message.  Therefore, replicators and appliers 
81
 
   * implementing an asynchronous replication system must copy
82
 
   * the supplied message to their own controlled memory storage
83
 
   * area.
84
 
   *
85
 
   * @param Pointer to the applier of the command message
86
 
   * @param Transaction message to be replicated
87
 
   */
88
 
  virtual ReplicationReturnCode replicate(TransactionApplier *in_applier, 
89
 
                                          Session &session,
90
 
                                          message::Transaction &to_replicate)= 0;
91
 
  static bool addPlugin(TransactionReplicator *replicator);
92
 
  static void removePlugin(TransactionReplicator *replicator);
93
 
};
94
 
 
95
 
} /* namespace plugin */
96
 
} /* namespace drizzled */
97
 
 
98
 
#endif /* DRIZZLED_PLUGIN_TRANSACTION_REPLICATOR_H */
 
1
/*
 
2
  -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
3
  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
4
 
 
5
  *  Definitions required for Configuration Variables plugin
 
6
 
 
7
  *  Copyright (C) 2008 Mark Atwood
 
8
  *
 
9
  *  This program is free software; you can redistribute it and/or modify
 
10
  *  it under the terms of the GNU General Public License as published by
 
11
  *  the Free Software Foundation; version 2 of the License.
 
12
  *
 
13
  *  This program is distributed in the hope that it will be useful,
 
14
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
  *  GNU General Public License for more details.
 
17
  *
 
18
  *  You should have received a copy of the GNU General Public License
 
19
  *  along with this program; if not, write to the Free Software
 
20
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
21
  */
 
22
 
 
23
#ifndef DRIZZLED_PLUGIN_REPLICATOR_H
 
24
#define DRIZZLED_PLUGIN_REPLICATOR_H
 
25
 
 
26
typedef struct replicator_st
 
27
{
 
28
  bool enabled;
 
29
  /* todo, define this api */
 
30
  /* this is the API that a replicator plugin must implement.
 
31
     it should implement each of these function pointers.
 
32
     if a function returns bool true, that means it failed.
 
33
     if a function pointer is NULL, that's ok.
 
34
  */
 
35
 
 
36
  bool (*session_init)(Session *session);
 
37
  bool (*row_insert)(Session *session, Table *table);
 
38
  bool (*row_update)(Session *session, Table *table,
 
39
                     const unsigned char *before,
 
40
                     const unsigned char *after);
 
41
  bool (*row_delete)(Session *session, Table *table);
 
42
  bool (*end_transaction)(Session *session, bool autocommit, bool commit);
 
43
  bool (*statement)(Session *session, const char *query, size_t query_length);
 
44
} replicator_t;
 
45
 
 
46
#endif /* DRIZZLED_PLUGIN_REPLICATOR_H */