~drizzle-trunk/drizzle/development

1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
 *  Copyright (C) 2010 Jay Pipes <jaypipes@gmail.com>
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
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
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
21
#pragma once
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
22
1720.5.3 by Monty Taylor
Removed a HASH in xa_resource_manager. It's not actually used, but I left it
23
#include <boost/unordered_set.hpp>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
24
#include <drizzled/visibility.h>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
25
2252.1.25 by Olaf van der Spek
Common fwd
26
namespace drizzled {
27
namespace plugin {
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
28
29
/**
30
 * An abstract interface class which exposes the participation
31
 * of implementing classes in distributed transactions in the XA protocol.
32
 */
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
33
class DRIZZLED_API XaResourceManager
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
34
{
35
public:
36
  virtual ~XaResourceManager() {}
37
38
  int xaPrepare(Session *session, bool normal_transaction)
39
  {
40
    return doXaPrepare(session, normal_transaction);
41
  }
42
43
  int xaCommit(Session *session, bool normal_transaction)
44
  {
45
    return doXaCommit(session, normal_transaction);
46
  }
47
48
  int xaRollback(Session *session, bool normal_transaction)
49
  {
50
    return doXaRollback(session, normal_transaction);
51
  }
52
53
  int xaCommitXid(XID *xid)
54
  {
55
    return doXaCommitXid(xid);
56
  }
57
58
  int xaRollbackXid(XID *xid)
59
  {
60
    return doXaRollbackXid(xid);
61
  }
62
63
  int xaRecover(XID * append_to, size_t len)
64
  {
65
    return doXaRecover(append_to, len);
66
  }
67
1856.2.5 by Joseph Daly
rework names for retrieving current trans id
68
  uint64_t getCurrentTransactionId(Session *session)
69
  {
70
    return doGetCurrentTransactionId(session);
71
  }
72
73
  uint64_t getNewTransactionId(Session *session)
74
  {
75
    return doGetNewTransactionId(session);
1856.2.1 by Joseph Daly
use transaction_id in innodb for transaction log
76
  }
77
1720.5.3 by Monty Taylor
Removed a HASH in xa_resource_manager. It's not actually used, but I left it
78
  typedef ::boost::unordered_set<my_xid> commit_list_set;
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
79
  /** 
80
   * The below static class methods wrap the interaction
81
   * of the vector of registered XA storage engines.
82
   */
83
  static int commitOrRollbackXID(XID *xid, bool commit);
1720.5.3 by Monty Taylor
Removed a HASH in xa_resource_manager. It's not actually used, but I left it
84
  static int recoverAllXids();
85
  static int recoverAllXids(const commit_list_set& commit_list);
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
86
87
  /* Class Methods for operating on plugin */
88
  static bool addPlugin(plugin::XaResourceManager *manager);
89
  static void removePlugin(plugin::XaResourceManager *manager);
90
private:
91
  /**
92
   * Does the COMMIT stage of the two-phase commit.
93
   */
94
  virtual int doXaCommit(Session *session, bool normal_transaction)= 0;
95
  /**
96
   * Does the ROLLBACK stage of the two-phase commit.
97
   */
98
  virtual int doXaRollback(Session *session, bool normal_transaction)= 0;
99
  /**
100
   * Does the PREPARE stage of the two-phase commit.
101
   */
102
  virtual int doXaPrepare(Session *session, bool normal_transaction)= 0;
103
  /**
104
   * Rolls back a transaction identified by a XID.
105
   */
106
  virtual int doXaRollbackXid(XID *xid)= 0;
107
  /**
108
   * Commits a transaction identified by a XID.
109
   */
110
  virtual int doXaCommitXid(XID *xid)= 0;
111
  /**
112
   * Notifies the transaction manager of any transactions
113
   * which had been marked prepared but not committed at
114
   * crash time or that have been heurtistically completed
115
   * by the storage engine.
116
   *
117
   * @param[out] Reference to a vector of XIDs to add to
118
   *
119
   * @retval
120
   *  Returns the number of transactions left to recover
121
   *  for this engine.
122
   */
123
  virtual int doXaRecover(XID * append_to, size_t len)= 0;
1856.2.1 by Joseph Daly
use transaction_id in innodb for transaction log
124
1856.2.5 by Joseph Daly
rework names for retrieving current trans id
125
  virtual uint64_t doGetCurrentTransactionId(Session *session)= 0;
126
127
  virtual uint64_t doGetNewTransactionId(Session *session)= 0;
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
128
};
129
130
} /* namespace plugin */
131
} /* namespace drizzled */
132