/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/broker/DtxManager.h

00001 /*
00002  *
00003  * Licensed to the Apache Software Foundation (ASF) under one
00004  * or more contributor license agreements.  See the NOTICE file
00005  * distributed with this work for additional information
00006  * regarding copyright ownership.  The ASF licenses this file
00007  * to you under the Apache License, Version 2.0 (the
00008  * "License"); you may not use this file except in compliance
00009  * with the License.  You may obtain a copy of the License at
00010  * 
00011  *   http://www.apache.org/licenses/LICENSE-2.0
00012  * 
00013  * Unless required by applicable law or agreed to in writing,
00014  * software distributed under the License is distributed on an
00015  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00016  * KIND, either express or implied.  See the License for the
00017  * specific language governing permissions and limitations
00018  * under the License.
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

Generated on Thu Apr 10 11:08:17 2008 for Qpid by  doxygen 1.4.7