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
33
* An abstract interface class which exposes the participation
34
* of implementing classes in distributed transactions in the XA protocol.
36
class XaResourceManager
39
XaResourceManager() {}
40
virtual ~XaResourceManager() {}
42
int xaPrepare(Session *session, bool normal_transaction)
44
return doXaPrepare(session, normal_transaction);
47
int xaCommit(Session *session, bool normal_transaction)
49
return doXaCommit(session, normal_transaction);
52
int xaRollback(Session *session, bool normal_transaction)
54
return doXaRollback(session, normal_transaction);
57
int xaCommitXid(XID *xid)
59
return doXaCommitXid(xid);
62
int xaRollbackXid(XID *xid)
64
return doXaRollbackXid(xid);
67
int xaRecover(XID * append_to, size_t len)
69
return doXaRecover(append_to, len);
73
* The below static class methods wrap the interaction
74
* of the vector of registered XA storage engines.
76
static int commitOrRollbackXID(XID *xid, bool commit);
77
static int recoverAllXids(HASH *commit_list);
79
/* Class Methods for operating on plugin */
80
static bool addPlugin(plugin::XaResourceManager *manager);
81
static void removePlugin(plugin::XaResourceManager *manager);
84
* Does the COMMIT stage of the two-phase commit.
86
virtual int doXaCommit(Session *session, bool normal_transaction)= 0;
88
* Does the ROLLBACK stage of the two-phase commit.
90
virtual int doXaRollback(Session *session, bool normal_transaction)= 0;
92
* Does the PREPARE stage of the two-phase commit.
94
virtual int doXaPrepare(Session *session, bool normal_transaction)= 0;
96
* Rolls back a transaction identified by a XID.
98
virtual int doXaRollbackXid(XID *xid)= 0;
100
* Commits a transaction identified by a XID.
102
virtual int doXaCommitXid(XID *xid)= 0;
104
* Notifies the transaction manager of any transactions
105
* which had been marked prepared but not committed at
106
* crash time or that have been heurtistically completed
107
* by the storage engine.
109
* @param[out] Reference to a vector of XIDs to add to
112
* Returns the number of transactions left to recover
115
virtual int doXaRecover(XID * append_to, size_t len)= 0;
118
} /* namespace plugin */
119
} /* namespace drizzled */
121
#endif /* DRIZZLED_PLUGIN_XA_RESOURCE_MANAGER_H */