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 #include <drizzled/visibility.h>
00025 
00026 namespace drizzled {
00027 namespace plugin {
00028 
00033 class DRIZZLED_API XaResourceManager
00034 {
00035 public:
00036   virtual ~XaResourceManager() {}
00037 
00038   int xaPrepare(Session *session, bool normal_transaction)
00039   {
00040     return doXaPrepare(session, normal_transaction);
00041   }
00042 
00043   int xaCommit(Session *session, bool normal_transaction)
00044   {
00045     return doXaCommit(session, normal_transaction);
00046   }
00047 
00048   int xaRollback(Session *session, bool normal_transaction)
00049   {
00050     return doXaRollback(session, normal_transaction);
00051   }
00052 
00053   int xaCommitXid(XID *xid)
00054   {
00055     return doXaCommitXid(xid);
00056   }
00057 
00058   int xaRollbackXid(XID *xid)
00059   {
00060     return doXaRollbackXid(xid);
00061   }
00062 
00063   int xaRecover(XID * append_to, size_t len)
00064   {
00065     return doXaRecover(append_to, len);
00066   }
00067 
00068   uint64_t getCurrentTransactionId(Session *session)
00069   {
00070     return doGetCurrentTransactionId(session);
00071   }
00072 
00073   uint64_t getNewTransactionId(Session *session)
00074   {
00075     return doGetNewTransactionId(session);
00076   }
00077 
00078   typedef ::boost::unordered_set<my_xid> commit_list_set;
00083   static int commitOrRollbackXID(XID *xid, bool commit);
00084   static int recoverAllXids();
00085   static int recoverAllXids(const commit_list_set& commit_list);
00086 
00087   /* Class Methods for operating on plugin */
00088   static bool addPlugin(plugin::XaResourceManager *manager);
00089   static void removePlugin(plugin::XaResourceManager *manager);
00090 private:
00094   virtual int doXaCommit(Session *session, bool normal_transaction)= 0;
00098   virtual int doXaRollback(Session *session, bool normal_transaction)= 0;
00102   virtual int doXaPrepare(Session *session, bool normal_transaction)= 0;
00106   virtual int doXaRollbackXid(XID *xid)= 0;
00110   virtual int doXaCommitXid(XID *xid)= 0;
00123   virtual int doXaRecover(XID * append_to, size_t len)= 0;
00124 
00125   virtual uint64_t doGetCurrentTransactionId(Session *session)= 0;
00126 
00127   virtual uint64_t doGetNewTransactionId(Session *session)= 0;
00128 };
00129 
00130 } /* namespace plugin */
00131 } /* namespace drizzled */
00132