00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _DtxManager_
00022 #define _DtxManager_
00023
00024 #include <boost/ptr_container/ptr_map.hpp>
00025 #include "DtxBuffer.h"
00026 #include "DtxWorkRecord.h"
00027 #include "Timer.h"
00028 #include "TransactionalStore.h"
00029 #include "qpid/framing/amqp_types.h"
00030 #include "qpid/sys/Mutex.h"
00031
00032 namespace qpid {
00033 namespace broker {
00034
00035 class DtxManager{
00036 typedef boost::ptr_map<std::string, DtxWorkRecord> WorkMap;
00037
00038 struct DtxCleanup : public TimerTask
00039 {
00040 DtxManager& mgr;
00041 const std::string& xid;
00042
00043 DtxCleanup(uint32_t timeout, DtxManager& mgr, const std::string& xid);
00044 void fire();
00045 };
00046
00047 WorkMap work;
00048 TransactionalStore* store;
00049 qpid::sys::Mutex lock;
00050 Timer timer;
00051
00052 void remove(const std::string& xid);
00053 DtxWorkRecord* getWork(const std::string& xid);
00054 DtxWorkRecord* createWork(std::string xid);
00055
00056 public:
00057 DtxManager();
00058 ~DtxManager();
00059 void start(const std::string& xid, DtxBuffer::shared_ptr work);
00060 void join(const std::string& xid, DtxBuffer::shared_ptr work);
00061 void recover(const std::string& xid, std::auto_ptr<TPCTransactionContext> txn, DtxBuffer::shared_ptr work);
00062 bool prepare(const std::string& xid);
00063 bool commit(const std::string& xid, bool onePhase);
00064 void rollback(const std::string& xid);
00065 void setTimeout(const std::string& xid, uint32_t secs);
00066 uint32_t getTimeout(const std::string& xid);
00067 void timedout(const std::string& xid);
00068 void setStore(TransactionalStore* store);
00069 };
00070
00071 }
00072 }
00073
00074 #endif