~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/xa_resource_manager.h

  • Committer: Brian Aker
  • Date: 2009-11-11 15:49:59 UTC
  • mto: This revision was merged to the branch mainline in revision 1212.
  • Revision ID: brian@gaz-20091111154959-jqu64e48gp9ig3tp
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
for protobuf to correctly store DECIMAL

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 Sun Microsystems
5
 
 *  Copyright (c) 2010 Jay Pipes <jaypipes@gmail.com>
6
 
 *
7
 
 *  This program is free software; you can redistribute it and/or modify
8
 
 *  it under the terms of the GNU General Public License as published by
9
 
 *  the Free Software Foundation; version 2 of the License.
10
 
 *
11
 
 *  This program is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
#ifndef DRIZZLED_PLUGIN_XA_RESOURCE_MANAGER_H
22
 
#define DRIZZLED_PLUGIN_XA_RESOURCE_MANAGER_H
23
 
 
24
 
#include <boost/unordered_set.hpp>
25
 
 
26
 
namespace drizzled
27
 
{
28
 
 
29
 
class XID;
30
 
 
31
 
namespace plugin
32
 
{
33
 
 
34
 
/**
35
 
 * An abstract interface class which exposes the participation
36
 
 * of implementing classes in distributed transactions in the XA protocol.
37
 
 */
38
 
class XaResourceManager
39
 
{
40
 
public:
41
 
  XaResourceManager() {}
42
 
  virtual ~XaResourceManager() {}
43
 
 
44
 
  int xaPrepare(Session *session, bool normal_transaction)
45
 
  {
46
 
    return doXaPrepare(session, normal_transaction);
47
 
  }
48
 
 
49
 
  int xaCommit(Session *session, bool normal_transaction)
50
 
  {
51
 
    return doXaCommit(session, normal_transaction);
52
 
  }
53
 
 
54
 
  int xaRollback(Session *session, bool normal_transaction)
55
 
  {
56
 
    return doXaRollback(session, normal_transaction);
57
 
  }
58
 
 
59
 
  int xaCommitXid(XID *xid)
60
 
  {
61
 
    return doXaCommitXid(xid);
62
 
  }
63
 
 
64
 
  int xaRollbackXid(XID *xid)
65
 
  {
66
 
    return doXaRollbackXid(xid);
67
 
  }
68
 
 
69
 
  int xaRecover(XID * append_to, size_t len)
70
 
  {
71
 
    return doXaRecover(append_to, len);
72
 
  }
73
 
 
74
 
  uint64_t getCurrentTransactionId(Session *session)
75
 
  {
76
 
    return doGetCurrentTransactionId(session);
77
 
  }
78
 
 
79
 
  uint64_t getNewTransactionId(Session *session)
80
 
  {
81
 
    return doGetNewTransactionId(session);
82
 
  }
83
 
 
84
 
  typedef ::boost::unordered_set<my_xid> commit_list_set;
85
 
  /** 
86
 
   * The below static class methods wrap the interaction
87
 
   * of the vector of registered XA storage engines.
88
 
   */
89
 
  static int commitOrRollbackXID(XID *xid, bool commit);
90
 
  static int recoverAllXids();
91
 
  static int recoverAllXids(const commit_list_set& commit_list);
92
 
 
93
 
  /* Class Methods for operating on plugin */
94
 
  static bool addPlugin(plugin::XaResourceManager *manager);
95
 
  static void removePlugin(plugin::XaResourceManager *manager);
96
 
private:
97
 
  /**
98
 
   * Does the COMMIT stage of the two-phase commit.
99
 
   */
100
 
  virtual int doXaCommit(Session *session, bool normal_transaction)= 0;
101
 
  /**
102
 
   * Does the ROLLBACK stage of the two-phase commit.
103
 
   */
104
 
  virtual int doXaRollback(Session *session, bool normal_transaction)= 0;
105
 
  /**
106
 
   * Does the PREPARE stage of the two-phase commit.
107
 
   */
108
 
  virtual int doXaPrepare(Session *session, bool normal_transaction)= 0;
109
 
  /**
110
 
   * Rolls back a transaction identified by a XID.
111
 
   */
112
 
  virtual int doXaRollbackXid(XID *xid)= 0;
113
 
  /**
114
 
   * Commits a transaction identified by a XID.
115
 
   */
116
 
  virtual int doXaCommitXid(XID *xid)= 0;
117
 
  /**
118
 
   * Notifies the transaction manager of any transactions
119
 
   * which had been marked prepared but not committed at
120
 
   * crash time or that have been heurtistically completed
121
 
   * by the storage engine.
122
 
   *
123
 
   * @param[out] Reference to a vector of XIDs to add to
124
 
   *
125
 
   * @retval
126
 
   *  Returns the number of transactions left to recover
127
 
   *  for this engine.
128
 
   */
129
 
  virtual int doXaRecover(XID * append_to, size_t len)= 0;
130
 
 
131
 
  virtual uint64_t doGetCurrentTransactionId(Session *session)= 0;
132
 
 
133
 
  virtual uint64_t doGetNewTransactionId(Session *session)= 0;
134
 
};
135
 
 
136
 
} /* namespace plugin */
137
 
} /* namespace drizzled */
138
 
 
139
 
#endif /* DRIZZLED_PLUGIN_XA_RESOURCE_MANAGER_H */