//////////////////////////////////////////////////////////////////////////////// /// @brief transaction manager /// /// @file /// /// DISCLAIMER /// /// Copyright 2014 ArangoDB GmbH, Cologne, Germany /// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. /// You may obtain a copy of the License at /// /// http://www.apache.org/licenses/LICENSE-2.0 /// /// Unless required by applicable law or agreed to in writing, software /// distributed under the License is distributed on an "AS IS" BASIS, /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// See the License for the specific language governing permissions and /// limitations under the License. /// /// Copyright holder is ArangoDB GmbH, Cologne, Germany /// /// @author Jan Steemann /// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany /// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// #ifndef ARANGODB_TRANSACTION_MANAGER_H #define ARANGODB_TRANSACTION_MANAGER_H 1 #include "Basics/Common.h" #include "Basics/ReadWriteLock.h" #include "Transaction/IdGenerator.h" #include "Transaction/Transaction.h" namespace triagens { namespace transaction { // ----------------------------------------------------------------------------- // --SECTION-- class TransactionManager // ----------------------------------------------------------------------------- class Manager { //////////////////////////////////////////////////////////////////////////////// /// @brief TransactionManager //////////////////////////////////////////////////////////////////////////////// private: Manager (Manager const&); Manager& operator= (Manager const&); // ----------------------------------------------------------------------------- // --SECTION-- public methods // ----------------------------------------------------------------------------- public: //////////////////////////////////////////////////////////////////////////////// /// @brief create a transaction manager //////////////////////////////////////////////////////////////////////////////// Manager (); //////////////////////////////////////////////////////////////////////////////// /// @brief destroy a transaction manager //////////////////////////////////////////////////////////////////////////////// ~Manager (); //////////////////////////////////////////////////////////////////////////////// /// @brief get the transaction manager instance //////////////////////////////////////////////////////////////////////////////// static Manager* instance (); //////////////////////////////////////////////////////////////////////////////// /// @brief initialise the transaction manager instance //////////////////////////////////////////////////////////////////////////////// static void initialise (); //////////////////////////////////////////////////////////////////////////////// /// @brief shutdown the transaction manager instance //////////////////////////////////////////////////////////////////////////////// void shutdown (); //////////////////////////////////////////////////////////////////////////////// /// @brief create a transaction object //////////////////////////////////////////////////////////////////////////////// Transaction* createTransaction (bool); //////////////////////////////////////////////////////////////////////////////// /// @brief get the status of a transaction //////////////////////////////////////////////////////////////////////////////// Transaction::StateType statusTransaction (TRI_voc_tid_t); //////////////////////////////////////////////////////////////////////////////// /// @brief get oldest still running transaction //////////////////////////////////////////////////////////////////////////////// TransactionInfo getOldestRunning (); //////////////////////////////////////////////////////////////////////////////// /// @brief check whether any of the specified transactions is still running //////////////////////////////////////////////////////////////////////////////// bool containsRunning (std::vector const&); //////////////////////////////////////////////////////////////////////////////// /// @brief remove specified transactions from the failed list //////////////////////////////////////////////////////////////////////////////// int removeFailed (std::vector const&); //////////////////////////////////////////////////////////////////////////////// /// @brief begin a transaction //////////////////////////////////////////////////////////////////////////////// int beginTransaction (Transaction*); //////////////////////////////////////////////////////////////////////////////// /// @brief commit a transaction //////////////////////////////////////////////////////////////////////////////// int commitTransaction (Transaction*, bool); //////////////////////////////////////////////////////////////////////////////// /// @brief rollback a transaction //////////////////////////////////////////////////////////////////////////////// int rollbackTransaction (Transaction*); // ----------------------------------------------------------------------------- // --SECTION-- private variables // ----------------------------------------------------------------------------- private: //////////////////////////////////////////////////////////////////////////////// /// @brief transaction id generator //////////////////////////////////////////////////////////////////////////////// IdGenerator _generator; //////////////////////////////////////////////////////////////////////////////// /// @brief R/W lock for transactions tables //////////////////////////////////////////////////////////////////////////////// basics::ReadWriteLock _lock; //////////////////////////////////////////////////////////////////////////////// /// @brief all running or aborted transactions //////////////////////////////////////////////////////////////////////////////// map _transactions; }; } } #endif // ----------------------------------------------------------------------------- // --SECTION-- END-OF-FILE // ----------------------------------------------------------------------------- // Local Variables: // mode: outline-minor // outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" // End: