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, Inc.
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>
26
#include "drizzled/visibility.h"
37
* An abstract interface class which exposes the participation
38
* of implementing classes in distributed transactions in the XA protocol.
40
class DRIZZLED_API XaResourceManager
43
XaResourceManager() {}
44
virtual ~XaResourceManager() {}
46
int xaPrepare(Session *session, bool normal_transaction)
48
return doXaPrepare(session, normal_transaction);
51
int xaCommit(Session *session, bool normal_transaction)
53
return doXaCommit(session, normal_transaction);
56
int xaRollback(Session *session, bool normal_transaction)
58
return doXaRollback(session, normal_transaction);
61
int xaCommitXid(XID *xid)
63
return doXaCommitXid(xid);
66
int xaRollbackXid(XID *xid)
68
return doXaRollbackXid(xid);
71
int xaRecover(XID * append_to, size_t len)
73
return doXaRecover(append_to, len);
76
uint64_t getCurrentTransactionId(Session *session)
78
return doGetCurrentTransactionId(session);
81
uint64_t getNewTransactionId(Session *session)
83
return doGetNewTransactionId(session);
86
typedef ::boost::unordered_set<my_xid> commit_list_set;
88
* The below static class methods wrap the interaction
89
* of the vector of registered XA storage engines.
91
static int commitOrRollbackXID(XID *xid, bool commit);
92
static int recoverAllXids();
93
static int recoverAllXids(const commit_list_set& commit_list);
95
/* Class Methods for operating on plugin */
96
static bool addPlugin(plugin::XaResourceManager *manager);
97
static void removePlugin(plugin::XaResourceManager *manager);
100
* Does the COMMIT stage of the two-phase commit.
102
virtual int doXaCommit(Session *session, bool normal_transaction)= 0;
104
* Does the ROLLBACK stage of the two-phase commit.
106
virtual int doXaRollback(Session *session, bool normal_transaction)= 0;
108
* Does the PREPARE stage of the two-phase commit.
110
virtual int doXaPrepare(Session *session, bool normal_transaction)= 0;
112
* Rolls back a transaction identified by a XID.
114
virtual int doXaRollbackXid(XID *xid)= 0;
116
* Commits a transaction identified by a XID.
118
virtual int doXaCommitXid(XID *xid)= 0;
120
* Notifies the transaction manager of any transactions
121
* which had been marked prepared but not committed at
122
* crash time or that have been heurtistically completed
123
* by the storage engine.
125
* @param[out] Reference to a vector of XIDs to add to
128
* Returns the number of transactions left to recover
131
virtual int doXaRecover(XID * append_to, size_t len)= 0;
133
virtual uint64_t doGetCurrentTransactionId(Session *session)= 0;
135
virtual uint64_t doGetNewTransactionId(Session *session)= 0;
138
} /* namespace plugin */
139
} /* namespace drizzled */
141
#endif /* DRIZZLED_PLUGIN_XA_RESOURCE_MANAGER_H */