diff --git a/arangod/Transaction/Collection.cpp b/arangod/Transaction/Collection.cpp deleted file mode 100644 index 4f08b868eb..0000000000 --- a/arangod/Transaction/Collection.cpp +++ /dev/null @@ -1,231 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction collection -/// -/// @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 -//////////////////////////////////////////////////////////////////////////////// - -#include "Collection.h" -#include "BasicsC/logging.h" -#include "Utils/Exception.h" -#include "VocBase/key-generator.h" -#include "VocBase/server.h" -#include "VocBase/vocbase.h" - -using namespace std; -using namespace triagens::transaction; - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create the transaction collection -//////////////////////////////////////////////////////////////////////////////// - -Collection::Collection (TRI_vocbase_col_t* collection, - Collection::AccessType accessType, - bool responsibility, - bool locked) - : _collection(collection), - _initialRevision(0), - _accessType(accessType), - _responsibility(responsibility), - _locked(locked), - _used(false) { -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy the transaction collection -//////////////////////////////////////////////////////////////////////////////// - -Collection::~Collection () { - done(); -} - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief generate a new revision -//////////////////////////////////////////////////////////////////////////////// - -TRI_voc_tick_t Collection::generateRevision () { - return TRI_NewTickServer(); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a new key -//////////////////////////////////////////////////////////////////////////////// - -string Collection::generateKey (TRI_voc_tick_t revision) { - // no key specified, now create one - TRI_key_generator_t* keyGenerator = static_cast(primary()->_keyGenerator); - - // create key using key generator - string key(keyGenerator->generateKey(keyGenerator, revision)); - - if (key.empty()) { - THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_OUT_OF_KEYS); - } - - return key; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief validate a key -//////////////////////////////////////////////////////////////////////////////// - -void Collection::validateKey (std::string const& key) { - TRI_key_generator_t* keyGenerator = static_cast(primary()->_keyGenerator); - - int res = keyGenerator->validateKey(keyGenerator, key); - - if (res != TRI_ERROR_NO_ERROR) { - THROW_ARANGO_EXCEPTION(res); - } -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief finalise usage of the collection -//////////////////////////////////////////////////////////////////////////////// - -int Collection::done () { - int res = unlock(); - unuse(); - - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief use the collection -//////////////////////////////////////////////////////////////////////////////// - -int Collection::use () { - if (hasResponsibility()) { - if (! _used) { - TRI_vocbase_col_t* collection = TRI_UseCollectionByIdVocBase(_collection->_vocbase, id()); - - if (collection == nullptr) { - return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND; - } - - if (collection->_collection == nullptr) { - return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND; - } - - _used = true; - } - } - - return TRI_ERROR_NO_ERROR; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief unuse the collection -//////////////////////////////////////////////////////////////////////////////// - -int Collection::unuse () { - if (hasResponsibility()) { - if (_used) { - TRI_ReleaseCollectionVocBase(_collection->_vocbase, _collection); - _used = false; - } - } - - return TRI_ERROR_NO_ERROR; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief lock the collection -//////////////////////////////////////////////////////////////////////////////// - -int Collection::lock () { - int res = TRI_ERROR_NO_ERROR; - - if (hasResponsibility()) { - if (! isLocked()) { - TRI_document_collection_t* p = primary(); - - if (p == nullptr) { - return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND; - } - - if (_accessType == Collection::AccessType::READ) { - res = p->beginRead(p); - } - else { - res = p->beginWrite(p); - } - - if (res == TRI_ERROR_NO_ERROR) { - _locked = true; - } - } - } - - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief unlock the collection -//////////////////////////////////////////////////////////////////////////////// - -int Collection::unlock () { - int res = TRI_ERROR_NO_ERROR; - - if (hasResponsibility()) { - if (isLocked()) { - TRI_document_collection_t* p = primary(); - - if (p == nullptr) { - return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND; - } - - if (_accessType == Collection::AccessType::READ) { - res = p->endRead(p); - } - else { - res = p->endWrite(p); - } - - if (res == TRI_ERROR_NO_ERROR) { - _locked = false; - } - } - } - - return res; -} - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/Collection.h b/arangod/Transaction/Collection.h deleted file mode 100644 index c646a5e0bf..0000000000 --- a/arangod/Transaction/Collection.h +++ /dev/null @@ -1,255 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction collection -/// -/// @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_COLLECTION_H -#define ARANGODB_TRANSACTION_COLLECTION_H 1 - -#include "Basics/Common.h" -#include "VocBase/primary-collection.h" -#include "VocBase/vocbase.h" - -namespace triagens { - namespace transaction { - -// ----------------------------------------------------------------------------- -// --SECTION-- class Collection -// ----------------------------------------------------------------------------- - - class Collection { - -// ----------------------------------------------------------------------------- -// --SECTION-- typedefs -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief access type -//////////////////////////////////////////////////////////////////////////////// - - enum class AccessType { - READ = 0, - WRITE = 1 // includes read - }; - - -//////////////////////////////////////////////////////////////////////////////// -/// @brief Operations -//////////////////////////////////////////////////////////////////////////////// - - private: - Collection (Collection const&); - Collection& operator= (Collection const&); - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create the transaction collection -//////////////////////////////////////////////////////////////////////////////// - - Collection (TRI_vocbase_col_t*, - Collection::AccessType, - bool, - bool); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy the transaction collection -//////////////////////////////////////////////////////////////////////////////// - - ~Collection (); - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief collection id -//////////////////////////////////////////////////////////////////////////////// - - inline TRI_voc_cid_t id () const { - return _collection->_cid; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief database id -//////////////////////////////////////////////////////////////////////////////// - - inline TRI_voc_tick_t databaseId () const { - return _collection->_vocbase->_id; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not write access is allowed -//////////////////////////////////////////////////////////////////////////////// - - inline bool allowWriteAccess () const { - return _accessType == AccessType::WRITE; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not the collection is currently locked -//////////////////////////////////////////////////////////////////////////////// - - inline bool isLocked () const { - return _locked; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not we are responsible for locking and using -//////////////////////////////////////////////////////////////////////////////// - - inline bool hasResponsibility () const { - return _responsibility; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief return the pointer to the primary collection -//////////////////////////////////////////////////////////////////////////////// - - inline TRI_document_collection_t* primary () const { - return _collection->_collection; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief generate a new revision -//////////////////////////////////////////////////////////////////////////////// - - TRI_voc_tick_t generateRevision (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a new key -//////////////////////////////////////////////////////////////////////////////// - - std::string generateKey (TRI_voc_tick_t); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief validate a key -//////////////////////////////////////////////////////////////////////////////// - - void validateKey (std::string const&); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief finalise usage of the collection -//////////////////////////////////////////////////////////////////////////////// - - int done (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief use the collection -//////////////////////////////////////////////////////////////////////////////// - - int use (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief unuse the collection -//////////////////////////////////////////////////////////////////////////////// - - int unuse (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief lock the collection -//////////////////////////////////////////////////////////////////////////////// - - int lock (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief unlock the collection -//////////////////////////////////////////////////////////////////////////////// - - int unlock (); - -// ----------------------------------------------------------------------------- -// --SECTION-- private methods -// ----------------------------------------------------------------------------- - - private: - -// ----------------------------------------------------------------------------- -// --SECTION-- private variables -// ----------------------------------------------------------------------------- - - private: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the pointer to the vocbase collection -//////////////////////////////////////////////////////////////////////////////// - - TRI_vocbase_col_t* _collection; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief initial revision of the collection -//////////////////////////////////////////////////////////////////////////////// - - TRI_voc_rid_t _initialRevision; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief access type for the collection -//////////////////////////////////////////////////////////////////////////////// - - Collection::AccessType const _accessType; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief are we responsible for using / locking ourselves? -//////////////////////////////////////////////////////////////////////////////// - - bool const _responsibility; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not the collection is currently locked -//////////////////////////////////////////////////////////////////////////////// - - bool _locked; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not we have used the collection -//////////////////////////////////////////////////////////////////////////////// - - bool _used; - - }; - - } -} - -#endif - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/Context.cpp b/arangod/Transaction/Context.cpp deleted file mode 100644 index 915b583610..0000000000 --- a/arangod/Transaction/Context.cpp +++ /dev/null @@ -1,234 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction context -/// -/// @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 -//////////////////////////////////////////////////////////////////////////////// - -#include "Context.h" - -#include "BasicsC/logging.h" -#include "Transaction/Collection.h" -#include "Transaction/Manager.h" -#include "Transaction/Transaction.h" -#include "Transaction/WorkUnit.h" -#include "VocBase/vocbase.h" -#include "Wal/LogfileManager.h" - -#define CONTEXT_LOG(msg) LOG_INFO("%s", msg) - -using namespace std; -using namespace triagens::transaction; -using namespace triagens::wal; - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create the transaction context -//////////////////////////////////////////////////////////////////////////////// - -Context::Context (Manager* manager, - wal::LogfileManager* logfileManager, - TRI_vocbase_t* vocbase, - Context** globalContext) - : _manager(manager), - _logfileManager(logfileManager), - _resolver(vocbase), - _globalContext(globalContext), - _transaction(0), - _workUnits(), - _nextWorkUnitId(0), - _refCount(0) { - - CONTEXT_LOG("creating context"); - - if (_globalContext != nullptr) { - *_globalContext = this; - } -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy the transaction context -//////////////////////////////////////////////////////////////////////////////// - -Context::~Context () { - TRI_ASSERT(_workUnits.empty()); - TRI_ASSERT(_transaction == nullptr); - - if (_globalContext != nullptr) { - *_globalContext = nullptr; - } - - CONTEXT_LOG("destroyed context"); -} - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief reuse or create a transaction context -//////////////////////////////////////////////////////////////////////////////// - -Context* Context::getContext (Manager* manager, - wal::LogfileManager* logfileManager, - TRI_vocbase_t* vocbase, - Context** globalContext) { - return createContext(manager, logfileManager, vocbase, globalContext); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a transaction context -//////////////////////////////////////////////////////////////////////////////// - -Context* Context::getContext (Manager* manager, - wal::LogfileManager* logfileManager, - TRI_vocbase_t* vocbase) { - return createContext(manager, logfileManager, vocbase, nullptr); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief increase the reference count -//////////////////////////////////////////////////////////////////////////////// - -void Context::increaseRefCount () { - ++_refCount; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief decrease the reference count -/// the last user that calls this will destroy the context! -//////////////////////////////////////////////////////////////////////////////// - -void Context::decreaseRefCount () { - TRI_ASSERT(_refCount > 0); - - if (--_refCount == 0) { - // last user has detached - delete this; - } -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief resolve a collection name -//////////////////////////////////////////////////////////////////////////////// - -TRI_vocbase_col_t* Context::resolveCollection (std::string const& name) const { - return const_cast(_resolver.getCollectionStruct(name)); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief find a collection in the top-level work units -//////////////////////////////////////////////////////////////////////////////// - -Collection* Context::findCollection (TRI_voc_cid_t id) const { - for (auto it = _workUnits.rbegin(); it != _workUnits.rend(); ++it) { - WorkUnit* workUnit = (*it); - - Collection* collection = workUnit->findCollection(id); - - if (collection != nullptr) { - // found the collection - return collection; - } - } - - // did not find the collection - return nullptr; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief start a new unit of work -//////////////////////////////////////////////////////////////////////////////// - -int Context::startWorkUnit (WorkUnit* workUnit) { - if (_workUnits.empty()) { - TRI_ASSERT(_transaction == nullptr); - - _transaction = _manager->createTransaction(workUnit->isSingleOperation()); - TRI_ASSERT(_transaction != nullptr); - } - - TRI_ASSERT(_transaction != nullptr); - - _workUnits.push_back(workUnit); - - return TRI_ERROR_NO_ERROR; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief end a unit of work -//////////////////////////////////////////////////////////////////////////////// - -int Context::endWorkUnit (WorkUnit* workUnit) { - TRI_ASSERT(! _workUnits.empty()); - - TRI_ASSERT(_workUnits.back() == workUnit); - - // pop last work unit from stack - _workUnits.pop_back(); - - if (_workUnits.empty()) { - // final level - if (_transaction != nullptr) { - delete _transaction; - _transaction = nullptr; - } - } - - return TRI_ERROR_NO_ERROR; -} - -// ----------------------------------------------------------------------------- -// --SECTION-- private methods -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a new transaction context -//////////////////////////////////////////////////////////////////////////////// - -Context* Context::createContext (Manager* manager, - wal::LogfileManager* logfileManager, - TRI_vocbase_t* vocbase, - Context** globalContext) { - if (globalContext == nullptr || - *globalContext == nullptr) { - return new Context(manager, logfileManager, vocbase, globalContext); - } - - return *globalContext; -} - - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/Context.h b/arangod/Transaction/Context.h deleted file mode 100644 index 8001196d2a..0000000000 --- a/arangod/Transaction/Context.h +++ /dev/null @@ -1,262 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction context -/// -/// @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_CONTEXT_H -#define ARANGODB_TRANSACTION_CONTEXT_H 1 - -#include "Basics/Common.h" -#include "Utils/CollectionNameResolver.h" -#include "VocBase/vocbase.h" - -namespace triagens { - namespace wal { - class LogfileManager; - } - - namespace transaction { - - class Collection; - - class Manager; - - class Transaction; - - class WorkUnit; - -// ----------------------------------------------------------------------------- -// --SECTION-- class Context -// ----------------------------------------------------------------------------- - - class Context { - -//////////////////////////////////////////////////////////////////////////////// -/// @brief Context -//////////////////////////////////////////////////////////////////////////////// - - private: - Context (Context const&); - Context& operator= (Context const&); - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a transaction context -//////////////////////////////////////////////////////////////////////////////// - - Context (Manager*, - triagens::wal::LogfileManager*, - TRI_vocbase_t*, - Context**); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy a transaction context -//////////////////////////////////////////////////////////////////////////////// - - ~Context (); - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief return the next work unit id inside the context -//////////////////////////////////////////////////////////////////////////////// - - inline uint64_t nextWorkUnitId () { - return ++_nextWorkUnitId; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief logfile manager -//////////////////////////////////////////////////////////////////////////////// - - inline wal::LogfileManager* logfileManager () const { - return _logfileManager; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief return the current transaction -//////////////////////////////////////////////////////////////////////////////// - - inline Transaction* transaction () const { - return _transaction; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief return the current nesting level -//////////////////////////////////////////////////////////////////////////////// - - inline int level () const { - return _workUnits.size(); - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief resolve a collection name -//////////////////////////////////////////////////////////////////////////////// - - TRI_vocbase_col_t* resolveCollection (std::string const&) const; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief find a collection in the top-level work units -//////////////////////////////////////////////////////////////////////////////// - - Collection* findCollection (TRI_voc_cid_t) const; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief get or create a transaction context -//////////////////////////////////////////////////////////////////////////////// - - static Context* getContext (Manager*, - triagens::wal::LogfileManager*, - TRI_vocbase_t*, - Context**); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a transaction context -//////////////////////////////////////////////////////////////////////////////// - - static Context* getContext (Manager*, - triagens::wal::LogfileManager*, - TRI_vocbase_t*); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief increase the reference count -//////////////////////////////////////////////////////////////////////////////// - - void increaseRefCount (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief decrease the reference count -/// the last user that calls this will destroy the context! -//////////////////////////////////////////////////////////////////////////////// - - void decreaseRefCount (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief start a new unit of work -//////////////////////////////////////////////////////////////////////////////// - - int startWorkUnit (WorkUnit*); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief end a unit of work -//////////////////////////////////////////////////////////////////////////////// - - int endWorkUnit (WorkUnit*); - -// ----------------------------------------------------------------------------- -// --SECTION-- private methods -// ----------------------------------------------------------------------------- - - private: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a new transaction context -//////////////////////////////////////////////////////////////////////////////// - - static Context* createContext (Manager*, - triagens::wal::LogfileManager*, - TRI_vocbase_t*, - Context**); - -// ----------------------------------------------------------------------------- -// --SECTION-- private variables -// ----------------------------------------------------------------------------- - - private: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the transaction manager -//////////////////////////////////////////////////////////////////////////////// - - Manager* _manager; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the logfile manager -//////////////////////////////////////////////////////////////////////////////// - - triagens::wal::LogfileManager* _logfileManager; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the collection name resolver -//////////////////////////////////////////////////////////////////////////////// - - triagens::arango::CollectionNameResolver _resolver; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief address to update with our context -//////////////////////////////////////////////////////////////////////////////// - - Context** _globalContext; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the underlying transaction -//////////////////////////////////////////////////////////////////////////////// - - Transaction* _transaction; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the current work units -//////////////////////////////////////////////////////////////////////////////// - - std::vector _workUnits; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief id for next work unit -//////////////////////////////////////////////////////////////////////////////// - - uint64_t _nextWorkUnitId; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the current number of users of this context -//////////////////////////////////////////////////////////////////////////////// - - int _refCount; - - }; - - } -} - -#endif - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/Helper.cpp b/arangod/Transaction/Helper.cpp deleted file mode 100644 index 7d281e2d46..0000000000 --- a/arangod/Transaction/Helper.cpp +++ /dev/null @@ -1,109 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief static transaction helper functions -/// -/// @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 -//////////////////////////////////////////////////////////////////////////////// - -#include "Helper.h" -#include "Transaction/transactions.h" -#include "VocBase/vocbase.h" - -using namespace std; -using namespace triagens::basics; -using namespace triagens::transaction; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief append a document key -//////////////////////////////////////////////////////////////////////////////// - -bool Helper::appendKey (Bson& document, - string const& key) { - return document.appendUtf8(string(TRI_VOC_ATTRIBUTE_KEY), key); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief extract a document key -/// this will throw if the document key is invalid -/// if the document does not contain the _key attribute, an empty string will -/// be returned -//////////////////////////////////////////////////////////////////////////////// - -string Helper::documentKey (Bson const& document) { - BsonIter iter(document); - - if (! iter.find(TRI_VOC_ATTRIBUTE_KEY)) { - // no _key attribute - return ""; - } - - // document has _key attribute - if (iter.getType() != BSON_TYPE_UTF8) { - // _key has an invalid type - THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_DOCUMENT_KEY_BAD); - } - - // _key is a string - string const key = iter.getUtf8(); - - if (key.empty()) { - // _key is empty - THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_DOCUMENT_KEY_BAD); - } - - return key; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief creates a BSON document from the string -//////////////////////////////////////////////////////////////////////////////// - -Bson Helper::documentFromJson (string const& data) { - return documentFromJson(data.c_str(), data.size()); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief creates a BSON document from the string -//////////////////////////////////////////////////////////////////////////////// - -Bson Helper::documentFromJson (char const* data, - size_t length) { - Bson document; - - if (! document.fromJson(data)) { - THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_DOCUMENT_TYPE_INVALID); - } - - return document; -} - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/Helper.h b/arangod/Transaction/Helper.h deleted file mode 100644 index 436219c9e3..0000000000 --- a/arangod/Transaction/Helper.h +++ /dev/null @@ -1,84 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief static transaction helper functions -/// -/// @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_HELPER_H -#define ARANGODB_TRANSACTION_HELPER_H 1 - -#include "Basics/Common.h" -#include "Basics/BsonHelper.h" - -namespace triagens { - namespace transaction { - - class Helper { - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief append a document key -//////////////////////////////////////////////////////////////////////////////// - - static bool appendKey (basics::Bson&, - std::string const&); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief extract a document key -/// this will throw if the document key is invalid -/// if the document does not contain the _key attribute, an empty string will -/// be returned -//////////////////////////////////////////////////////////////////////////////// - - static std::string documentKey (basics::Bson const&); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief creates a BSON document from the string -//////////////////////////////////////////////////////////////////////////////// - - static basics::Bson documentFromJson (std::string const&); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief creates a BSON document from the string -//////////////////////////////////////////////////////////////////////////////// - - static basics::Bson documentFromJson (char const*, - size_t); - - }; - } -} - -#endif - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/IdGenerator.cpp b/arangod/Transaction/IdGenerator.cpp deleted file mode 100644 index a361fcb500..0000000000 --- a/arangod/Transaction/IdGenerator.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction id generator -/// -/// @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 -//////////////////////////////////////////////////////////////////////////////// - -#include "IdGenerator.h" -#include "VocBase/server.h" - -using namespace std; -using namespace triagens::transaction; - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create an id generator -//////////////////////////////////////////////////////////////////////////////// - -IdGenerator::IdGenerator (TRI_voc_tid_t id) { - setLastId(id); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy an id generator -//////////////////////////////////////////////////////////////////////////////// - -IdGenerator::~IdGenerator () { -} - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief set minimal transaction id -//////////////////////////////////////////////////////////////////////////////// - -void IdGenerator::setLastId (TRI_voc_tid_t id) { - TRI_UpdateTickServer(static_cast(id)); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a transaction id -//////////////////////////////////////////////////////////////////////////////// - -TRI_voc_tid_t IdGenerator::next () { - return static_cast(TRI_NewTickServer()); -} - -// ----------------------------------------------------------------------------- -// --SECTION-- private methods -// ----------------------------------------------------------------------------- - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/IdGenerator.h b/arangod/Transaction/IdGenerator.h deleted file mode 100644 index 846320e61f..0000000000 --- a/arangod/Transaction/IdGenerator.h +++ /dev/null @@ -1,97 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction id generator -/// -/// @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_ID_GENERATOR_H -#define ARANGODB_TRANSACTION_ID_GENERATOR_H 1 - -#include "Basics/Common.h" -#include "Transaction/Transaction.h" - -namespace triagens { - namespace transaction { - -// ----------------------------------------------------------------------------- -// --SECTION-- class IdGenerator -// ----------------------------------------------------------------------------- - - class IdGenerator { - -//////////////////////////////////////////////////////////////////////////////// -/// @brief Transaction -//////////////////////////////////////////////////////////////////////////////// - - private: - IdGenerator (IdGenerator const&); - IdGenerator& operator= (IdGenerator const&); - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create an id generator -//////////////////////////////////////////////////////////////////////////////// - - IdGenerator (TRI_voc_tid_t = 0); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy an id generator -//////////////////////////////////////////////////////////////////////////////// - - ~IdGenerator (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief set minimal transaction id -//////////////////////////////////////////////////////////////////////////////// - - void setLastId (TRI_voc_tid_t id); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a transaction id -//////////////////////////////////////////////////////////////////////////////// - - TRI_voc_tid_t next (); - - }; - - } -} - -#endif - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/Manager.cpp b/arangod/Transaction/Manager.cpp deleted file mode 100644 index 15c5503778..0000000000 --- a/arangod/Transaction/Manager.cpp +++ /dev/null @@ -1,278 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @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 -//////////////////////////////////////////////////////////////////////////////// - -#include "Manager.h" -#include "Basics/ReadLocker.h" -#include "Basics/WriteLocker.h" -#include "Transaction/IdGenerator.h" -#include "Transaction/State.h" -#include "VocBase/vocbase.h" - -using namespace std; -using namespace triagens::transaction; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the transaction manager singleton -//////////////////////////////////////////////////////////////////////////////// - -static Manager* Instance = nullptr; - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create the transaction manager -//////////////////////////////////////////////////////////////////////////////// - -Manager::Manager () - : _generator(), - _lock(), - _transactions() { -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy the transaction manager -//////////////////////////////////////////////////////////////////////////////// - -Manager::~Manager () { - WRITE_LOCKER(_lock); - - for (auto it = _transactions.begin(); it != _transactions.end(); ++it) { - Transaction* transaction = (*it).second; - - if (transaction->state() == State::StateType::BEGUN) { - transaction->setState(State::StateType::ABORTED); - } - } - - _transactions.clear(); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief get the transaction manager instance -//////////////////////////////////////////////////////////////////////////////// - -Manager* Manager::instance () { - TRI_ASSERT(Instance != nullptr); - return Instance; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief initialise the transaction manager instance -//////////////////////////////////////////////////////////////////////////////// - -void Manager::initialise () { - TRI_ASSERT(Instance == nullptr); - - Instance = new Manager(); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief shutdown the transaction manager instance -//////////////////////////////////////////////////////////////////////////////// - -void Manager::shutdown () { - if (Instance != nullptr) { - delete Instance; - Instance = nullptr; - } -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a transaction object -//////////////////////////////////////////////////////////////////////////////// - -Transaction* Manager::createTransaction (bool singleOperation) { - TRI_voc_tid_t id = _generator.next(); - - Transaction* transaction = new Transaction(this, id, singleOperation); - - WRITE_LOCKER(_lock); - auto it = _transactions.insert(make_pair(id, transaction)); - - if (it.first == _transactions.end()) { - // couldn't insert transaction - delete transaction; - - return nullptr; - } - - return transaction; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief return the status of a transaction -//////////////////////////////////////////////////////////////////////////////// - -Transaction::StateType Manager::statusTransaction (TRI_voc_tid_t id) { - READ_LOCKER(_lock); - - auto it = _transactions.find(id); - if (it != _transactions.end()) { - return (*it).second->state(); - } - - // unknown transaction. probably already committed - return State::StateType::COMMITTED; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief get oldest still running transaction -//////////////////////////////////////////////////////////////////////////////// - -TransactionInfo Manager::getOldestRunning () { - READ_LOCKER(_lock); - - for (auto it = _transactions.begin(); it != _transactions.end(); ++it) { - Transaction* transaction = (*it).second; - - if (transaction->state() == State::StateType::BEGUN) { - return TransactionInfo(transaction->id(), transaction->elapsedTime()); - } - } - - return TransactionInfo(); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief check whether any of the specified transactions is still running -//////////////////////////////////////////////////////////////////////////////// - -bool Manager::containsRunning (vector const& ids) { - READ_LOCKER(_lock); - - for (auto it = ids.begin(); it != ids.end(); ++it) { - auto it2 = _transactions.find(*it); - - if (it2 != _transactions.end()) { - Transaction* transaction = (*it2).second; - - if (transaction->state() == State::StateType::BEGUN) { - return true; - } - } - } - - return false; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove failed transactions from the failed list -//////////////////////////////////////////////////////////////////////////////// - -int Manager::removeFailed (vector const& ids) { - WRITE_LOCKER(_lock); - - for (auto it = ids.begin(); it != ids.end(); ++it) { - _transactions.erase(*it); - } - - return TRI_ERROR_NO_ERROR; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief begin a transaction -//////////////////////////////////////////////////////////////////////////////// - -int Manager::beginTransaction (Transaction* transaction) { - WRITE_LOCKER(_lock); - - // check the transaction state first - if (transaction->state() != State::StateType::UNINITIALISED) { - transaction->setState(State::StateType::ABORTED); - return TRI_ERROR_TRANSACTION_INTERNAL; - } - - // sets status and start time stamp - transaction->setState(State::StateType::BEGUN); - - return TRI_ERROR_NO_ERROR; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief commit a transaction -//////////////////////////////////////////////////////////////////////////////// - -int Manager::commitTransaction (Transaction* transaction, - bool waitForSync) { - TRI_voc_tid_t id = transaction->id(); - - WRITE_LOCKER(_lock); - - if (transaction->state() != State::StateType::BEGUN) { - // set it to aborted - transaction->setState(State::StateType::ABORTED); - return TRI_ERROR_TRANSACTION_INTERNAL; - } - - transaction->setState(State::StateType::COMMITTED); - - auto it = _transactions.find(id); - - if (it == _transactions.end()) { - // not found - return TRI_ERROR_TRANSACTION_INTERNAL; - } - - // erase it in the list of transactions - _transactions.erase(id); - - return TRI_ERROR_NO_ERROR; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief rollback a transaction -//////////////////////////////////////////////////////////////////////////////// - -int Manager::rollbackTransaction (Transaction* transaction) { - WRITE_LOCKER(_lock); - - if (transaction->state() != State::StateType::BEGUN) { - // TODO: set it to aborted - return TRI_ERROR_TRANSACTION_INTERNAL; - } - - transaction->setState(State::StateType::ABORTED); - - // leave it in the list of transactions - return TRI_ERROR_NO_ERROR; -} - -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/Manager.h b/arangod/Transaction/Manager.h deleted file mode 100644 index adab8cdd6d..0000000000 --- a/arangod/Transaction/Manager.h +++ /dev/null @@ -1,178 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @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: diff --git a/arangod/Transaction/Marker.h b/arangod/Transaction/Marker.h deleted file mode 100644 index 2442f8cc7a..0000000000 --- a/arangod/Transaction/Marker.h +++ /dev/null @@ -1,152 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction markers -/// -/// @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_MARKER_H -#define ARANGODB_TRANSACTION_MARKER_H 1 - -#include "Basics/Common.h" -#include "Basics/BsonHelper.h" -#include "VocBase/datafile.h" - -namespace triagens { - namespace transaction { - - struct Marker { - Marker (TRI_df_marker_type_e type, - size_t size) - : buffer(new char[sizeof(TRI_df_marker_t) + size]), - size(sizeof(TRI_df_marker_t) + size) { - - // initialise the marker header - auto h = header(); - h->_type = type; - h->_size = static_cast(size); - h->_crc = 0; - h->_tick = 0; - } - - virtual ~Marker () { - if (buffer != nullptr) { - delete buffer; - } - } - - inline TRI_df_marker_t* header () const { - return (TRI_df_marker_t*) buffer; - } - - inline char* data () const { - return (char*) buffer + sizeof(TRI_df_marker_t); - } - - inline void advance (char*& ptr, size_t length) { - ptr += length; - } - - template void store (char*& ptr, T value) { - *((T*) ptr) = value; - advance(ptr, sizeof(T)); - } - - void store (char*& ptr, char const* src, size_t length) { - memcpy(ptr, src, length); - advance(ptr, length); - } - - char* buffer; - uint32_t const size; - }; - - struct DocumentMarker : public Marker { - DocumentMarker (TRI_voc_tick_t databaseId, - TRI_voc_cid_t collectionId, - TRI_voc_tid_t transactionId, - std::string const& key, - TRI_voc_tick_t revision, - triagens::basics::Bson const& document) - : Marker(TRI_WAL_MARKER_DOCUMENT, - sizeof(TRI_voc_tick_t) + sizeof(TRI_voc_cid_t) + sizeof(TRI_voc_tid_t) + sizeof(TRI_voc_tick_t) + key.size() + 2 + document.getSize()) { - - char* p = data(); - store(p, databaseId); - store(p, collectionId); - store(p, transactionId); - store(p, revision); - - // store key - store(p, (uint8_t) key.size()); - store(p, key.c_str(), key.size()); - store(p, '\0'); - - // store bson - store(p, (char const*) document.getBuffer(), static_cast(document.getSize())); - } - - ~DocumentMarker () { - } - - }; - - struct RemoveMarker : public Marker { - RemoveMarker (TRI_voc_tick_t databaseId, - TRI_voc_cid_t collectionId, - TRI_voc_tid_t transactionId, - std::string const& key) - : Marker(TRI_WAL_MARKER_REMOVE, - sizeof(TRI_voc_tick_t) + sizeof(TRI_voc_cid_t) + sizeof(TRI_voc_tid_t) + key.size() + 2) { - - char* p = data(); - store(p, databaseId); - store(p, collectionId); - store(p, transactionId); - - // store key - store(p, (uint8_t) key.size()); - store(p, key.c_str(), key.size()); - store(p, '\0'); - } - - ~RemoveMarker () { - } - - }; - - } -} - -#endif - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/Operations.cpp b/arangod/Transaction/Operations.cpp deleted file mode 100644 index 25a11e6461..0000000000 --- a/arangod/Transaction/Operations.cpp +++ /dev/null @@ -1,98 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction operations interface -/// -/// @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 -//////////////////////////////////////////////////////////////////////////////// - -#include "Operations.h" - -#include "BasicsC/logging.h" - -using namespace std; -using namespace triagens::transaction; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief get a document -//////////////////////////////////////////////////////////////////////////////// - -int getDocument () { - int res = TRI_ERROR_NO_ERROR; - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief save a document -//////////////////////////////////////////////////////////////////////////////// - -int saveDocument () { - int res = TRI_ERROR_NO_ERROR; - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove a document -//////////////////////////////////////////////////////////////////////////////// - -int removeDocument () { - int res = TRI_ERROR_NO_ERROR; - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief update a document -//////////////////////////////////////////////////////////////////////////////// - -int updateDocument () { - int res = TRI_ERROR_NO_ERROR; - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief replace a document -//////////////////////////////////////////////////////////////////////////////// - -int replaceDocument () { - int res = TRI_ERROR_NO_ERROR; - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief truncate a collection -//////////////////////////////////////////////////////////////////////////////// - -int truncate () { - int res = TRI_ERROR_NO_ERROR; - return res; -} - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/Operations.h b/arangod/Transaction/Operations.h deleted file mode 100644 index d3f1761b1c..0000000000 --- a/arangod/Transaction/Operations.h +++ /dev/null @@ -1,85 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction operations interface -/// -/// @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_OPERATIONS_H -#define ARANGODB_TRANSACTION_OPERATIONS_H 1 - -#include "Basics/Common.h" - -namespace triagens { - namespace transaction { - -//////////////////////////////////////////////////////////////////////////////// -/// @brief get a document -//////////////////////////////////////////////////////////////////////////////// - - int getDocument (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief save a document -//////////////////////////////////////////////////////////////////////////////// - - int saveDocument (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief remove a document -//////////////////////////////////////////////////////////////////////////////// - - int removeDocument (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief update a document -//////////////////////////////////////////////////////////////////////////////// - - int updateDocument (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief replace a document -//////////////////////////////////////////////////////////////////////////////// - - int replaceDocument (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief truncate a collection -//////////////////////////////////////////////////////////////////////////////// - - int truncate (); - } -} - -#endif - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/State.cpp b/arangod/Transaction/State.cpp deleted file mode 100644 index ba44c035f7..0000000000 --- a/arangod/Transaction/State.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction state -/// -/// @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 -//////////////////////////////////////////////////////////////////////////////// - -#include "State.h" - -using namespace std; -using namespace triagens::transaction; - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create the state -//////////////////////////////////////////////////////////////////////////////// - -State::State () - : _state(StateType::UNINITIALISED) { - -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy the state -//////////////////////////////////////////////////////////////////////////////// - -State::~State () { -} - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/State.h b/arangod/Transaction/State.h deleted file mode 100644 index 063af03277..0000000000 --- a/arangod/Transaction/State.h +++ /dev/null @@ -1,153 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction state -/// -/// @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_STATE_H -#define ARANGODB_TRANSACTION_STATE_H 1 - -#include "Basics/Common.h" - -namespace triagens { - namespace transaction { - -// ----------------------------------------------------------------------------- -// --SECTION-- class State -// ----------------------------------------------------------------------------- - - class State { - -// ----------------------------------------------------------------------------- -// --SECTION-- typedefs -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction state -//////////////////////////////////////////////////////////////////////////////// - - enum class StateType { - UNINITIALISED = 0, - BEGUN = 1, - ABORTED = 2, - COMMITTED = 3 - }; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief State -//////////////////////////////////////////////////////////////////////////////// - - private: - State (State const&); - State& operator= (State const&); - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a state -//////////////////////////////////////////////////////////////////////////////// - - State (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy a state -//////////////////////////////////////////////////////////////////////////////// - - virtual ~State (); - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - - public: - -/////////////////////////////////////////////////////////////////////////////// -/// @brief get the transaction state -//////////////////////////////////////////////////////////////////////////////// - - inline StateType state () const { - return _state; - } - -/////////////////////////////////////////////////////////////////////////////// -/// @brief set the transaction state -//////////////////////////////////////////////////////////////////////////////// - - inline void setState (StateType state) { - _state = state; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief begin a transaction -//////////////////////////////////////////////////////////////////////////////// - - virtual int begin () = 0; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief commit a transaction -//////////////////////////////////////////////////////////////////////////////// - - virtual int commit (bool) = 0; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief rollback a transaction -//////////////////////////////////////////////////////////////////////////////// - - virtual int rollback () = 0; - -// ----------------------------------------------------------------------------- -// --SECTION-- private variables -// ----------------------------------------------------------------------------- - - private: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction state -//////////////////////////////////////////////////////////////////////////////// - - StateType _state; - - }; - - } -} - -#endif - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/Transaction.cpp b/arangod/Transaction/Transaction.cpp deleted file mode 100644 index 7f460ddfe5..0000000000 --- a/arangod/Transaction/Transaction.cpp +++ /dev/null @@ -1,130 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction -/// -/// @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 -//////////////////////////////////////////////////////////////////////////////// - -#include "Transaction.h" - -#include "BasicsC/logging.h" -#include "Transaction/Manager.h" - -using namespace std; -using namespace triagens::transaction; - -#define TRANSACTION_LOG(msg) LOG_INFO("trx #%llu: %s", (unsigned long long) _id, msg) - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create the transaction -//////////////////////////////////////////////////////////////////////////////// - -Transaction::Transaction (Manager* manager, - TRI_voc_tid_t id, - bool singleOperation, - bool waitForSync) - : State(), - _manager(manager), - _id(id), - _singleOperation(singleOperation), - _waitForSync(waitForSync), - _startTime() { - - TRANSACTION_LOG("creating transaction"); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy the transaction -//////////////////////////////////////////////////////////////////////////////// - -Transaction::~Transaction () { - if (state() != State::StateType::COMMITTED && - state() != State::StateType::ABORTED) { - this->rollback(); - } - - TRANSACTION_LOG("destroyed transaction"); -} - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief begin a transaction -//////////////////////////////////////////////////////////////////////////////// - -int Transaction::begin () { - if (state() != State::StateType::UNINITIALISED) { - return TRI_ERROR_TRANSACTION_INTERNAL; - } - - TRANSACTION_LOG("beginning transaction"); - int res = _manager->beginTransaction(this); - - if (res == TRI_ERROR_NO_ERROR) { - _startTime = TRI_microtime(); - } - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief commit a transaction -//////////////////////////////////////////////////////////////////////////////// - -int Transaction::commit (bool waitForSync) { - if (state() != State::StateType::BEGUN) { - return TRI_ERROR_TRANSACTION_INTERNAL; - } - - TRANSACTION_LOG("committing transaction"); - return _manager->commitTransaction(this, waitForSync || _waitForSync); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief rollback a transaction -//////////////////////////////////////////////////////////////////////////////// - -int Transaction::rollback () { - if (state() != State::StateType::BEGUN) { - return TRI_ERROR_TRANSACTION_INTERNAL; - } - - TRANSACTION_LOG("rolling back transaction"); - return _manager->rollbackTransaction(this); -} - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/Transaction.h b/arangod/Transaction/Transaction.h deleted file mode 100644 index bf8e0ccbff..0000000000 --- a/arangod/Transaction/Transaction.h +++ /dev/null @@ -1,236 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction -/// -/// @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_TRANSACTION_H -#define ARANGODB_TRANSACTION_TRANSACTION_H 1 - -#include "Basics/Common.h" -#include "Transaction/State.h" -#include "VocBase/voc-types.h" - -namespace triagens { - namespace transaction { - - class Manager; - -// ----------------------------------------------------------------------------- -// --SECTION-- class Transaction -// ----------------------------------------------------------------------------- - - class Transaction : public State { - - friend class Manager; - -// ----------------------------------------------------------------------------- -// --SECTION-- typedefs -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief Transaction -//////////////////////////////////////////////////////////////////////////////// - - private: - Transaction (Transaction const&); - Transaction& operator= (Transaction const&); - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a transaction -//////////////////////////////////////////////////////////////////////////////// - - Transaction (Manager*, - TRI_voc_tid_t, - bool, - bool = false); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy a transaction -//////////////////////////////////////////////////////////////////////////////// - - ~Transaction (); - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief get the transaction id -//////////////////////////////////////////////////////////////////////////////// - - inline TRI_voc_tid_t id () const { - return _id; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief get the transaction id for writing it into a marker -//////////////////////////////////////////////////////////////////////////////// - - inline TRI_voc_tid_t idForMarker () const { - if (_singleOperation) { - return 0; - } - return id(); - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief is single operation? -//////////////////////////////////////////////////////////////////////////////// - - inline bool singleOperation () const { - return _singleOperation; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief is synchronous? -//////////////////////////////////////////////////////////////////////////////// - - inline bool waitForSync () const { - return _waitForSync; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief get the transaction start time stamp -//////////////////////////////////////////////////////////////////////////////// - - inline double startTime () const { - return _startTime; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief get the time since transaction start -//////////////////////////////////////////////////////////////////////////////// - - inline double elapsedTime () const { - if (state() == State::StateType::BEGUN) { - return TRI_microtime() - _startTime; - } - return 0.0; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief begin a transaction -//////////////////////////////////////////////////////////////////////////////// - - int begin (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief commit a transaction -//////////////////////////////////////////////////////////////////////////////// - - int commit (bool); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief rollback a transaction -//////////////////////////////////////////////////////////////////////////////// - - int rollback (); - -// ----------------------------------------------------------------------------- -// --SECTION-- private variables -// ----------------------------------------------------------------------------- - - private: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the transaction manager -//////////////////////////////////////////////////////////////////////////////// - - Manager* _manager; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction id -//////////////////////////////////////////////////////////////////////////////// - - TRI_voc_tid_t const _id; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not the transaction consists of a single operation -//////////////////////////////////////////////////////////////////////////////// - -// TODO: do we need this? - bool const _singleOperation; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not the transaction is synchronous -//////////////////////////////////////////////////////////////////////////////// - -// TODO: do we need this? - bool _waitForSync; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief timestamp of transaction start -//////////////////////////////////////////////////////////////////////////////// - - double _startTime; - - }; - -// ----------------------------------------------------------------------------- -// --SECTION-- TransactionInfo -// ----------------------------------------------------------------------------- - - // TODO: move to separate file - struct TransactionInfo { - TransactionInfo (TRI_voc_tid_t id, - double elapsedTime) - : _id(id), - _elapsedTime(elapsedTime) { - } - - TransactionInfo () - : _id(0), - _elapsedTime(0.0) { - } - - TRI_voc_tid_t const _id; - double const _elapsedTime; - }; - - } -} - -#endif - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/WorkUnit.cpp b/arangod/Transaction/WorkUnit.cpp deleted file mode 100644 index 1ecc372ce4..0000000000 --- a/arangod/Transaction/WorkUnit.cpp +++ /dev/null @@ -1,365 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction context -/// -/// @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 -//////////////////////////////////////////////////////////////////////////////// - -#include "WorkUnit.h" -#include "BasicsC/logging.h" -#include "Transaction/Collection.h" -#include "Transaction/Context.h" -#include "Transaction/Helper.h" -#include "Transaction/Marker.h" -#include "Transaction/Transaction.h" -#include "Utils/Exception.h" -#include "VocBase/vocbase.h" -#include "Wal/LogfileManager.h" - -#define WORKUNIT_LOG(msg) LOG_INFO("workunit #%llu: %s", (unsigned long long) _id, msg) - -using namespace std; -using namespace triagens::transaction; -using namespace triagens::wal; - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a transaction work unit -//////////////////////////////////////////////////////////////////////////////// - -WorkUnit::WorkUnit (Context* context, - bool singleOperation) - : State(), - _context(context), - _id(context->nextWorkUnitId()), - _level(context->level()), - _singleOperation(singleOperation), - _done(false) { - - _context->increaseRefCount(); - - _context->startWorkUnit(this); - WORKUNIT_LOG("starting"); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy a transaction work unit -//////////////////////////////////////////////////////////////////////////////// - -WorkUnit::~WorkUnit () { - WORKUNIT_LOG("destroyed"); - done(); - - _context->decreaseRefCount(); -} - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief add a collection to the unit, assert a specific collection type -//////////////////////////////////////////////////////////////////////////////// - -Collection* WorkUnit::addCollection (string const& name, - Collection::AccessType accessType, - TRI_col_type_e collectionType, - bool lockResponsibility, - bool locked) { - TRI_vocbase_col_t* collection = _context->resolveCollection(name); - - if (collection == nullptr) { - THROW_ARANGO_EXCEPTION_STRING(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND, name); - } - - if (collection->_type != static_cast(collectionType)) { - THROW_ARANGO_EXCEPTION_STRING(TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID, name); - } - - return addCollection(collection->_cid, collection, accessType, lockResponsibility, locked); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief add a collection to the unit -//////////////////////////////////////////////////////////////////////////////// - -Collection* WorkUnit::addCollection (string const& name, - Collection::AccessType accessType, - bool lockResponsibility, - bool locked) { - TRI_vocbase_col_t* collection = _context->resolveCollection(name); - - if (collection == nullptr) { - THROW_ARANGO_EXCEPTION_STRING(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND, name); - } - - return addCollection(collection->_cid, collection, accessType, lockResponsibility, locked); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief add a collection to the unit -//////////////////////////////////////////////////////////////////////////////// - -Collection* WorkUnit::addCollection (TRI_voc_cid_t id, - TRI_vocbase_col_t* collection, - Collection::AccessType accessType, - bool lockResponsibility, - bool locked) { - if (id == 0) { - THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND); - } - - auto it = _collections.find(id); - - if (it != _collections.end()) { - if (accessType == Collection::AccessType::WRITE && - ! (*it).second->allowWriteAccess()) { - THROW_ARANGO_EXCEPTION(TRI_ERROR_TRANSACTION_INTERNAL); - } - - return (*it).second; - } - - Collection* c = _context->findCollection(id); - - if (c == nullptr) { - // no previous collection found, now insert it - c = new Collection(collection, accessType, lockResponsibility, locked); - - _collections.insert(make_pair(id, c)); - } - - return c; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief find a collection in a unit of work -//////////////////////////////////////////////////////////////////////////////// - -Collection* WorkUnit::findCollection (TRI_voc_cid_t id) const { - auto it = _collections.find(id); - if (it != _collections.end()) { - return (*it).second; - } - return nullptr; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief begin a unit of work -//////////////////////////////////////////////////////////////////////////////// - -int WorkUnit::begin () { - if (state() != State::StateType::UNINITIALISED) { - return TRI_ERROR_TRANSACTION_INTERNAL; - } - - WORKUNIT_LOG("begin"); - - int res = TRI_ERROR_NO_ERROR; - for (auto& it : _collections) { - res = it.second->use(); - if (res != TRI_ERROR_NO_ERROR) { - return res; - } - - res = it.second->lock(); - if (res != TRI_ERROR_NO_ERROR) { - return res; - } - } - - if (! isTopLevel()) { - res = TRI_ERROR_NO_ERROR; - } - else { - Transaction* transaction = _context->transaction(); - res = transaction->begin(); - } - - setState(State::StateType::BEGUN); - - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief commit a unit of work -//////////////////////////////////////////////////////////////////////////////// - -int WorkUnit::commit (bool waitForSync) { - if (state() != State::StateType::BEGUN) { - return TRI_ERROR_TRANSACTION_INTERNAL; - } - - WORKUNIT_LOG("commit"); - - int res; - if (! isTopLevel()) { - res = TRI_ERROR_NO_ERROR; - } - else { - Transaction* transaction = _context->transaction(); - res = transaction->commit(waitForSync); - } - - done(); - setState(State::StateType::COMMITTED); - - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief rollback a unit of work -//////////////////////////////////////////////////////////////////////////////// - -int WorkUnit::rollback () { - if (state() != State::StateType::BEGUN) { - return TRI_ERROR_TRANSACTION_INTERNAL; - } - - WORKUNIT_LOG("rollback"); - - int res; - if (! isTopLevel()) { - res = TRI_ERROR_NO_ERROR; - } - else { - Transaction* transaction = _context->transaction(); - res = transaction->rollback(); - } - - done(); - setState(State::StateType::ABORTED); - - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief save a single document -//////////////////////////////////////////////////////////////////////////////// - -int WorkUnit::saveDocument (Collection* collection, - triagens::basics::Bson& document, - bool waitForSync) { - // generate a tick value - TRI_voc_tick_t revision = collection->generateRevision(); - - // validate or create key - string key(Helper::documentKey(document)); - if (key.empty()) { - // no key specified. now create one - key = collection->generateKey(revision); - Helper::appendKey(document, key); - } - else { - // a key was specified, now validate it - collection->validateKey(key); - } - - // TODO: remove _key attribute from BSON document - - // TODO: distinct between document and edge markers - Transaction* transaction = _context->transaction(); - DocumentMarker marker(collection->databaseId(), collection->id(), transaction->idForMarker(), key, revision, document); - - LogfileManager* logfileManager = _context->logfileManager(); - - int res = logfileManager->allocateAndWrite(marker.buffer, - marker.size, - waitForSync); - - // TODO: insert into indexes - // TODO: return TRI_doc_mptr_t* - - return res; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief delete a single document -//////////////////////////////////////////////////////////////////////////////// - -int WorkUnit::deleteDocument (Collection* collection, - string const& key, -// WriteOperationContext& operationContext, - bool waitForSync) { - - Transaction* transaction = _context->transaction(); - RemoveMarker marker(collection->databaseId(), collection->id(), transaction->idForMarker(), key); - - LogfileManager* logfileManager = _context->logfileManager(); - - int res = logfileManager->allocateAndWrite(marker.buffer, - marker.size, - waitForSync); - - // TODO: remove from indexes - - return res; -} - -// ----------------------------------------------------------------------------- -// --SECTION-- private methods -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief set the unit of work to done -//////////////////////////////////////////////////////////////////////////////// - -void WorkUnit::done () { - if (! _done) { - for (auto& it : _collections) { - it.second->done(); - } - - _context->endWorkUnit(this); - _done = true; - } - - cleanup(); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief cleanup the unit of work -//////////////////////////////////////////////////////////////////////////////// - -void WorkUnit::cleanup () { - for (auto it = _collections.begin(); it != _collections.end(); ++it) { - Collection* collection = (*it).second; - delete collection; - } - - _collections.clear(); -} - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/WorkUnit.h b/arangod/Transaction/WorkUnit.h deleted file mode 100644 index 3ac2a4401b..0000000000 --- a/arangod/Transaction/WorkUnit.h +++ /dev/null @@ -1,251 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction unit of work -/// -/// @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_WORK_UNIT_H -#define ARANGODB_TRANSACTION_WORK_UNIT_H 1 - -#include "Basics/Common.h" -#include "Basics/BsonHelper.h" -#include "Transaction/Collection.h" -#include "Transaction/State.h" -#include "Transaction/Transaction.h" - -namespace triagens { - namespace transaction { - - class Context; - -// ----------------------------------------------------------------------------- -// --SECTION-- class WorkUnit -// ----------------------------------------------------------------------------- - - class WorkUnit : public State { - -//////////////////////////////////////////////////////////////////////////////// -/// @brief Context -//////////////////////////////////////////////////////////////////////////////// - - private: - WorkUnit (WorkUnit const&); - WorkUnit& operator= (WorkUnit const&); - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief create a transaction work unit -//////////////////////////////////////////////////////////////////////////////// - - WorkUnit (Context*, - bool); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief destroy a transaction work unit -//////////////////////////////////////////////////////////////////////////////// - - ~WorkUnit (); - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief id of the work unit -//////////////////////////////////////////////////////////////////////////////// - - inline uint64_t id () const { - return _id; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not the unit contains just a single operation -//////////////////////////////////////////////////////////////////////////////// - - inline bool isSingleOperation () const { - return _singleOperation; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief add a collection to the unit, assert a specific collection type -//////////////////////////////////////////////////////////////////////////////// - - Collection* addCollection (std::string const&, - Collection::AccessType, - TRI_col_type_e, - bool = true, - bool = false); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief add a collection to the unit -//////////////////////////////////////////////////////////////////////////////// - - Collection* addCollection (std::string const&, - Collection::AccessType, - bool = true, - bool = false); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief add a collection to the unit -//////////////////////////////////////////////////////////////////////////////// - - Collection* addCollection (TRI_voc_cid_t, - TRI_vocbase_col_t*, - Collection::AccessType, - bool = true, - bool = false); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief find a collection in a unit of work -//////////////////////////////////////////////////////////////////////////////// - - Collection* findCollection (TRI_voc_cid_t) const; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief begin a unit of work -//////////////////////////////////////////////////////////////////////////////// - - int begin (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief commit a unit of work -//////////////////////////////////////////////////////////////////////////////// - - int commit (bool = false); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief rollback a unit of work -//////////////////////////////////////////////////////////////////////////////// - - int rollback (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief save a single document -//////////////////////////////////////////////////////////////////////////////// - - int saveDocument (Collection*, - triagens::basics::Bson&, - bool); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief delete a single document -//////////////////////////////////////////////////////////////////////////////// - - int deleteDocument (Collection*, - std::string const&, - bool); - -// ----------------------------------------------------------------------------- -// --SECTION-- private methods -// ----------------------------------------------------------------------------- - - private: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not we are on the top level -//////////////////////////////////////////////////////////////////////////////// - -// TODO: remove - inline bool isTopLevel () const { - return _level == 0; - } - -//////////////////////////////////////////////////////////////////////////////// -/// @brief set the unit of work to done -//////////////////////////////////////////////////////////////////////////////// - - void done (); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief cleanup the unit of work -//////////////////////////////////////////////////////////////////////////////// - - void cleanup (); - -// ----------------------------------------------------------------------------- -// --SECTION-- private variables -// ----------------------------------------------------------------------------- - - private: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the transaction context -//////////////////////////////////////////////////////////////////////////////// - - Context* _context; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the participating collections -//////////////////////////////////////////////////////////////////////////////// - - std::map _collections; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the work unit id inside the current context -//////////////////////////////////////////////////////////////////////////////// - - uint64_t const _id; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief the current level we are in -//////////////////////////////////////////////////////////////////////////////// - - int const _level; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not the unit will contain just a single operation -//////////////////////////////////////////////////////////////////////////////// - - bool const _singleOperation; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not the work unit was done -//////////////////////////////////////////////////////////////////////////////// - - bool _done; - - }; - - } -} - -#endif - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Transaction/transactions.h b/arangod/Transaction/transactions.h deleted file mode 100644 index b976b8642f..0000000000 --- a/arangod/Transaction/transactions.h +++ /dev/null @@ -1,78 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief transaction macros -/// -/// @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_TRANSACTIONS_H -#define ARANGODB_TRANSACTION_TRANSACTIONS_H 1 - -#include "Basics/Common.h" -#include "BasicsC/logging.h" -#include "Transaction/Context.h" -#include "Transaction/Helper.h" -#include "Transaction/Manager.h" -#include "Transaction/Transaction.h" -#include "Transaction/WorkUnit.h" -#include "Utils/Exception.h" -#include "Wal/LogfileManager.h" - -//////////////////////////////////////////////////////////////////////////////// -/// @brief try block for a transaction -//////////////////////////////////////////////////////////////////////////////// - -#define TRANSACTION_TRY(vocbase, context, globalContext) \ - try { \ - triagens::transaction::Manager* manager = new triagens::transaction::Manager(); \ - triagens::transaction::Context* context = triagens::transaction::Context::getContext(manager, triagens::wal::LogfileManager::instance(), vocbase, globalContext); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief catch block for a transaction -//////////////////////////////////////////////////////////////////////////////// - -#define TRANSACTION_CATCH(ex) \ - } \ - catch (triagens::arango::Exception const &ex) { \ - LOG_INFO("transaction exception: %s", ex.what()); \ - - -//////////////////////////////////////////////////////////////////////////////// -/// @brief final block for a transaction -//////////////////////////////////////////////////////////////////////////////// - -#define TRANSACTION_FINALLY \ - } - -#endif - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/arangod/Wal/CollectorThread.h b/arangod/Wal/CollectorThread.h index 094ef94ba9..d63d5eaa4b 100644 --- a/arangod/Wal/CollectorThread.h +++ b/arangod/Wal/CollectorThread.h @@ -290,12 +290,6 @@ namespace triagens { bool processQueuedOperations (); -//////////////////////////////////////////////////////////////////////////////// -/// @brief step 3: perform removal of a logfile (if any) -//////////////////////////////////////////////////////////////////////////////// - - bool removeLogfiles (); - //////////////////////////////////////////////////////////////////////////////// /// @brief process all operations for a single collection ////////////////////////////////////////////////////////////////////////////////