~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/instance/shared.h

This patch completes the first step in the splitting of
the XA resource manager API from the storage engine API,
as outlined in the specification here:

http://drizzle.org/wiki/XaStorageEngine

* Splits plugin::StorageEngine into a base StorageEngine
  class and two derived classes, TransactionalStorageEngine
  and XaStorageEngine.  XaStorageEngine derives from
  TransactionalStorageEngine and creates the XA Resource
  Manager API for storage engines.

  - The methods moved from StorageEngine to TransactionalStorageEngine
    include releaseTemporaryLatches(), startConsistentSnapshot(), 
    commit(), rollback(), setSavepoint(), releaseSavepoint(),
    rollbackToSavepoint() and hasTwoPhaseCommit()
  - The methods moved from StorageEngine to XaStorageEngine
    include recover(), commitXid(), rollbackXid(), and prepare()

* Places all static "EngineVector"s into their proper
  namespaces (typedefs belong in header files, not implementation files)
  and places all static methods corresponding
  to either only transactional engines or only XA engines
  into their respective files in /drizzled/plugin/

* Modifies the InnoDB "handler" files to extend plugin::XaStorageEngine
  and not plugin::StorageEngine

The next step, as outlined in the wiki spec page above, is to isolate
the XA Resource Manager API into its own plugin class and modify
plugin::XaStorageEngine to implement plugin::XaResourceManager via
composition.  This is necessary to enable building plugins which can
participate in an XA transaction *without having to have that plugin
implement the entire storage engine API*

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) 2011 Brian Aker
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; either version 2 of the License, or
9
 
 *  (at your option) any later version.
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
 
 
22
 
#ifndef DRIZZLED_TABLE_INSTANCE_SHARED_H
23
 
#define DRIZZLED_TABLE_INSTANCE_SHARED_H
24
 
 
25
 
#include <drizzled/table/instance/base.h>
26
 
 
27
 
namespace drizzled
28
 
{
29
 
 
30
 
class TableShare;
31
 
class Session;
32
 
 
33
 
namespace identifier { class Table; }
34
 
 
35
 
namespace table
36
 
{
37
 
 
38
 
namespace instance
39
 
{
40
 
 
41
 
void release(TableShare *share);
42
 
void release(TableShare::shared_ptr &share);
43
 
void release(const identifier::Table &identifier);
44
 
 
45
 
 
46
 
class Shared : public drizzled::TableShare
47
 
{
48
 
  friend void release(TableShare *share);
49
 
  friend void release(TableShare::shared_ptr &share);
50
 
 
51
 
public:
52
 
  typedef boost::shared_ptr<Shared> shared_ptr;
53
 
  typedef std::vector <shared_ptr> vector;
54
 
 
55
 
  Shared(const identifier::Table::Type type_arg,
56
 
         const identifier::Table &identifier,
57
 
         char *path_arg= NULL, uint32_t path_length_arg= 0); // Shares for cache
58
 
 
59
 
  Shared(const identifier::Table &identifier); // Used by placeholder
60
 
 
61
 
  ~Shared();
62
 
 
63
 
 
64
 
  void lock()
65
 
  {
66
 
    mutex.lock();
67
 
  }
68
 
 
69
 
  void unlock()
70
 
  {
71
 
    mutex.unlock();
72
 
  }
73
 
 
74
 
  static shared_ptr make_shared(Session *session, 
75
 
                                const identifier::Table &identifier,
76
 
                                int &in_error);
77
 
 
78
 
  static shared_ptr foundTableShare(shared_ptr share);
79
 
 
80
 
  plugin::EventObserverList *getTableObservers() 
81
 
  { 
82
 
    return event_observers;
83
 
  }
84
 
 
85
 
  void setTableObservers(plugin::EventObserverList *observers) 
86
 
  { 
87
 
    event_observers= observers;
88
 
  }
89
 
 
90
 
  virtual bool replicate() const
91
 
  {
92
 
    if (getTableMessage()->options().has_dont_replicate() and getTableMessage()->options().dont_replicate())
93
 
      return false;
94
 
 
95
 
    return true;
96
 
  }
97
 
 
98
 
private:
99
 
  boost::mutex mutex;                /* For locking the share  */
100
 
 
101
 
  /* 
102
 
    event_observers is a class containing all the event plugins that have 
103
 
    registered an interest in this table.
104
 
  */
105
 
  plugin::EventObserverList *event_observers;
106
 
 
107
 
};
108
 
 
109
 
} /* namespace instance */
110
 
} /* namespace table */
111
 
} /* namespace drizzled */
112
 
 
113
 
#endif /* DRIZZLED_TABLE_INSTANCE_SHARED_H */