1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
5
* Copyright (c) 2010 Jay Pipes <jaypipes@gmail.com>
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.
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.
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
21
#ifndef DRIZZLED_PLUGIN_XA_RESOURCE_MANAGER_H
22
#define DRIZZLED_PLUGIN_XA_RESOURCE_MANAGER_H
24
#include <boost/unordered_set.hpp>
35
* An abstract interface class which exposes the participation
36
* of implementing classes in distributed transactions in the XA protocol.
38
class XaResourceManager
41
XaResourceManager() {}
42
virtual ~XaResourceManager() {}
44
int xaPrepare(Session *session, bool normal_transaction)
46
return doXaPrepare(session, normal_transaction);
49
int xaCommit(Session *session, bool normal_transaction)
51
return doXaCommit(session, normal_transaction);
54
int xaRollback(Session *session, bool normal_transaction)
56
return doXaRollback(session, normal_transaction);
59
int xaCommitXid(XID *xid)
61
return doXaCommitXid(xid);
64
int xaRollbackXid(XID *xid)
66
return doXaRollbackXid(xid);
69
int xaRecover(XID * append_to, size_t len)
71
return doXaRecover(append_to, len);
74
uint64_t getCurrentTransactionId(Session *session)
76
return doGetCurrentTransactionId(session);
79
uint64_t getNewTransactionId(Session *session)
81
return doGetNewTransactionId(session);
84
typedef ::boost::unordered_set<my_xid> commit_list_set;
86
* The below static class methods wrap the interaction
87
* of the vector of registered XA storage engines.
89
static int commitOrRollbackXID(XID *xid, bool commit);
90
static int recoverAllXids();
91
static int recoverAllXids(const commit_list_set& commit_list);
93
/* Class Methods for operating on plugin */
94
static bool addPlugin(plugin::XaResourceManager *manager);
95
static void removePlugin(plugin::XaResourceManager *manager);
98
* Does the COMMIT stage of the two-phase commit.
100
virtual int doXaCommit(Session *session, bool normal_transaction)= 0;
102
* Does the ROLLBACK stage of the two-phase commit.
104
virtual int doXaRollback(Session *session, bool normal_transaction)= 0;
106
* Does the PREPARE stage of the two-phase commit.
108
virtual int doXaPrepare(Session *session, bool normal_transaction)= 0;
110
* Rolls back a transaction identified by a XID.
112
virtual int doXaRollbackXid(XID *xid)= 0;
114
* Commits a transaction identified by a XID.
116
virtual int doXaCommitXid(XID *xid)= 0;
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.
123
* @param[out] Reference to a vector of XIDs to add to
126
* Returns the number of transactions left to recover
129
virtual int doXaRecover(XID * append_to, size_t len)= 0;
131
virtual uint64_t doGetCurrentTransactionId(Session *session)= 0;
133
virtual uint64_t doGetNewTransactionId(Session *session)= 0;
136
} /* namespace plugin */
137
} /* namespace drizzled */
139
#endif /* DRIZZLED_PLUGIN_XA_RESOURCE_MANAGER_H */