From 8da51546c827bcb18617406fdd6294810c4d28b0 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Fri, 21 Mar 2014 14:53:42 +0100 Subject: [PATCH 1/5] little refactoring --- arangod/CMakeLists.txt | 1 + arangod/Makefile.files | 1 + arangod/Wal/CollectorThread.cpp | 2 - arangod/Wal/Configuration.cpp | 2 +- arangod/Wal/Logfile.cpp | 75 +++++++++++-- arangod/Wal/Logfile.h | 60 ++++++++--- arangod/Wal/LogfileManager.cpp | 88 ++++++++-------- arangod/Wal/LogfileManager.h | 11 +- arangod/Wal/Slot.cpp | 120 +++++++++++++++++++++ arangod/Wal/Slot.h | 181 ++++++++++++++++++++++---------- arangod/Wal/Slots.cpp | 21 ++-- arangod/Wal/Slots.h | 27 ++++- 12 files changed, 448 insertions(+), 141 deletions(-) create mode 100644 arangod/Wal/Slot.cpp diff --git a/arangod/CMakeLists.txt b/arangod/CMakeLists.txt index 4fce26b298..822da7bdd6 100644 --- a/arangod/CMakeLists.txt +++ b/arangod/CMakeLists.txt @@ -152,6 +152,7 @@ add_executable( Wal/Configuration.cpp Wal/LogfileManager.cpp Wal/Logfile.cpp + Wal/Slot.cpp Wal/Slots.cpp Wal/SynchroniserThread.cpp ${ARANGOD_MRUBY_SOURCE} diff --git a/arangod/Makefile.files b/arangod/Makefile.files index 1ec68314c0..d02d473a15 100644 --- a/arangod/Makefile.files +++ b/arangod/Makefile.files @@ -118,6 +118,7 @@ bin_arangod_SOURCES = \ arangod/Wal/Configuration.cpp \ arangod/Wal/LogfileManager.cpp \ arangod/Wal/Logfile.cpp \ + arangod/Wal/Slot.cpp \ arangod/Wal/Slots.cpp \ arangod/Wal/SynchroniserThread.cpp diff --git a/arangod/Wal/CollectorThread.cpp b/arangod/Wal/CollectorThread.cpp index 8a805cab22..f0af34a404 100644 --- a/arangod/Wal/CollectorThread.cpp +++ b/arangod/Wal/CollectorThread.cpp @@ -88,8 +88,6 @@ void CollectorThread::stop () { void CollectorThread::run () { while (_stop == 0) { - LOG_INFO("hello from collector thread"); - Logfile* logfile = _logfileManager->getCollectableLogfile(); if (logfile != nullptr) { diff --git a/arangod/Wal/Configuration.cpp b/arangod/Wal/Configuration.cpp index 27c4697984..5db4af7628 100644 --- a/arangod/Wal/Configuration.cpp +++ b/arangod/Wal/Configuration.cpp @@ -130,7 +130,7 @@ if (i % 500000 == 0) { LOG_INFO("now at: %d", (int) i); } memcpy(static_cast(p) + sizeof(TRI_df_marker_t), "the fox is brown\0", strlen("the fox is brown") + 1); - _logfileManager->allocateAndWrite(p, static_cast(64), (int) i); + _logfileManager->allocateAndWrite(p, static_cast(64)); TRI_Free(TRI_UNKNOWN_MEM_ZONE, p); } diff --git a/arangod/Wal/Logfile.cpp b/arangod/Wal/Logfile.cpp index 1791c356b0..295420f57c 100644 --- a/arangod/Wal/Logfile.cpp +++ b/arangod/Wal/Logfile.cpp @@ -37,10 +37,12 @@ using namespace triagens::wal; /// @brief create the logfile //////////////////////////////////////////////////////////////////////////////// -Logfile::Logfile (TRI_datafile_t* df) +Logfile::Logfile (TRI_datafile_t* df, + SealStatusType sealStatus, + CollectionStatusType collectionStatus) : _df(df), - _sealRequested(false), - _collectionStatus(CollectionStatusType::UNCOLLECTED) { + _sealStatus(sealStatus), + _collectionStatus(collectionStatus) { } //////////////////////////////////////////////////////////////////////////////// @@ -48,22 +50,79 @@ Logfile::Logfile (TRI_datafile_t* df) //////////////////////////////////////////////////////////////////////////////// Logfile::~Logfile () { - if (_df != nullptr) { - TRI_CloseDatafile(_df); - } + this->close(); } // ----------------------------------------------------------------------------- // --SECTION-- public methods // ----------------------------------------------------------------------------- +//////////////////////////////////////////////////////////////////////////////// +/// @brief create a new logfile +//////////////////////////////////////////////////////////////////////////////// + +Logfile* Logfile::create (std::string const& filename, + Logfile::IdType id, + uint32_t size) { + TRI_datafile_t* df = TRI_CreateDatafile(filename.c_str(), id, static_cast(size)); + + if (df == nullptr) { + int res = TRI_errno(); + + if (res != TRI_ERROR_NO_ERROR) { + LOG_ERROR("unable to create logfile '%s': %s", + filename.c_str(), + TRI_errno_string(res)); + return nullptr; + } + } + + Logfile* logfile = new Logfile(df, SealStatusType::UNKNOWN, CollectionStatusType::UNCOLLECTED); + return logfile; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief open an existing logfile +//////////////////////////////////////////////////////////////////////////////// + +Logfile* Logfile::open (std::string const& filename) { + TRI_datafile_t* df = TRI_OpenDatafile(filename.c_str()); + + if (df == nullptr) { + int res = TRI_errno(); + + if (res != TRI_ERROR_NO_ERROR) { + LOG_ERROR("unable to open logfile '%s': %s", + filename.c_str(), + TRI_errno_string(res)); + return nullptr; + } + } + + Logfile* logfile = new Logfile(df, SealStatusType::UNKNOWN, CollectionStatusType::UNCOLLECTED); + return logfile; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief close a logfile +//////////////////////////////////////////////////////////////////////////////// + +void Logfile::close () { + if (_df != nullptr) { + TRI_CloseDatafile(_df); + _df = nullptr; + } +} + //////////////////////////////////////////////////////////////////////////////// /// @brief seal a logfile //////////////////////////////////////////////////////////////////////////////// void Logfile::seal () { - LOG_INFO("sealing logfile %llu", (unsigned long long) id()); - _sealRequested = true; + LOG_INFO("sealing logfile %llu", + (unsigned long long) id()); + assert(_sealStatus == SealStatusType::UNSEALED); + _sealStatus = SealStatusType::REQUESTED; } // Local Variables: diff --git a/arangod/Wal/Logfile.h b/arangod/Wal/Logfile.h index 623793a107..e0263d09bb 100644 --- a/arangod/Wal/Logfile.h +++ b/arangod/Wal/Logfile.h @@ -53,11 +53,22 @@ namespace triagens { typedef TRI_voc_fid_t IdType; +//////////////////////////////////////////////////////////////////////////////// +/// @brief logfile seal status +//////////////////////////////////////////////////////////////////////////////// + + enum class SealStatusType : uint32_t { + UNKNOWN, + UNSEALED, + REQUESTED, + SEALED + }; + //////////////////////////////////////////////////////////////////////////////// /// @brief logfile collection status //////////////////////////////////////////////////////////////////////////////// - enum class CollectionStatusType { + enum class CollectionStatusType : uint32_t { UNCOLLECTED, REQUESTED, DONE @@ -82,7 +93,9 @@ namespace triagens { /// @brief create a logfile //////////////////////////////////////////////////////////////////////////////// - Logfile (TRI_datafile_t*); + Logfile (TRI_datafile_t*, + SealStatusType, + CollectionStatusType); //////////////////////////////////////////////////////////////////////////////// /// @brief destroy a logfile @@ -94,11 +107,31 @@ namespace triagens { // --SECTION-- public methods // ----------------------------------------------------------------------------- +//////////////////////////////////////////////////////////////////////////////// +/// @brief create a new logfile +//////////////////////////////////////////////////////////////////////////////// + + static Logfile* create (std::string const&, + Logfile::IdType, + uint32_t); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief open an existing logfile +//////////////////////////////////////////////////////////////////////////////// + + static Logfile* open (std::string const&); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief close a logfile +//////////////////////////////////////////////////////////////////////////////// + + void close (); + //////////////////////////////////////////////////////////////////////////////// /// @brief return the datafile pointer //////////////////////////////////////////////////////////////////////////////// - TRI_datafile_t* df () { + inline TRI_datafile_t* df () const { return _df; } @@ -106,7 +139,7 @@ namespace triagens { /// @brief return the logfile id //////////////////////////////////////////////////////////////////////////////// - Logfile::IdType id () const { + inline Logfile::IdType id () const { return _df->_fid; } @@ -114,7 +147,7 @@ namespace triagens { /// @brief return the allocated size of the logfile //////////////////////////////////////////////////////////////////////////////// - uint64_t allocatedSize () const { + inline uint64_t allocatedSize () const { return static_cast(_df->_maximalSize); } @@ -123,7 +156,7 @@ namespace triagens { //////////////////////////////////////////////////////////////////////////////// uint64_t freeSize () const { - if (_df->_isSealed) { + if (isSealed()) { return 0; } @@ -150,17 +183,16 @@ namespace triagens { /// @brief whether or not the logfile is sealed //////////////////////////////////////////////////////////////////////////////// - bool isSealed () const { - // TODO: introduce a logfile status instead of this boolean - return _sealRequested; + inline bool isSealed () const { + return (_sealStatus == SealStatusType::SEALED); } //////////////////////////////////////////////////////////////////////////////// /// @brief whether or not the logfile can be collected //////////////////////////////////////////////////////////////////////////////// - bool canCollect () const { - return isSealed() && (_collectionStatus == CollectionStatusType::UNCOLLECTED); + inline bool canCollect () const { + return (isSealed() && (_collectionStatus == CollectionStatusType::UNCOLLECTED)); } //////////////////////////////////////////////////////////////////////////////// @@ -198,10 +230,10 @@ namespace triagens { TRI_datafile_t* _df; //////////////////////////////////////////////////////////////////////////////// -/// @brief whether or not a seal was requested +/// @brief logfile seal status //////////////////////////////////////////////////////////////////////////////// - - bool _sealRequested; + + SealStatusType _sealStatus; //////////////////////////////////////////////////////////////////////////////// /// @brief logfile collection status diff --git a/arangod/Wal/LogfileManager.cpp b/arangod/Wal/LogfileManager.cpp index f102a10701..b83a924d76 100644 --- a/arangod/Wal/LogfileManager.cpp +++ b/arangod/Wal/LogfileManager.cpp @@ -65,7 +65,7 @@ LogfileManager::LogfileManager (Configuration* configuration) _maxEntrySize(configuration->maxEntrySize()), _directory(configuration->directory()), _regex(), - _shutdown(false) { + _shutdown(0) { LOG_INFO("creating wal logfile manager"); @@ -142,15 +142,22 @@ int LogfileManager::startup () { res = readShutdownInfo(); if (res != TRI_ERROR_NO_ERROR) { - LOG_ERROR("could not open shutdown file '%s': %s", shutdownFile.c_str(), TRI_errno_string(res)); + LOG_ERROR("could not open shutdown file '%s': %s", + shutdownFile.c_str(), + TRI_errno_string(res)); return res; } + + LOG_INFO("last tick: %llu, last collected: %llu", + (unsigned long long) _slots->lastTick(), + (unsigned long long) _lastCollectedId); } res = openLogfiles(); if (res != TRI_ERROR_NO_ERROR) { - LOG_ERROR("could not open wal logfiles: %s", TRI_errno_string(res)); + LOG_ERROR("could not open wal logfiles: %s", + TRI_errno_string(res)); return res; } @@ -193,11 +200,11 @@ int LogfileManager::startup () { //////////////////////////////////////////////////////////////////////////////// void LogfileManager::shutdown () { - if (_shutdown) { + if (_shutdown > 0) { return; } - _shutdown = true; + _shutdown = 1; LOG_INFO("stopping collector thread"); // stop threads @@ -234,25 +241,21 @@ void LogfileManager::signalSync () { /// @brief allocate space in a logfile for later writing //////////////////////////////////////////////////////////////////////////////// -Slot* LogfileManager::allocate (uint32_t size, int ctx) { - /* +SlotInfo LogfileManager::allocate (uint32_t size) { if (size > _maxEntrySize) { // entry is too big - return LogEntry(TRI_ERROR_ARANGO_DOCUMENT_TOO_LARGE); + return SlotInfo(TRI_ERROR_ARANGO_DOCUMENT_TOO_LARGE); } - */ - return _slots->nextUnused(size, ctx); + return _slots->nextUnused(size); } //////////////////////////////////////////////////////////////////////////////// /// @brief finalise a log entry //////////////////////////////////////////////////////////////////////////////// -int LogfileManager::finalise (Slot* slot) { - _slots->returnUsed(slot); - - return TRI_ERROR_NO_ERROR; +void LogfileManager::finalise (SlotInfo& slotInfo) { + _slots->returnUsed(slotInfo); } //////////////////////////////////////////////////////////////////////////////// @@ -261,22 +264,20 @@ int LogfileManager::finalise (Slot* slot) { //////////////////////////////////////////////////////////////////////////////// int LogfileManager::allocateAndWrite (void* mem, - uint32_t size, - int ctx) { + uint32_t size) { - Slot* slot = allocate(size, ctx); + SlotInfo slotInfo = allocate(size); - if (slot == nullptr) { - // TODO: return "real" error code - LOG_ERROR("no free slot!"); - assert(false); - return TRI_ERROR_OUT_OF_MEMORY; + if (slotInfo.errorCode != TRI_ERROR_NO_ERROR) { + return slotInfo.errorCode; } + + assert(slotInfo.slot != nullptr); - TRI_df_marker_t* marker = static_cast(slot->mem()); + TRI_df_marker_t* marker = static_cast(slotInfo.slot->mem()); // write tick into marker - marker->_tick = slot->tick(); + marker->_tick = slotInfo.slot->tick(); // set initial crc to 0 marker->_crc = 0; @@ -286,9 +287,10 @@ int LogfileManager::allocateAndWrite (void* mem, crc = TRI_BlockCrc32(crc, static_cast(mem), static_cast(size)); marker->_crc = TRI_FinalCrc32(crc); - memcpy(slot->mem(), mem, static_cast(size)); + memcpy(slotInfo.slot->mem(), mem, static_cast(size)); - return finalise(slot); + finalise(slotInfo); + return slotInfo.errorCode; } //////////////////////////////////////////////////////////////////////////////// @@ -298,10 +300,10 @@ int LogfileManager::allocateAndWrite (void* mem, int LogfileManager::sealLogfile (Logfile* logfile) { assert(logfile != nullptr); - LOG_INFO("sealing logfile"); - - WRITE_LOCKER(_logfilesLock); - logfile->seal(); + { + WRITE_LOCKER(_logfilesLock); + logfile->seal(); + } return TRI_ERROR_NO_ERROR; } @@ -616,25 +618,21 @@ int LogfileManager::inventory () { int LogfileManager::openLogfiles () { WRITE_LOCKER(_logfilesLock); - for (auto it = _logfiles.begin(); it != _logfiles.end(); ++it) { + for (auto it = _logfiles.begin(); it != _logfiles.end(); ) { Logfile::IdType const id = (*it).first; std::string const filename = logfileName(id); assert((*it).second == nullptr); - TRI_datafile_t* df = TRI_OpenDatafile(filename.c_str()); + Logfile* logfile = Logfile::open(filename); - if (df == nullptr) { - int res = TRI_errno(); - - if (res != TRI_ERROR_NO_ERROR) { - LOG_ERROR("unable to open logfile '%s': %s", filename.c_str(), TRI_errno_string(res)); - return res; - } + if (logfile == nullptr) { + _logfiles.erase(it++); + } + else { + (*it).second = Logfile::open(filename); + ++it; } - - // TODO: the last logfile is probably still a journal. must fix the "false" value - (*it).second = new Logfile(df); } return TRI_ERROR_NO_ERROR; @@ -648,9 +646,9 @@ int LogfileManager::allocateDatafile () { Logfile::IdType const id = nextId(); std::string const filename = logfileName(id); - TRI_datafile_t* df = TRI_CreateDatafile(filename.c_str(), id, static_cast(_configuration->filesize())); + Logfile* logfile = Logfile::create(filename.c_str(), id, _configuration->filesize()); - if (df == nullptr) { + if (logfile == nullptr) { int res = TRI_errno(); LOG_ERROR("unable to create datafile: %s", TRI_errno_string(res)); @@ -658,7 +656,7 @@ int LogfileManager::allocateDatafile () { } WRITE_LOCKER(_logfilesLock); - _logfiles.insert(make_pair(id, new Logfile(df))); + _logfiles.insert(make_pair(id, logfile)); return TRI_ERROR_NO_ERROR; } diff --git a/arangod/Wal/LogfileManager.h b/arangod/Wal/LogfileManager.h index 772b5b4ed4..5d9d8cd349 100644 --- a/arangod/Wal/LogfileManager.h +++ b/arangod/Wal/LogfileManager.h @@ -32,6 +32,7 @@ #include "Basics/Mutex.h" #include "Basics/ReadWriteLock.h" #include "Wal/Logfile.h" +#include "Wal/Slots.h" #include @@ -42,7 +43,6 @@ namespace triagens { class CollectorThread; class Configuration; class Slot; - class Slots; class SynchroniserThread; // ----------------------------------------------------------------------------- @@ -122,13 +122,13 @@ namespace triagens { /// @brief reserve space in a logfile //////////////////////////////////////////////////////////////////////////////// - Slot* allocate (uint32_t, int); + SlotInfo allocate (uint32_t); //////////////////////////////////////////////////////////////////////////////// /// @brief finalise a log entry //////////////////////////////////////////////////////////////////////////////// - int finalise (Slot*); + void finalise (SlotInfo&); //////////////////////////////////////////////////////////////////////////////// /// @brief write data into the logfile @@ -136,8 +136,7 @@ namespace triagens { //////////////////////////////////////////////////////////////////////////////// int allocateAndWrite (void*, - uint32_t, - int); + uint32_t); //////////////////////////////////////////////////////////////////////////////// /// @brief seal a logfile @@ -361,7 +360,7 @@ namespace triagens { /// @brief whether or not we have been shutdown already //////////////////////////////////////////////////////////////////////////////// - bool _shutdown; + volatile sig_atomic_t _shutdown; }; diff --git a/arangod/Wal/Slot.cpp b/arangod/Wal/Slot.cpp new file mode 100644 index 0000000000..b7eddac11b --- /dev/null +++ b/arangod/Wal/Slot.cpp @@ -0,0 +1,120 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log slot +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2004-2013 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 triAGENS GmbH, Cologne, Germany +/// +/// @author Jan Steemann +/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +#include "Wal/Slot.h" + +using namespace triagens::wal; + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create a slot +//////////////////////////////////////////////////////////////////////////////// + +Slot::Slot () + : _tick(0), + _logfileId(0), + _mem(nullptr), + _size(0), + _status(StatusType::UNUSED) { + +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy a slot +//////////////////////////////////////////////////////////////////////////////// + +Slot::~Slot () { +} + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return the slot status as a string +//////////////////////////////////////////////////////////////////////////////// + +std::string Slot::statusText () const { + switch (_status) { + case StatusType::UNUSED: + return "unused"; + case StatusType::USED: + return "used"; + case StatusType::RETURNED: + return "returned"; + } +} + +// ----------------------------------------------------------------------------- +// --SECTION-- private methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief mark as slot as used +//////////////////////////////////////////////////////////////////////////////// + +void Slot::setUnused () { + assert(isReturned()); + _tick = 0; + _logfileId = 0; + _mem = nullptr; + _size = 0; + _status = StatusType::UNUSED; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief mark as slot as used +//////////////////////////////////////////////////////////////////////////////// + +void Slot::setUsed (void* mem, + uint32_t size, + Logfile::IdType logfileId, + Slot::TickType tick) { + assert(isUnused()); + _tick = tick; + _logfileId = logfileId; + _mem = mem; + _size = size; + _status = StatusType::USED; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief mark as slot as returned +//////////////////////////////////////////////////////////////////////////////// + +void Slot::setReturned () { + assert(isUsed()); + _status = StatusType::RETURNED; +} + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/Slot.h b/arangod/Wal/Slot.h index 54ad81acd8..73809e019c 100644 --- a/arangod/Wal/Slot.h +++ b/arangod/Wal/Slot.h @@ -33,114 +33,187 @@ namespace triagens { namespace wal { + class Slots; +// ----------------------------------------------------------------------------- +// --SECTION-- class Slot +// ----------------------------------------------------------------------------- + class Slot { friend class Slots; +// ----------------------------------------------------------------------------- +// --SECTION-- typedefs +// ----------------------------------------------------------------------------- + public: +//////////////////////////////////////////////////////////////////////////////// +/// @brief tick typedef +//////////////////////////////////////////////////////////////////////////////// + typedef TRI_voc_tick_t TickType; - public: +//////////////////////////////////////////////////////////////////////////////// +/// @brief slot status typedef +//////////////////////////////////////////////////////////////////////////////// - enum class StatusType { + enum class StatusType : uint32_t { UNUSED = 0, USED = 1, RETURNED = 2 }; - private: - Slot (size_t slotIndex) - : _status(StatusType::UNUSED), - _tick(0), - _logfileId(0), - _mem(nullptr), - _size(0) { - } +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- - ~Slot () { - } +//////////////////////////////////////////////////////////////////////////////// +/// @brief create a slot +//////////////////////////////////////////////////////////////////////////////// + + private: + + Slot (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy a slot +//////////////////////////////////////////////////////////////////////////////// + + ~Slot (); + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- public: - std::string statusText () const { - switch (_status) { - case StatusType::UNUSED: - return "unused"; - case StatusType::USED: - return "used"; - case StatusType::RETURNED: - return "returned"; - } - } +//////////////////////////////////////////////////////////////////////////////// +/// @brief return the tick assigned to the slot +//////////////////////////////////////////////////////////////////////////////// - Slot::TickType tick () const { + inline Slot::TickType tick () const { return _tick; } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return the logfile id assigned to the slot +//////////////////////////////////////////////////////////////////////////////// - Logfile::IdType logfileId () const { + inline Logfile::IdType logfileId () const { return _logfileId; } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return the raw memory pointer assigned to the slot +//////////////////////////////////////////////////////////////////////////////// - void* mem () const { + inline void* mem () const { return _mem; } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return the memory size assigned to the slot +//////////////////////////////////////////////////////////////////////////////// - uint32_t size () const { + inline uint32_t size () const { return _size; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief return the slot status as a string +//////////////////////////////////////////////////////////////////////////////// + + std::string statusText () const; + +// ----------------------------------------------------------------------------- +// --SECTION-- private methods +// ----------------------------------------------------------------------------- + private: - bool isUnused () const { + +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not the slot is unused +//////////////////////////////////////////////////////////////////////////////// + + inline bool isUnused () const { return _status == StatusType::UNUSED; } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not the slot is used +//////////////////////////////////////////////////////////////////////////////// - bool isUsed () const { + inline bool isUsed () const { return _status == StatusType::USED; } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not the slot is returned +//////////////////////////////////////////////////////////////////////////////// - bool isReturned () const { + inline bool isReturned () const { return _status == StatusType::RETURNED; } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief mark as slot as unused +//////////////////////////////////////////////////////////////////////////////// - void setUnused () { - assert(isReturned()); - _status = StatusType::UNUSED; - _tick = 0; - _logfileId = 0; - _mem = nullptr; - _size = 0; - } + void setUnused (); - void setUsed (void* mem, - uint32_t size, - Logfile::IdType logfileId, - Slot::TickType tick) { - assert(isUnused()); - _status = StatusType::USED; - _tick = tick; - _logfileId = logfileId; - _mem = mem; - _size = size; - } +//////////////////////////////////////////////////////////////////////////////// +/// @brief mark as slot as used +//////////////////////////////////////////////////////////////////////////////// - void setReturned () { - assert(isUsed()); - _status = StatusType::RETURNED; - } + void setUsed (void*, + uint32_t, + Logfile::IdType, + Slot::TickType); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief mark as slot as returned +//////////////////////////////////////////////////////////////////////////////// + + void setReturned (); + +// ----------------------------------------------------------------------------- +// --SECTION-- private variables +// ----------------------------------------------------------------------------- private: - - StatusType _status; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief slot tick +//////////////////////////////////////////////////////////////////////////////// Slot::TickType _tick; +//////////////////////////////////////////////////////////////////////////////// +/// @brief slot logfile id +//////////////////////////////////////////////////////////////////////////////// + Logfile::IdType _logfileId; +//////////////////////////////////////////////////////////////////////////////// +/// @brief slot raw memory pointer +//////////////////////////////////////////////////////////////////////////////// + void* _mem; +//////////////////////////////////////////////////////////////////////////////// +/// @brief slot raw memory size +//////////////////////////////////////////////////////////////////////////////// + uint32_t _size; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief slot status +//////////////////////////////////////////////////////////////////////////////// + + StatusType _status; + }; } diff --git a/arangod/Wal/Slots.cpp b/arangod/Wal/Slots.cpp index 763609f1ac..760d2cf767 100644 --- a/arangod/Wal/Slots.cpp +++ b/arangod/Wal/Slots.cpp @@ -58,7 +58,7 @@ Slots::Slots (LogfileManager* logfileManager, _readOnly(false) { for (size_t i = 0; i < _numberOfSlots; ++i) { - _slots[i] = new Slot(i); + _slots[i] = new Slot(); } } @@ -106,7 +106,7 @@ Slot::TickType Slots::lastTick () { /// @brief return the next unused slot //////////////////////////////////////////////////////////////////////////////// -Slot* Slots::nextUnused (uint32_t size, int ctx) { +SlotInfo Slots::nextUnused (uint32_t size) { // we need to use the aligned size for writing size = TRI_DF_ALIGN_BLOCK(size); @@ -117,7 +117,7 @@ Slot* Slots::nextUnused (uint32_t size, int ctx) { MUTEX_LOCKER(_lock); if (_readOnly) { - return nullptr; + return SlotInfo(TRI_ERROR_ARANGO_READ_ONLY); } Slot* slot = _slots[_handoutIndex]; @@ -155,12 +155,15 @@ Slot* Slots::nextUnused (uint32_t size, int ctx) { TRI_df_marker_t* mem; int res = TRI_ReserveElementDatafile(_logfile->df(), static_cast(size), &mem, 32 * 1024 * 1024); - if (res != TRI_ERROR_NO_ERROR || mem == nullptr) { - return nullptr; + if (res != TRI_ERROR_NO_ERROR) { + return SlotInfo(res); } + + assert(mem != nullptr); assert(_freeSlots > 0); _freeSlots--; + slot->setUsed(static_cast(mem), size, _logfile->id(), ++_lastTick); if (++_handoutIndex ==_numberOfSlots) { @@ -168,7 +171,7 @@ Slot* Slots::nextUnused (uint32_t size, int ctx) { _handoutIndex = 0; } - return slot; + return SlotInfo(slot); } } @@ -195,12 +198,12 @@ Slot* Slots::nextUnused (uint32_t size, int ctx) { /// @brief return a used slot, allowing its synchronisation //////////////////////////////////////////////////////////////////////////////// -void Slots::returnUsed (Slot* slot) { - assert(slot != nullptr); +void Slots::returnUsed (SlotInfo& slotInfo) { + assert(slotInfo.slot != nullptr); { MUTEX_LOCKER(_lock); - slot->setReturned(); + slotInfo.slot->setReturned(); } _logfileManager->signalSync(); diff --git a/arangod/Wal/Slots.h b/arangod/Wal/Slots.h index 0cdca98a2e..c682a8653f 100644 --- a/arangod/Wal/Slots.h +++ b/arangod/Wal/Slots.h @@ -40,6 +40,29 @@ namespace triagens { class LogfileManager; +// ----------------------------------------------------------------------------- +// --SECTION-- struct SlotInfo +// ----------------------------------------------------------------------------- + + struct SlotInfo { + explicit SlotInfo (int errorCode) + : slot(nullptr), + errorCode(errorCode) { + } + + explicit SlotInfo (Slot* slot) + : slot(slot), + errorCode(TRI_ERROR_NO_ERROR) { + } + + SlotInfo () + : SlotInfo(TRI_ERROR_NO_ERROR) { + } + + Slot* slot; + int errorCode; + }; + // ----------------------------------------------------------------------------- // --SECTION-- class Slots // ----------------------------------------------------------------------------- @@ -96,13 +119,13 @@ namespace triagens { /// @brief return the next unused slot //////////////////////////////////////////////////////////////////////////////// - Slot* nextUnused (uint32_t, int); + SlotInfo nextUnused (uint32_t); //////////////////////////////////////////////////////////////////////////////// /// @brief return a used slot, allowing its synchronisation //////////////////////////////////////////////////////////////////////////////// - void returnUsed (Slot*); + void returnUsed (SlotInfo&); //////////////////////////////////////////////////////////////////////////////// /// @brief get the next synchronisable region From 03118a179c5953bb960362cbb5497851487ee125 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Fri, 21 Mar 2014 14:52:39 +0100 Subject: [PATCH 2/5] updated CHANGELOG --- CHANGELOG | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 759f41779e..42c6dba3d4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,13 @@ v2.1.0 (XXXX-XX-XX) ------------------- +* fixed V8 compile error on MacOS X + +* prevent `body length: -9223372036854775808` being logged in development mode for + some Foxx HTTP responses + +* fixed several bugs in web interface dashboard + * fixed issue #783: coffee script not working in manifest file * provide a size hint to indexes when initially filling them From 31a69dba6778c3bf7f29f728ba6725699c1cc46b Mon Sep 17 00:00:00 2001 From: Heiko Kernbach Date: Fri, 21 Mar 2014 15:09:18 +0100 Subject: [PATCH 3/5] dataTables css -> scss --- .../aardvark/frontend/css/datatables.css | 59 ----- .../aardvark/frontend/scss/_dataTables.scss | 59 ++++- .../aardvark/frontend/scss/generated.css | 203 ++++++++++-------- .../system/aardvark/frontend/scss/style.scss | 2 +- 4 files changed, 175 insertions(+), 148 deletions(-) diff --git a/js/apps/system/aardvark/frontend/css/datatables.css b/js/apps/system/aardvark/frontend/css/datatables.css index 6bbfd0f0de..e69de29bb2 100644 --- a/js/apps/system/aardvark/frontend/css/datatables.css +++ b/js/apps/system/aardvark/frontend/css/datatables.css @@ -1,59 +0,0 @@ -/* -#documentsTable thead { - border: 0 !important; -} -*/ - -#tableDiv table.dataTable td { - padding:12px 18px !important; -} - - -table.dataTable thead th { - border-bottom:none; - cursor: default !important; -} - -table.arangoDataTable.dataTable td { - padding:10px 18px; -} - -.arangoDataTable thead { - font-weight: 400 !important; - background-color: #FFFFFF !important; - text-align: left; -} - -.arangoDataTable { - width: 100% !important; - position: relative; - table-layout:fixed !important; - border-spacing:0 0px; -} - -.arangoDataTable.dataTable thead tr { - border-bottom: 1px solid #C2C2C2; -} - -table.arangoDataTable tr { - cursor: pointer; -} - -table.arangoDataTable.noPointer tr { - cursor: default; -} - -.arangoDataTable .key { - margin-top: 4px; -} - -/* Odd / Even coloring */ -.api-container ul#resources > li.resource:nth-child(even), -table.arangoDataTable tr.even { - background-color: #FFFFFF; -} - -.api-container ul#resources > li.resource:nth-child(odd), -table.arangoDataTable tr.odd { - background-color: #F1F0EE; -} diff --git a/js/apps/system/aardvark/frontend/scss/_dataTables.scss b/js/apps/system/aardvark/frontend/scss/_dataTables.scss index 34d4a93231..ee27061576 100644 --- a/js/apps/system/aardvark/frontend/scss/_dataTables.scss +++ b/js/apps/system/aardvark/frontend/scss/_dataTables.scss @@ -1,9 +1,62 @@ -table.dataTable thead th { - font-weight: 400 !important; - padding: 10px 14px; +.arangoDataTable { + width: 100% !important; + position: relative; + table-layout:fixed !important; + border-spacing:0 0px; + + thead { + background-color: #FFF !important; + font-weight: 400 !important; + text-align: left; + + th { + font-weight: 400 !important; + padding: 10px 14px !important; + border-bottom: none; + cursor: default !important; + } + + tr { + border-bottom: 1px solid #C2C2C2; + } + + } + + tr { + cursor: pointer; + } + + td { + padding: 10px 18px !important; + } + + .key { + margin-top: 4px; + } + + .dataTable { + .noPointer tr { + cursor: default; + } + } +} + +/* Odd / Even coloring */ +.api-container ul#resources > li.resource:nth-child(even), +table.arangoDataTable tr.even { + background-color: #FFF; +} + +.api-container ul#resources > li.resource:nth-child(odd), +table.arangoDataTable tr.odd { + background-color: #F1F0EE; } // TODO Hard cleanup +#tableDiv table.dataTable td { + padding:12px 18px !important; +} + #documentsTableID_length, #documentsTableID_filter { display: none; diff --git a/js/apps/system/aardvark/frontend/scss/generated.css b/js/apps/system/aardvark/frontend/scss/generated.css index e73904d702..127a04fdbc 100644 --- a/js/apps/system/aardvark/frontend/scss/generated.css +++ b/js/apps/system/aardvark/frontend/scss/generated.css @@ -1444,9 +1444,9 @@ nav.navbar, footer.footer { background-color: #f87c0f; } .button-inactive { - background-color: lightgrey; } + background-color: lightgray; } .button-inactive:hover { - background-color: grey; } + background-color: gray; } ul.link-dropdown-menu, ul.user-dropdown-menu, ul.gv-dropdown-menu { -moz-border-radius: 3px; @@ -2454,6 +2454,84 @@ div.breadcrumb a.disabledBread { .css-label-round { background-image: url("../img/dark-check-green-round.png"); } +.modal-body { + color: #736b68; + font-size: 14px; } + .modal-body th th.actionCell, .modal-body th th.keyCell, .modal-body th .valueCell { + text-align: center; } + .modal-body th.actionCell { + width: 30px; } + .modal-body th.keyCell { + width: 170px; } + .modal-body th.keyCell input { + width: 150px; } + .modal-body th .valueCell { + width: 300px; } + .modal-body th .valueCell input { + width: 290px; } + +.modal-backdrop, +.modal-backdrop.fade.in { + opacity: .4; } + +.modalChartDetail { + height: 70%; + margin-left: 0; + width: 70%; } + +.waitModal { + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + background: transparent; + border: 0; + color: white; } + +.collectionTh { + font-size: 14px; } + +.waitModalBackdrop { + opacity: .7 !important; } + +.addCollection table tr { + border-bottom: 0 !important; + height: 53px; } +.addCollection .icon_arangodb_info { + margin-left: 20px !important; + position: relative; + top: 2px !important; } +.addCollection .accordion { + margin-top: 10px; } +.addCollection .collectionThSec { + width: 320px !important; } +.addCollection .collectionTh { + width: 96px; } +.addCollection .modalInput { + width: 320px; } +.addCollection .modalSelect { + width: 334px; } +.addCollection .accordion-toggle { + width: 457px !important; } + +.modalTooltips span { + color: #736b68; + font-size: 20px; } + .modalTooltips span:hover { + color: black; } + +.change-collection .tab-content { + min-height: 230px; } + +.show-collection .tab-content { + min-height: 200px; } + +pre.gv-object-view { + text-align: left; + white-space: pre; } + +.capitalize { + text-transform: capitalize; } + .navlogo .stat_cpu { height: 26px; margin-top: 1px; @@ -2587,7 +2665,7 @@ div.breadcrumb a.disabledBread { width: 100%; } .user-menu-img { - background-color: lightgrey; + background-color: lightgray; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; @@ -2690,84 +2768,6 @@ div.breadcrumb a.disabledBread { height: 220px; width: 250px; } -.modal-body { - color: #736b68; - font-size: 14px; } - .modal-body th th.actionCell, .modal-body th th.keyCell, .modal-body th .valueCell { - text-align: center; } - .modal-body th.actionCell { - width: 30px; } - .modal-body th.keyCell { - width: 170px; } - .modal-body th.keyCell input { - width: 150px; } - .modal-body th .valueCell { - width: 300px; } - .modal-body th .valueCell input { - width: 290px; } - -.modal-backdrop, -.modal-backdrop.fade.in { - opacity: .4; } - -.modalChartDetail { - height: 70%; - margin-left: 0; - width: 70%; } - -.waitModal { - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - background: transparent; - border: 0; - color: white; } - -.collectionTh { - font-size: 14px; } - -.waitModalBackdrop { - opacity: .7 !important; } - -.addCollection table tr { - border-bottom: 0 !important; - height: 53px; } -.addCollection .icon_arangodb_info { - margin-left: 20px !important; - position: relative; - top: 2px !important; } -.addCollection .accordion { - margin-top: 10px; } -.addCollection .collectionThSec { - width: 320px !important; } -.addCollection .collectionTh { - width: 96px; } -.addCollection .modalInput { - width: 320px; } -.addCollection .modalSelect { - width: 334px; } -.addCollection .accordion-toggle { - width: 457px !important; } - -.modalTooltips span { - color: #736b68; - font-size: 20px; } - .modalTooltips span:hover { - color: black; } - -.change-collection .tab-content { - min-height: 230px; } - -.show-collection .tab-content { - min-height: 200px; } - -pre.gv-object-view { - text-align: left; - white-space: pre; } - -.capitalize { - text-transform: capitalize; } - .shortcuts { font-size: 11px; font-weight: 200; } @@ -3172,7 +3172,7 @@ pre.gv-object-view { color: #66ff00; } .jqconsole-cursor { - background-color: grey; } + background-color: gray; } .jqconsole-blurred .jqconsole-header .jqconsole-cursor { color: #c4cccc; } @@ -3429,9 +3429,42 @@ input.gv-radio-button { margin-top: 3px; width: auto; } -table.dataTable thead th { - font-weight: 400 !important; - padding: 10px 14px; } +.arangoDataTable { + width: 100% !important; + position: relative; + table-layout: fixed !important; + border-spacing: 0 0px; } + .arangoDataTable thead { + background-color: #FFF !important; + font-weight: 400 !important; + text-align: left; } + .arangoDataTable thead th { + font-weight: 400 !important; + padding: 10px 14px !important; + border-bottom: none; + cursor: default !important; } + .arangoDataTable thead tr { + border-bottom: 1px solid #C2C2C2; } + .arangoDataTable tr { + cursor: pointer; } + .arangoDataTable td { + padding: 10px 18px !important; } + .arangoDataTable .key { + margin-top: 4px; } + .arangoDataTable .dataTable .noPointer tr { + cursor: default; } + +/* Odd / Even coloring */ +.api-container ul#resources > li.resource:nth-child(even), +table.arangoDataTable tr.even { + background-color: #FFF; } + +.api-container ul#resources > li.resource:nth-child(odd), +table.arangoDataTable tr.odd { + background-color: #F1F0EE; } + +#tableDiv table.dataTable td { + padding: 12px 18px !important; } #documentsTableID_length, #documentsTableID_filter { diff --git a/js/apps/system/aardvark/frontend/scss/style.scss b/js/apps/system/aardvark/frontend/scss/style.scss index 7de0304fcb..afcc1a285d 100644 --- a/js/apps/system/aardvark/frontend/scss/style.scss +++ b/js/apps/system/aardvark/frontend/scss/style.scss @@ -54,7 +54,7 @@ // General Dialogs @import 'dialogs'; // Collections -@import 'collection'; +//@import 'collection'; // Data Tables, TODO: might all be superflous From c84d284a908b4ae8541689fbeffa8f8393ceeec4 Mon Sep 17 00:00:00 2001 From: Heiko Kernbach Date: Fri, 21 Mar 2014 15:09:42 +0100 Subject: [PATCH 4/5] cleanup css --- js/apps/system/aardvark/frontend/css/datatables.css | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 js/apps/system/aardvark/frontend/css/datatables.css diff --git a/js/apps/system/aardvark/frontend/css/datatables.css b/js/apps/system/aardvark/frontend/css/datatables.css deleted file mode 100644 index e69de29bb2..0000000000 From a409acd0135ac9f5d31850f9bd5b522fe7456259 Mon Sep 17 00:00:00 2001 From: Heiko Kernbach Date: Fri, 21 Mar 2014 15:17:25 +0100 Subject: [PATCH 5/5] dataTables scss lint --- .../aardvark/frontend/scss/_dataTables.scss | 30 +++++++++---------- .../aardvark/frontend/scss/generated.css | 23 +++++++------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/js/apps/system/aardvark/frontend/scss/_dataTables.scss b/js/apps/system/aardvark/frontend/scss/_dataTables.scss index ee27061576..b84b97b6c8 100644 --- a/js/apps/system/aardvark/frontend/scss/_dataTables.scss +++ b/js/apps/system/aardvark/frontend/scss/_dataTables.scss @@ -1,29 +1,29 @@ .arangoDataTable { - width: 100% !important; + border-spacing: 0 0; position: relative; - table-layout:fixed !important; - border-spacing:0 0px; + table-layout: fixed !important; + width: 100% !important; thead { - background-color: #FFF !important; + background-color: #fff !important; font-weight: 400 !important; text-align: left; th { + border-bottom: 0; + cursor: default !important; font-weight: 400 !important; padding: 10px 14px !important; - border-bottom: none; - cursor: default !important; } tr { - border-bottom: 1px solid #C2C2C2; + border-bottom: 1px solid #c2c2c2; } } tr { - cursor: pointer; + cursor: pointer; } td { @@ -41,20 +41,20 @@ } } -/* Odd / Even coloring */ -.api-container ul#resources > li.resource:nth-child(even), +// Odd / Even coloring +.api-container #resources > li.resource:nth-child(even), table.arangoDataTable tr.even { - background-color: #FFF; + background-color: #fff; } -.api-container ul#resources > li.resource:nth-child(odd), +.api-container #resources > li.resource:nth-child(odd), table.arangoDataTable tr.odd { - background-color: #F1F0EE; + background-color: #f1f0ee; } // TODO Hard cleanup #tableDiv table.dataTable td { - padding:12px 18px !important; + padding: 12px 18px !important; } #documentsTableID_length, @@ -100,7 +100,7 @@ table.arangoDataTable tr.odd { } .prettify { - border: 0 !important; + border: none !important; font-size: 1em !important; margin: 0 !important; padding: 0 !important; diff --git a/js/apps/system/aardvark/frontend/scss/generated.css b/js/apps/system/aardvark/frontend/scss/generated.css index 127a04fdbc..a6896fe9c6 100644 --- a/js/apps/system/aardvark/frontend/scss/generated.css +++ b/js/apps/system/aardvark/frontend/scss/generated.css @@ -3430,21 +3430,21 @@ input.gv-radio-button { width: auto; } .arangoDataTable { - width: 100% !important; + border-spacing: 0 0; position: relative; table-layout: fixed !important; - border-spacing: 0 0px; } + width: 100% !important; } .arangoDataTable thead { - background-color: #FFF !important; + background-color: #fff !important; font-weight: 400 !important; text-align: left; } .arangoDataTable thead th { - font-weight: 400 !important; - padding: 10px 14px !important; border-bottom: none; - cursor: default !important; } + cursor: default !important; + font-weight: 400 !important; + padding: 10px 14px !important; } .arangoDataTable thead tr { - border-bottom: 1px solid #C2C2C2; } + border-bottom: 1px solid #c2c2c2; } .arangoDataTable tr { cursor: pointer; } .arangoDataTable td { @@ -3454,12 +3454,11 @@ input.gv-radio-button { .arangoDataTable .dataTable .noPointer tr { cursor: default; } -/* Odd / Even coloring */ -.api-container ul#resources > li.resource:nth-child(even), +.api-container #resources > li.resource:nth-child(even), table.arangoDataTable tr.even { - background-color: #FFF; } + background-color: #fff; } -.api-container ul#resources > li.resource:nth-child(odd), +.api-container #resources > li.resource:nth-child(odd), table.arangoDataTable tr.odd { background-color: #F1F0EE; } @@ -3502,7 +3501,7 @@ table.arangoDataTable tr.odd { padding-left: 10px; } .prettify { - border: 0 !important; + border: none !important; font-size: 1em !important; margin: 0 !important; padding: 0 !important; }