~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
 *
4
 *  Copyright (c) 2010 Jay Pipes <jaypipes@gmail.com>
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
#ifndef DRIZZLED_PLUGIN_MONITORED_IN_TRANSACTION_H
21
#define DRIZZLED_PLUGIN_MONITORED_IN_TRANSACTION_H
22
23
#include <cstring>
24
25
namespace drizzled
26
{
27
28
namespace plugin
29
{
30
31
extern size_t num_trx_monitored_objects;
32
33
/**
34
 * An abstract interface class for those objects which are tracked
35
 * by the TransactionServices component during operations in a
36
 * transaction.
37
 *
38
 * Note that both non-transactional plugin::StorageEngines, non-XA
39
 * plugin::TransactionalStorageEngines, and plugin::XaResourceManager
40
 * objects are all tracked by the transaction manager in TransactionServices.
41
 *
42
 * Implementing classes should inherit *publically* from
43
 * plugin::MonitoredInTransaction, as public inheritance means
44
 * "is a" and is the appropriate use here since all implementing classes
45
 * *are* monitored in a transaction...
46
 */
47
class MonitoredInTransaction
48
{
49
public:
50
51
  MonitoredInTransaction();
52
  virtual ~MonitoredInTransaction() {}
53
54
  /**
55
   * Returns true if the class should participate
56
   * in the SQL transaction.
57
   */
58
  virtual bool participatesInSqlTransaction() const= 0;
59
60
  /**
61
   * Returns true if the class should participate
62
   * in the XA transaction.
63
   */
64
  virtual bool participatesInXaTransaction() const= 0;
65
66
  /**
67
   * Returns true if the class should be registered
68
   * for every XA transaction regardless of whether
69
   * the class modifies the server's state.
70
   *
71
   * @note
72
   *
73
   * As an example, the XaTransactionApplier plugin class returns
74
   * true for this virtual method.  Even though it does not
75
   * change the result of the transaction (it simply is logging
76
   * the changes made by other resource managers), the applier
77
   * plugin should be enlisted in all XA transactions in order
78
   * to be able to rollback or recover its logging activity
79
   * properly.
80
   */
81
  virtual bool alwaysRegisterForXaTransaction() const= 0;
82
83
  /**
84
   * Returns the "slot" or ID of the monitored resource
85
   */
86
  size_t getId() const
87
  {
88
    return id;
89
  }
90
private:
91
  /**
92
   * The ID or "slot" of the plugin.
93
   *
94
   * @todo
95
   *
96
   * Maybe move this into plugin::Plugin?  Only issue then is
97
   * that all plugins would have a ha_data slot, when only a few
98
   * actually need that.  Maybe create a plugin::NeedsSessionData?
99
   */
100
  size_t id;
101
};
102
103
} /* namespace plugin */
104
} /* namespace drizzled */
105
106
#endif /* DRIZZLED_PLUGIN_MONITORED_IN_TRANSACTION_H */