Drizzled Public API Documentation

xa_resource_manager.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *  Copyright (C) 2010 Jay Pipes <jaypipes@gmail.com>
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; version 2 of the License.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #pragma once
00022 
00023 #include <boost/unordered_set.hpp>
00024 
00025 #include <drizzled/visibility.h>
00026 
00027 namespace drizzled
00028 {
00029 
00030 class XID;
00031 
00032 namespace plugin
00033 {
00034 
00039 class DRIZZLED_API XaResourceManager
00040 {
00041 public:
00042   XaResourceManager() {}
00043   virtual ~XaResourceManager() {}
00044 
00045   int xaPrepare(Session *session, bool normal_transaction)
00046   {
00047     return doXaPrepare(session, normal_transaction);
00048   }
00049 
00050   int xaCommit(Session *session, bool normal_transaction)
00051   {
00052     return doXaCommit(session, normal_transaction);
00053   }
00054 
00055   int xaRollback(Session *session, bool normal_transaction)
00056   {
00057     return doXaRollback(session, normal_transaction);
00058   }
00059 
00060   int xaCommitXid(XID *xid)
00061   {
00062     return doXaCommitXid(xid);
00063   }
00064 
00065   int xaRollbackXid(XID *xid)
00066   {
00067     return doXaRollbackXid(xid);
00068   }
00069 
00070   int xaRecover(XID * append_to, size_t len)
00071   {
00072     return doXaRecover(append_to, len);
00073   }
00074 
00075   uint64_t getCurrentTransactionId(Session *session)
00076   {
00077     return doGetCurrentTransactionId(session);
00078   }
00079 
00080   uint64_t getNewTransactionId(Session *session)
00081   {
00082     return doGetNewTransactionId(session);
00083   }
00084 
00085   typedef ::boost::unordered_set<my_xid> commit_list_set;
00090   static int commitOrRollbackXID(XID *xid, bool commit);
00091   static int recoverAllXids();
00092   static int recoverAllXids(const commit_list_set& commit_list);
00093 
00094   /* Class Methods for operating on plugin */
00095   static bool addPlugin(plugin::XaResourceManager *manager);
00096   static void removePlugin(plugin::XaResourceManager *manager);
00097 private:
00101   virtual int doXaCommit(Session *session, bool normal_transaction)= 0;
00105   virtual int doXaRollback(Session *session, bool normal_transaction)= 0;
00109   virtual int doXaPrepare(Session *session, bool normal_transaction)= 0;
00113   virtual int doXaRollbackXid(XID *xid)= 0;
00117   virtual int doXaCommitXid(XID *xid)= 0;
00130   virtual int doXaRecover(XID * append_to, size_t len)= 0;
00131 
00132   virtual uint64_t doGetCurrentTransactionId(Session *session)= 0;
00133 
00134   virtual uint64_t doGetNewTransactionId(Session *session)= 0;
00135 };
00136 
00137 } /* namespace plugin */
00138 } /* namespace drizzled */
00139