~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-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

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, Inc.
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
 
#include "drizzled/visibility.h"
27
 
 
28
 
namespace drizzled
29
 
{
30
 
 
31
 
class XID;
32
 
 
33
 
namespace plugin
34
 
{
35
 
 
36
 
/**
37
 
 * An abstract interface class which exposes the participation
38
 
 * of implementing classes in distributed transactions in the XA protocol.
39
 
 */
40
 
class DRIZZLED_API XaResourceManager
41
 
{
42
 
public:
43
 
  XaResourceManager() {}
44
 
  virtual ~XaResourceManager() {}
45
 
 
46
 
  int xaPrepare(Session *session, bool normal_transaction)
47
 
  {
48
 
    return doXaPrepare(session, normal_transaction);
49
 
  }
50
 
 
51
 
  int xaCommit(Session *session, bool normal_transaction)
52
 
  {
53
 
    return doXaCommit(session, normal_transaction);
54
 
  }
55
 
 
56
 
  int xaRollback(Session *session, bool normal_transaction)
57
 
  {
58
 
    return doXaRollback(session, normal_transaction);
59
 
  }
60
 
 
61
 
  int xaCommitXid(XID *xid)
62
 
  {
63
 
    return doXaCommitXid(xid);
64
 
  }
65
 
 
66
 
  int xaRollbackXid(XID *xid)
67
 
  {
68
 
    return doXaRollbackXid(xid);
69
 
  }
70
 
 
71
 
  int xaRecover(XID * append_to, size_t len)
72
 
  {
73
 
    return doXaRecover(append_to, len);
74
 
  }
75
 
 
76
 
  uint64_t getCurrentTransactionId(Session *session)
77
 
  {
78
 
    return doGetCurrentTransactionId(session);
79
 
  }
80
 
 
81
 
  uint64_t getNewTransactionId(Session *session)
82
 
  {
83
 
    return doGetNewTransactionId(session);
84
 
  }
85
 
 
86
 
  typedef ::boost::unordered_set<my_xid> commit_list_set;
87
 
  /** 
88
 
   * The below static class methods wrap the interaction
89
 
   * of the vector of registered XA storage engines.
90
 
   */
91
 
  static int commitOrRollbackXID(XID *xid, bool commit);
92
 
  static int recoverAllXids();
93
 
  static int recoverAllXids(const commit_list_set& commit_list);
94
 
 
95
 
  /* Class Methods for operating on plugin */
96
 
  static bool addPlugin(plugin::XaResourceManager *manager);
97
 
  static void removePlugin(plugin::XaResourceManager *manager);
98
 
private:
99
 
  /**
100
 
   * Does the COMMIT stage of the two-phase commit.
101
 
   */
102
 
  virtual int doXaCommit(Session *session, bool normal_transaction)= 0;
103
 
  /**
104
 
   * Does the ROLLBACK stage of the two-phase commit.
105
 
   */
106
 
  virtual int doXaRollback(Session *session, bool normal_transaction)= 0;
107
 
  /**
108
 
   * Does the PREPARE stage of the two-phase commit.
109
 
   */
110
 
  virtual int doXaPrepare(Session *session, bool normal_transaction)= 0;
111
 
  /**
112
 
   * Rolls back a transaction identified by a XID.
113
 
   */
114
 
  virtual int doXaRollbackXid(XID *xid)= 0;
115
 
  /**
116
 
   * Commits a transaction identified by a XID.
117
 
   */
118
 
  virtual int doXaCommitXid(XID *xid)= 0;
119
 
  /**
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.
124
 
   *
125
 
   * @param[out] Reference to a vector of XIDs to add to
126
 
   *
127
 
   * @retval
128
 
   *  Returns the number of transactions left to recover
129
 
   *  for this engine.
130
 
   */
131
 
  virtual int doXaRecover(XID * append_to, size_t len)= 0;
132
 
 
133
 
  virtual uint64_t doGetCurrentTransactionId(Session *session)= 0;
134
 
 
135
 
  virtual uint64_t doGetNewTransactionId(Session *session)= 0;
136
 
};
137
 
 
138
 
} /* namespace plugin */
139
 
} /* namespace drizzled */
140
 
 
141
 
#endif /* DRIZZLED_PLUGIN_XA_RESOURCE_MANAGER_H */