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 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 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 6bbfd0f0de..0000000000 --- a/js/apps/system/aardvark/frontend/css/datatables.css +++ /dev/null @@ -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..b84b97b6c8 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 { + border-spacing: 0 0; + position: relative; + table-layout: fixed !important; + width: 100% !important; + + thead { + 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; + } + + 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 #resources > li.resource:nth-child(even), +table.arangoDataTable tr.even { + background-color: #fff; +} + +.api-container #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; @@ -47,7 +100,7 @@ table.dataTable thead th { } .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 fbea143202..3deb2b8b33 100644 --- a/js/apps/system/aardvark/frontend/scss/generated.css +++ b/js/apps/system/aardvark/frontend/scss/generated.css @@ -3486,138 +3486,41 @@ input.gv-radio-button { margin-top: 3px; width: auto; } -.collectionTh { - font-family: 'Open Sans', sans-serif !important; - font-size: 14px; - font-weight: 400 !important; - text-align: left; - width: 20% !important; } - .collectionTh input, - .collectionTh select, - .collectionTh textarea { - margin-top: 10px; } - -.collectionInfoTh { - min-width: 60px; - text-align: left; - width: 320px; } - -.addCollection table tr { - border-bottom: 0 !important; - height: 53px; } -.addCollection .icon_arangodb_info { - margin-left: 20px !important; +.arangoDataTable { + border-spacing: 0 0; 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; } + table-layout: fixed !important; + width: 100% !important; } + .arangoDataTable thead { + background-color: #fff !important; + font-weight: 400 !important; + text-align: left; } + .arangoDataTable thead th { + border-bottom: 0; + cursor: default !important; + font-weight: 400 !important; + padding: 10px 14px !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; } -.change-collection .tab-content { - min-height: 230px; } -.change-collection input { - width: 384px !important; } -.change-collection select { - width: 398px !important; } +.api-container #resources > li.resource:nth-child(even), +table.arangoDataTable tr.even { + background-color: #fff; } -.show-collection .tab-content { - min-height: 200px; } +.api-container #resources > li.resource:nth-child(odd), +table.arangoDataTable tr.odd { + background-color: #f1f0ee; } -.collectionInfoTh { - width: 320px; } - -.collectionInfoTh2 { - font-family: 'Open Sans', sans-serif !important; - font-weight: 400 !important; - text-align: left; - width: 150px; } - -.collection-info-figures table { - float: left; - margin-left: 0; - margin-right: 0; - margin-top: 0; - min-width: 200px; - padding: 3px; - text-align: left; } - -.figures1, -.figures2 { - margin-bottom: 20px; - width: 255px; } - -.figures2 { - margin-left: 20px !important; } - -.figures3 { - margin-bottom: 0; - width: 100%; } - -.figuresHeader { - border-bottom: 1px solid #c2c2c2; } - -.figuresHeader th { - font-family: 'Open Sans', sans-serif !important; - font-weight: 400 !important; } - -#collectionIndexTable { - margin-left: 0; - width: 100%; } - -#infoTab, -#collectionTab { - border-bottom: 0; - margin-bottom: 1px; - padding-bottom: 0; - padding-right: 10px; } - -#infoTab li, -#collectionTab li { - float: right; } - -#infoTab a, -#collectionTab a { - background-color: #f1f0ee; - border-bottom: 1px solid #888888; - border-radius: 0 !important; - color: black; - font-size: 13px !important; - height: 21px; - margin-bottom: -1px; - margin-right: 4px; - padding: 4px !important; } - -#infoTab .active > a, -#collectionTab .active > a { - background-color: white; - border-color: #888888 #888888 transparent !important; } - -#tab-content-collection-info #info, -#tab-content-collection-info .collection-info-figures, -#tab-content-collection-info #index { - border-top: 1px solid #888888 !important; - margin-left: 0 !important; - padding-top: 10px; } - -#confirmCreateEdge { - margin-left: 20px; } - -.collection-info-figures .icon_arangodb_info { - position: relative !important; - right: -4px !important; } - -table.dataTable thead th { - font-weight: 400 !important; - padding: 10px 14px; } +#tableDiv table.dataTable td { + padding: 12px 18px !important; } #documentsTableID_length, #documentsTableID_filter { @@ -3655,7 +3558,7 @@ table.dataTable thead th { padding-left: 10px; } .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/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