~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-01-24 09:43:35 UTC
  • Revision ID: brian@gir-3.local-20090124094335-6qdtvc35gl5fvivz
Adding in an example singe thread scheduler

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