diff --git a/arangod/CMakeLists.txt b/arangod/CMakeLists.txt index faed984b55..27e034f070 100644 --- a/arangod/CMakeLists.txt +++ b/arangod/CMakeLists.txt @@ -111,6 +111,9 @@ add_executable( RestServer/VocbaseContext.cpp RestServer/arango.cpp SkipLists/skiplistIndex.c + Transaction/IdGenerator.cpp + Transaction/Manager.cpp + Transaction/Transaction.cpp Utils/DocumentHelper.cpp V8Server/ApplicationV8.cpp V8Server/V8PeriodicTask.cpp @@ -144,6 +147,12 @@ add_executable( VocBase/voc-shaper.c VocBase/vocbase.c VocBase/vocbase-defaults.c + Wal/AllocatorThread.cpp + Wal/CollectorThread.cpp + Wal/Configuration.cpp + Wal/LogfileManager.cpp + Wal/Logfile.cpp + Wal/Logger.cpp ${ARANGOD_MRUBY_SOURCE} ) diff --git a/arangod/Makefile.files b/arangod/Makefile.files index 82a0c4c9f5..21f72f1fb4 100644 --- a/arangod/Makefile.files +++ b/arangod/Makefile.files @@ -112,7 +112,13 @@ bin_arangod_SOURCES = \ arangod/VocBase/update-policy.c \ arangod/VocBase/voc-shaper.c \ arangod/VocBase/vocbase.c \ - arangod/VocBase/vocbase-defaults.c + arangod/VocBase/vocbase-defaults.c \ + arangod/Wal/AllocatorThread.cpp \ + arangod/Wal/CollectorThread.cpp \ + arangod/Wal/Configuration.cpp \ + arangod/Wal/LogfileManager.cpp \ + arangod/Wal/Logfile.cpp \ + arangod/Wal/Logger.cpp if ENABLE_CLUSTER diff --git a/arangod/RestServer/ArangoServer.cpp b/arangod/RestServer/ArangoServer.cpp index 0a505231e5..fafef004c7 100644 --- a/arangod/RestServer/ArangoServer.cpp +++ b/arangod/RestServer/ArangoServer.cpp @@ -80,6 +80,7 @@ #include "V8Server/ApplicationV8.h" #include "VocBase/auth.h" #include "VocBase/server.h" +#include "Wal/Configuration.h" #ifdef TRI_ENABLE_CLUSTER #include "Cluster/ApplicationCluster.h" @@ -289,6 +290,7 @@ ArangoServer::ArangoServer (int argc, char** argv) : _argc(argc), _argv(argv), _tempPath(), + _walConfiguration(0), _applicationScheduler(0), _applicationDispatcher(0), _applicationEndpointServer(0), @@ -384,11 +386,14 @@ void ArangoServer::buildApplicationServer () { // arangod allows defining a user-specific configuration file. arangosh and the other binaries don't _applicationServer->setUserConfigFile(".arango" + string(1, TRI_DIR_SEPARATOR_CHAR) + string(conf)); - +/* + _walConfiguration = new wal::Configuration(); + _applicationServer->addFeature(_walConfiguration); +*/ // ............................................................................. // dispatcher // ............................................................................. - + _applicationDispatcher = new ApplicationDispatcher(); if (_applicationDispatcher == 0) { diff --git a/arangod/RestServer/ArangoServer.h b/arangod/RestServer/ArangoServer.h index 391e5d9fba..97a5da087f 100644 --- a/arangod/RestServer/ArangoServer.h +++ b/arangod/RestServer/ArangoServer.h @@ -56,6 +56,10 @@ namespace triagens { class HttpsServer; } + namespace wal { + class Configuration; + } + namespace admin { class ApplicationAdminServer; } @@ -186,6 +190,12 @@ namespace triagens { std::string _tempPath; +//////////////////////////////////////////////////////////////////////////////// +/// @brief write-ahead log configuration +//////////////////////////////////////////////////////////////////////////////// + + wal::Configuration* _walConfiguration; + //////////////////////////////////////////////////////////////////////////////// /// @brief application scheduler //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/Transaction/Transaction.cpp b/arangod/Transaction/Transaction.cpp index 1bc0a7fd4b..1880fbece8 100644 --- a/arangod/Transaction/Transaction.cpp +++ b/arangod/Transaction/Transaction.cpp @@ -110,10 +110,6 @@ int Transaction::abort () { return TRI_ERROR_TRANSACTION_INTERNAL; } -// ----------------------------------------------------------------------------- -// --SECTION-- private methods -// ----------------------------------------------------------------------------- - // Local Variables: // mode: outline-minor // outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" diff --git a/arangod/Wal/AllocatorThread.cpp b/arangod/Wal/AllocatorThread.cpp new file mode 100644 index 0000000000..4eb5c37a7c --- /dev/null +++ b/arangod/Wal/AllocatorThread.cpp @@ -0,0 +1,139 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log storage allocator thread +/// +/// @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 "AllocatorThread.h" +#include "BasicsC/logging.h" +#include "Basics/ConditionLocker.h" +#include "Wal/LogfileManager.h" + +using namespace triagens::wal; + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the allocator thread +//////////////////////////////////////////////////////////////////////////////// + +AllocatorThread::AllocatorThread (LogfileManager* logfileManager) + : Thread("WalAllocator"), + _logfileManager(logfileManager), + _condition(), + _createLogfile(false), + _stop(0) { + + allowAsynchronousCancelation(); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the allocator thread +//////////////////////////////////////////////////////////////////////////////// + +AllocatorThread::~AllocatorThread () { +} + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief initialises the allocator thread +//////////////////////////////////////////////////////////////////////////////// + +bool AllocatorThread::init () { + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief stops the allocator thread +//////////////////////////////////////////////////////////////////////////////// + +void AllocatorThread::stop () { + if (_stop > 0) { + return; + } + + _stop = 1; + _condition.signal(); + + while (_stop != 2) { + usleep(1000); + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief signal the creation of a new logfile +//////////////////////////////////////////////////////////////////////////////// + +void AllocatorThread::signalLogfileCreation () { + CONDITION_LOCKER(guard, _condition); + + _createLogfile = true; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief creates a new logfile +//////////////////////////////////////////////////////////////////////////////// + +bool AllocatorThread::createLogfile () { + int res = _logfileManager->allocateDatafile(); + + return (res == TRI_ERROR_NO_ERROR); +} + +// ----------------------------------------------------------------------------- +// --SECTION-- Thread methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief main loop +//////////////////////////////////////////////////////////////////////////////// + +void AllocatorThread::run () { + while (_stop == 0) { + CONDITION_LOCKER(guard, _condition); + + if (_createLogfile) { + if (createLogfile()) { + _createLogfile = false; + continue; + } + + LOG_ERROR("unable to create new wal logfile"); + } + + guard.wait(1000000); + } + + _stop = 2; +} + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/AllocatorThread.h b/arangod/Wal/AllocatorThread.h new file mode 100644 index 0000000000..e3e51f1eb4 --- /dev/null +++ b/arangod/Wal/AllocatorThread.h @@ -0,0 +1,160 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log storage allocator thread +/// +/// @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 +//////////////////////////////////////////////////////////////////////////////// + +#ifndef TRIAGENS_WAL_ALLOCATOR_THREAD_H +#define TRIAGENS_WAL_ALLOCATOR_THREAD_H 1 + +#include "Basics/Common.h" +#include "Basics/ConditionVariable.h" +#include "Basics/Thread.h" + +namespace triagens { + namespace wal { + + class LogfileManager; + +// ----------------------------------------------------------------------------- +// --SECTION-- class AllocatorThread +// ----------------------------------------------------------------------------- + + class AllocatorThread : public basics::Thread { + +//////////////////////////////////////////////////////////////////////////////// +/// @brief AllocatorThread +//////////////////////////////////////////////////////////////////////////////// + + private: + AllocatorThread (AllocatorThread const&); + AllocatorThread& operator= (AllocatorThread const&); + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the allocator thread +//////////////////////////////////////////////////////////////////////////////// + + AllocatorThread (LogfileManager*); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the allocator thread +//////////////////////////////////////////////////////////////////////////////// + + ~AllocatorThread (); + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief initialises the allocator thread +//////////////////////////////////////////////////////////////////////////////// + + bool init (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief stops the allocator thread +//////////////////////////////////////////////////////////////////////////////// + + void stop (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief signal the creation of a new logfile +//////////////////////////////////////////////////////////////////////////////// + + void signalLogfileCreation (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief creates a new logfile +//////////////////////////////////////////////////////////////////////////////// + + bool createLogfile (); + +// ----------------------------------------------------------------------------- +// --SECTION-- Thread methods +// ----------------------------------------------------------------------------- + + protected: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief main loop +//////////////////////////////////////////////////////////////////////////////// + + void run (); + +// ----------------------------------------------------------------------------- +// --SECTION-- private methods +// ----------------------------------------------------------------------------- + + private: + +// ----------------------------------------------------------------------------- +// --SECTION-- private variables +// ----------------------------------------------------------------------------- + + private: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the logfile manager +//////////////////////////////////////////////////////////////////////////////// + + LogfileManager* _logfileManager; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief condition variable for the allocator thread +//////////////////////////////////////////////////////////////////////////////// + + basics::ConditionVariable _condition; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not we should create a new logfile +//////////////////////////////////////////////////////////////////////////////// + + bool _createLogfile; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief stop flag +//////////////////////////////////////////////////////////////////////////////// + + volatile sig_atomic_t _stop; + + }; + + } +} + +#endif + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/CollectorThread.cpp b/arangod/Wal/CollectorThread.cpp new file mode 100644 index 0000000000..f1a1007268 --- /dev/null +++ b/arangod/Wal/CollectorThread.cpp @@ -0,0 +1,110 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log garbage collection thread +/// +/// @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 "CollectorThread.h" +#include "BasicsC/logging.h" +#include "Basics/ConditionLocker.h" +#include "Wal/LogfileManager.h" + +using namespace triagens::wal; + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the collector thread +//////////////////////////////////////////////////////////////////////////////// + +CollectorThread::CollectorThread (LogfileManager* logfileManager) + : Thread("WalCollector"), + _logfileManager(logfileManager), + _condition(), + _stop(0) { + + allowAsynchronousCancelation(); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the collector thread +//////////////////////////////////////////////////////////////////////////////// + +CollectorThread::~CollectorThread () { +} + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief initialises the collector thread +//////////////////////////////////////////////////////////////////////////////// + +bool CollectorThread::init () { + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief stops the collector thread +//////////////////////////////////////////////////////////////////////////////// + +void CollectorThread::stop () { + if (_stop > 0) { + return; + } + + _stop = 1; + _condition.signal(); + + while (_stop != 2) { + usleep(1000); + } +} + +// ----------------------------------------------------------------------------- +// --SECTION-- Thread methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief main loop +//////////////////////////////////////////////////////////////////////////////// + +void CollectorThread::run () { + while (_stop == 0) { + CONDITION_LOCKER(guard, _condition); + + // TODO: implement collection + guard.wait(1000000); + } + + _stop = 2; +} + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/CollectorThread.h b/arangod/Wal/CollectorThread.h new file mode 100644 index 0000000000..c65d1533fc --- /dev/null +++ b/arangod/Wal/CollectorThread.h @@ -0,0 +1,142 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log garbage collection thread +/// +/// @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 +//////////////////////////////////////////////////////////////////////////////// + +#ifndef TRIAGENS_WAL_COLLECTOR_THREAD_H +#define TRIAGENS_WAL_COLLECTOR_THREAD_H 1 + +#include "Basics/Common.h" +#include "Basics/ConditionVariable.h" +#include "Basics/Thread.h" + +namespace triagens { + namespace wal { + + class LogfileManager; + +// ----------------------------------------------------------------------------- +// --SECTION-- class CollectorThread +// ----------------------------------------------------------------------------- + + class CollectorThread : public basics::Thread { + +//////////////////////////////////////////////////////////////////////////////// +/// @brief CollectorThread +//////////////////////////////////////////////////////////////////////////////// + + private: + CollectorThread (CollectorThread const&); + CollectorThread& operator= (CollectorThread const&); + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the collector thread +//////////////////////////////////////////////////////////////////////////////// + + CollectorThread (LogfileManager*); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the collector thread +//////////////////////////////////////////////////////////////////////////////// + + ~CollectorThread (); + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief initialises the collector thread +//////////////////////////////////////////////////////////////////////////////// + + bool init (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief stops the collector thread +//////////////////////////////////////////////////////////////////////////////// + + void stop (); + +// ----------------------------------------------------------------------------- +// --SECTION-- Thread methods +// ----------------------------------------------------------------------------- + + protected: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief main loop +//////////////////////////////////////////////////////////////////////////////// + + void run (); + +// ----------------------------------------------------------------------------- +// --SECTION-- private methods +// ----------------------------------------------------------------------------- + + private: + +// ----------------------------------------------------------------------------- +// --SECTION-- private variables +// ----------------------------------------------------------------------------- + + private: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the logfile manager +//////////////////////////////////////////////////////////////////////////////// + + LogfileManager* _logfileManager; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief condition variable for the collector thread +//////////////////////////////////////////////////////////////////////////////// + + basics::ConditionVariable _condition; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief stop flag +//////////////////////////////////////////////////////////////////////////////// + + volatile sig_atomic_t _stop; + + }; + + } +} + +#endif + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/Configuration.cpp b/arangod/Wal/Configuration.cpp new file mode 100644 index 0000000000..2b6937f27b --- /dev/null +++ b/arangod/Wal/Configuration.cpp @@ -0,0 +1,143 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log configuration +/// +/// @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 "Configuration.h" +#include "BasicsC/logging.h" +#include "Wal/LogfileManager.h" + +using namespace triagens::wal; + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the configuration +//////////////////////////////////////////////////////////////////////////////// + +Configuration::Configuration () + : ApplicationFeature("wal"), + _logfileManager(nullptr), + _filesize(32 * 1024 * 1024), + _numberOfLogfiles(4), + _reserveSize(16 * 1024 * 1024), + _directory() { + +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the configuration +//////////////////////////////////////////////////////////////////////////////// + +Configuration::~Configuration () { + if (_logfileManager != nullptr) { + delete _logfileManager; + } +} + +// ----------------------------------------------------------------------------- +// --SECTION-- ApplicationFeature methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + +void Configuration::setupOptions (std::map& options) { + options["Write-ahead log options:help-wal"] + ("wal.filesize", &_filesize, "size of each logfile") + ("wal.logfiles", &_numberOfLogfiles, "target number of logfiles") + ("wal.reserve", &_reserveSize, "minimum space to reserve for new data") + ("wal.directory", &_directory, "logfile directory") + ; +} + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + +bool Configuration::prepare () { + if (_directory.empty()) { + LOG_FATAL_AND_EXIT("no directory specified for write-ahead logs. Please provide the --wal.directory option"); + } + + if (_directory[_directory.size() - 1] != TRI_DIR_SEPARATOR_CHAR) { + // append a trailing slash to directory name + _directory.push_back(TRI_DIR_SEPARATOR_CHAR); + } + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + +bool Configuration::start () { + _logfileManager = new LogfileManager(this); + + assert(_logfileManager != nullptr); + + int res = _logfileManager->startup(); + + if (res != TRI_ERROR_NO_ERROR) { + LOG_ERROR("could not initialise wal components: %s", TRI_errno_string(res)); + return false; + } + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + +bool Configuration::open () { + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + +void Configuration::close () { +} + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + +void Configuration::stop () { + if (_logfileManager != nullptr) { + _logfileManager->shutdown(); + } +} + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/Configuration.h b/arangod/Wal/Configuration.h new file mode 100644 index 0000000000..a49218ecb4 --- /dev/null +++ b/arangod/Wal/Configuration.h @@ -0,0 +1,211 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log configuration +/// +/// @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 +//////////////////////////////////////////////////////////////////////////////// + +#ifndef TRIAGENS_WAL_LOGFILE_CONFIGURATION_H +#define TRIAGENS_WAL_LOGFILE_CONFIGURATION_H 1 + +#include "Basics/Common.h" +#include "ApplicationServer/ApplicationFeature.h" + +namespace triagens { + namespace wal { + + class LogfileManager; + +// ----------------------------------------------------------------------------- +// --SECTION-- class Configuration +// ----------------------------------------------------------------------------- + + class Configuration : public rest::ApplicationFeature { + +//////////////////////////////////////////////////////////////////////////////// +/// @brief Configuration +//////////////////////////////////////////////////////////////////////////////// + + private: + Configuration (Configuration const&); + Configuration& operator= (Configuration const&); + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the configuration +//////////////////////////////////////////////////////////////////////////////// + + Configuration (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the configuration +//////////////////////////////////////////////////////////////////////////////// + + ~Configuration (); + +// ----------------------------------------------------------------------------- +// --SECTION-- ApplicationFeature methods +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + + void setupOptions (std::map&); + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + + bool prepare (); + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + + bool open (); + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + + bool start (); + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + + void close (); + +//////////////////////////////////////////////////////////////////////////////// +/// {@inheritDoc} +//////////////////////////////////////////////////////////////////////////////// + + void stop (); + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the logfile size +//////////////////////////////////////////////////////////////////////////////// + + uint32_t filesize () const { + return _filesize; + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the maximum number of logfiles +//////////////////////////////////////////////////////////////////////////////// + + uint32_t numberOfLogfiles () const { + return _numberOfLogfiles; + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the maximum size for all logfiles +//////////////////////////////////////////////////////////////////////////////// + + uint64_t maximumSize () const { + return static_cast(_filesize) * static_cast(_numberOfLogfiles); + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the reserve size for all logfiles +//////////////////////////////////////////////////////////////////////////////// + + uint64_t reserveSize () const { + return static_cast(_reserveSize); + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get the logfile directory +//////////////////////////////////////////////////////////////////////////////// + + std::string directory () const { + return _directory; + } + +// ----------------------------------------------------------------------------- +// --SECTION-- private methods +// ----------------------------------------------------------------------------- + + private: + +// ----------------------------------------------------------------------------- +// --SECTION-- private variables +// ----------------------------------------------------------------------------- + + private: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the logfile manager +//////////////////////////////////////////////////////////////////////////////// + + LogfileManager* _logfileManager; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the size of each logfile +//////////////////////////////////////////////////////////////////////////////// + + uint32_t _filesize; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the target number of logfiles +//////////////////////////////////////////////////////////////////////////////// + + uint32_t _numberOfLogfiles; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the reserve free space +//////////////////////////////////////////////////////////////////////////////// + + uint32_t _reserveSize; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the logfile directory +//////////////////////////////////////////////////////////////////////////////// + + std::string _directory; + + }; + + } +} + +#endif + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/LogEntry.h b/arangod/Wal/LogEntry.h new file mode 100644 index 0000000000..f16399459e --- /dev/null +++ b/arangod/Wal/LogEntry.h @@ -0,0 +1,115 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log entry +/// +/// @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 +//////////////////////////////////////////////////////////////////////////////// + +#ifndef TRIAGENS_WAL_LOG_ENTRY_H +#define TRIAGENS_WAL_LOG_ENTRY_H 1 + +#include "Basics/Common.h" +#include "VocBase/voc-types.h" + +namespace triagens { + namespace wal { + +// ----------------------------------------------------------------------------- +// --SECTION-- struct LogEntry +// ----------------------------------------------------------------------------- + + struct LogEntry { + +// ----------------------------------------------------------------------------- +// --SECTION-- typedefs +// ----------------------------------------------------------------------------- + + typedef TRI_voc_tick_t TickType; + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create a log entry +//////////////////////////////////////////////////////////////////////////////// + + LogEntry (void* mem, + size_t size, + TickType tick) + : _mem(mem), + _size(size), + _tick(tick) { + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy a log entry +//////////////////////////////////////////////////////////////////////////////// + + ~LogEntry () { + } + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief check if the entry is valid +//////////////////////////////////////////////////////////////////////////////// + + bool isValid () const { + return _mem != nullptr; + } + +// ----------------------------------------------------------------------------- +// --SECTION-- public variables +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the position in memory where the log entry resides +//////////////////////////////////////////////////////////////////////////////// + + void* const _mem; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the size of the log entry +//////////////////////////////////////////////////////////////////////////////// + + size_t const _size; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the id (sequence number of the log entry) +//////////////////////////////////////////////////////////////////////////////// + + TickType _tick; + }; + + } +} + +#endif + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/Logfile.cpp b/arangod/Wal/Logfile.cpp new file mode 100644 index 0000000000..5b500c51d8 --- /dev/null +++ b/arangod/Wal/Logfile.cpp @@ -0,0 +1,55 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log logfile +/// +/// @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 "Logfile.h" + +using namespace triagens::wal; + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the logfile +//////////////////////////////////////////////////////////////////////////////// + +Logfile::Logfile (TRI_datafile_t* df) + : _df(df) { +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the logfile +//////////////////////////////////////////////////////////////////////////////// + +Logfile::~Logfile () { + TRI_CloseDatafile(_df); +} + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/Logfile.h b/arangod/Wal/Logfile.h new file mode 100644 index 0000000000..a66943a3f6 --- /dev/null +++ b/arangod/Wal/Logfile.h @@ -0,0 +1,134 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log logfile +/// +/// @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 +//////////////////////////////////////////////////////////////////////////////// + +#ifndef TRIAGENS_WAL_LOGFILE_H +#define TRIAGENS_WAL_LOGFILE_H 1 + +#include "Basics/Common.h" +#include "VocBase/datafile.h" + +namespace triagens { + namespace wal { + +// ----------------------------------------------------------------------------- +// --SECTION-- class Logfile +// ----------------------------------------------------------------------------- + + class Logfile { + +// ----------------------------------------------------------------------------- +// --SECTION-- typedefs +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief typedef for logfile ids +//////////////////////////////////////////////////////////////////////////////// + + typedef TRI_voc_fid_t IdType; + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + + private: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief Logfile +//////////////////////////////////////////////////////////////////////////////// + + Logfile (Logfile const&); + Logfile& operator= (Logfile const&); + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create a logfile +//////////////////////////////////////////////////////////////////////////////// + + Logfile (TRI_datafile_t*); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy a logfile +//////////////////////////////////////////////////////////////////////////////// + + ~Logfile (); + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return the allocated size of the logfile +//////////////////////////////////////////////////////////////////////////////// + + uint64_t allocatedSize () const { + return static_cast(_df->_maximalSize); + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return the size of the free space in the logfile +//////////////////////////////////////////////////////////////////////////////// + + uint64_t freeSize () const { + if (_df->_isSealed) { + return 0; + } + + return static_cast(allocatedSize() - _df->_footerSize); + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not the logfile is sealed +//////////////////////////////////////////////////////////////////////////////// + + bool isSealed () const { + return _df->_isSealed; + } + +// ----------------------------------------------------------------------------- +// --SECTION-- public variables +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the datafile entry +//////////////////////////////////////////////////////////////////////////////// + + TRI_datafile_t* _df; + + }; + + } +} + +#endif + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/LogfileManager.cpp b/arangod/Wal/LogfileManager.cpp new file mode 100644 index 0000000000..529ed114f1 --- /dev/null +++ b/arangod/Wal/LogfileManager.cpp @@ -0,0 +1,553 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log logfile manager +/// +/// @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 "LogfileManager.h" +#include "BasicsC/json.h" +#include "BasicsC/logging.h" +#include "Basics/Exceptions.h" +#include "Basics/FileUtils.h" +#include "Basics/JsonHelper.h" +#include "Basics/MutexLocker.h" +#include "Basics/ReadLocker.h" +#include "Basics/StringUtils.h" +#include "Basics/WriteLocker.h" +#include "Wal/AllocatorThread.h" +#include "Wal/CollectorThread.h" +#include "Wal/Configuration.h" + +using namespace triagens::wal; + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the logfile manager +//////////////////////////////////////////////////////////////////////////////// + +LogfileManager::LogfileManager (Configuration* configuration) + : _configuration(configuration), + _tickLock(), + _tick(0), + _allocatorThread(nullptr), + _collectorThread(nullptr), + _logfileIdLock(), + _logfileId(0), + _logfilesLock(), + _logfiles(), + _directory(configuration->directory()) { + + int res = regcomp(&_regex, "^logfile-([0-9][0-9]*)\\.db$", REG_EXTENDED); + + if (res != 0) { + THROW_INTERNAL_ERROR("could not compile regex"); + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the logfile manager +//////////////////////////////////////////////////////////////////////////////// + +LogfileManager::~LogfileManager () { + shutdown(); + regfree(&_regex); +} + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief startup the logfile manager +//////////////////////////////////////////////////////////////////////////////// + +int LogfileManager::startup () { + int res = inventory(); + + if (res != TRI_ERROR_NO_ERROR) { + LOG_ERROR("could not create wal logfile inventory: %s", TRI_errno_string(res)); + return res; + } + + std::string const shutdownFile = shutdownFilename(); + bool const shutdownFileExists = basics::FileUtils::exists(shutdownFile); + + if (shutdownFileExists) { + res = readShutdownInfo(); + + if (res != TRI_ERROR_NO_ERROR) { + LOG_ERROR("could not open shutdown file '%s': %s", shutdownFile.c_str(), TRI_errno_string(res)); + return res; + } + } + + res = openLogfiles(); + + if (res != TRI_ERROR_NO_ERROR) { + LOG_ERROR("could not open wal logfiles: %s", TRI_errno_string(res)); + return res; + } + + res = reserveSpace(); + + if (res != TRI_ERROR_NO_ERROR) { + LOG_ERROR("could not reserve wal space: %s", TRI_errno_string(res)); + return res; + } + + res = startAllocatorThread(); + + if (res != TRI_ERROR_NO_ERROR) { + LOG_ERROR("could not start wal allocator thread: %s", TRI_errno_string(res)); + return res; + } + + res = startCollectorThread(); + + if (res != TRI_ERROR_NO_ERROR) { + LOG_ERROR("could not start wal collector thread: %s", TRI_errno_string(res)); + return res; + } + + if (shutdownFileExists) { + // delete the shutdown file if it existed + if (! basics::FileUtils::remove(shutdownFile, &res)) { + LOG_ERROR("could not remove shutdown file '%s': %s", shutdownFile.c_str(), TRI_errno_string(res)); + return res; + } + } + + LOG_INFO("wal logfile manager started successfully"); + + return TRI_ERROR_NO_ERROR; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief shuts down and closes all open logfiles +//////////////////////////////////////////////////////////////////////////////// + +void LogfileManager::shutdown () { + // stop threads + stopCollectorThread(); + stopAllocatorThread(); + + // close all open logfiles + WRITE_LOCKER(_logfilesLock); + + for (auto it = _logfiles.begin(); it != _logfiles.end(); ++it) { + Logfile* logfile = (*it).second; + + if (logfile != nullptr) { + delete logfile; + } + } + + _logfiles.clear(); + + int res = writeShutdownInfo(); + + if (res != TRI_ERROR_NO_ERROR) { + LOG_ERROR("could not write wal shutdown info: %s", TRI_errno_string(res)); + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief reserve space in a log file +//////////////////////////////////////////////////////////////////////////////// + +LogEntry LogfileManager::reserve (size_t size) { + LogEntry::TickType const tick = nextTick(); + + LogEntry entry = LogEntry(0, size, tick); + + return entry; +} + +// ----------------------------------------------------------------------------- +// --SECTION-- private methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief increases the tick value and returns it +//////////////////////////////////////////////////////////////////////////////// + +LogEntry::TickType LogfileManager::nextTick () { + WRITE_LOCKER(_tickLock); + return ++_tick; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief returns the last assigned tick +//////////////////////////////////////////////////////////////////////////////// + +LogEntry::TickType LogfileManager::currentTick () { + READ_LOCKER(_tickLock); + return _tick; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief reads the shutdown information +//////////////////////////////////////////////////////////////////////////////// + +int LogfileManager::readShutdownInfo () { + std::string const filename = shutdownFilename(); + + TRI_json_t* json = TRI_JsonFile(TRI_UNKNOWN_MEM_ZONE, filename.c_str(), nullptr); + + if (json == nullptr) { + return TRI_ERROR_INTERNAL; + } + + uint64_t const tick = basics::JsonHelper::stringUInt64(json, "maxTick"); + + _tick = static_cast(tick); + + TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json); + + return TRI_ERROR_NO_ERROR; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief writes the shutdown information +//////////////////////////////////////////////////////////////////////////////// + +int LogfileManager::writeShutdownInfo () { + std::string const filename = shutdownFilename(); + + std::string content; + content.append("{\"maxTick\":\""); + content.append(basics::StringUtils::itoa(currentTick())); + content.append("\"}"); + + // TODO: spit() doesn't return success/failure. FIXME! + basics::FileUtils::spit(filename, content); + + return TRI_ERROR_NO_ERROR; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief start the allocator thread +//////////////////////////////////////////////////////////////////////////////// + +int LogfileManager::startAllocatorThread () { + _allocatorThread = new AllocatorThread(this); + + if (_allocatorThread == nullptr) { + return TRI_ERROR_INTERNAL; + } + + if (! _allocatorThread->init() || + ! _allocatorThread->start()) { + return TRI_ERROR_INTERNAL; + } + + return TRI_ERROR_NO_ERROR; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief stop the allocator thread +//////////////////////////////////////////////////////////////////////////////// + +void LogfileManager::stopAllocatorThread () { + if (_allocatorThread != nullptr) { + LOG_TRACE("stopping wal allocator thread"); + + _allocatorThread->stop(); + _allocatorThread->shutdown(); + + delete _allocatorThread; + _allocatorThread = 0; + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief start the collector thread +//////////////////////////////////////////////////////////////////////////////// + +int LogfileManager::startCollectorThread () { + _collectorThread = new CollectorThread(this); + + if (_collectorThread == nullptr) { + return TRI_ERROR_INTERNAL; + } + + if (! _collectorThread->init() || + ! _collectorThread->start()) { + return TRI_ERROR_INTERNAL; + } + + return TRI_ERROR_NO_ERROR; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief stop the collector thread +//////////////////////////////////////////////////////////////////////////////// + +void LogfileManager::stopCollectorThread () { + if (_collectorThread != nullptr) { + LOG_TRACE("stopping wal collector thread"); + + _collectorThread->stop(); + _collectorThread->shutdown(); + + delete _collectorThread; + _collectorThread = 0; + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief check which logfiles are present in the log directory +//////////////////////////////////////////////////////////////////////////////// + +int LogfileManager::inventory () { + int res = ensureDirectory(); + + if (res != TRI_ERROR_NO_ERROR) { + return res; + } + + LOG_INFO("scanning wal directory: '%s'", _directory.c_str()); + std::vector files = basics::FileUtils::listFiles(_directory); + + for (auto it = files.begin(); it != files.end(); ++it) { + regmatch_t matches[2]; + std::string const file = (*it); + char const* s = file.c_str(); + + if (regexec(&_regex, s, sizeof(matches) / sizeof(matches[1]), matches, 0) == 0) { + Logfile::IdType const id = basics::StringUtils::uint64(s + matches[1].rm_so, matches[1].rm_eo - matches[1].rm_so); + + WRITE_LOCKER(_logfilesLock); + _logfiles.insert(make_pair(id, nullptr)); + } + } + + // now pick up the logfile with the highest id and use its id + + READ_LOCKER(_logfilesLock); + if (! _logfiles.empty()) { + auto it = _logfiles.rbegin(); + + MUTEX_LOCKER(_logfileIdLock); + _logfileId = (*it).first; + } + + return TRI_ERROR_NO_ERROR; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief scan the logfiles in the log directory +//////////////////////////////////////////////////////////////////////////////// + +int LogfileManager::openLogfiles () { + WRITE_LOCKER(_logfilesLock); + + for (auto it = _logfiles.begin(); it != _logfiles.end(); ++it) { + 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()); + + 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; + } + } + + (*it).second = new Logfile(df); + } + + return TRI_ERROR_NO_ERROR; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief reserve space in the logfile directory +//////////////////////////////////////////////////////////////////////////////// + +int LogfileManager::reserveSpace () { + while (shouldAllocate()) { + int res = allocateDatafile(); + + if (res != TRI_ERROR_NO_ERROR) { + LOG_ERROR("unable to allocate new datafile: %s", TRI_errno_string(res)); + + return res; + } + } + + return TRI_ERROR_NO_ERROR; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not a new datafile must be allocated +//////////////////////////////////////////////////////////////////////////////// + +bool LogfileManager::shouldAllocate () { + uint64_t const maximum = _configuration->maximumSize(); + uint64_t const reserve = _configuration->reserveSize(); + uint64_t const allocated = allocatedSize(); + uint64_t const free = freeSize(); + + if (allocated >= maximum) { + return false; + } + + if (free >= reserve) { + return false; + } + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief total number of bytes allocated in datafiles +//////////////////////////////////////////////////////////////////////////////// + +uint64_t LogfileManager::allocatedSize () { + uint64_t allocated = 0; + + READ_LOCKER(_logfilesLock); + + for (auto it = _logfiles.begin(); it != _logfiles.end(); ++it) { + Logfile* logfile = (*it).second; + + assert(logfile != nullptr); + allocated += logfile->allocatedSize(); + } + + return allocated; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief total number of free bytes in already allocated datafiles +//////////////////////////////////////////////////////////////////////////////// + +uint64_t LogfileManager::freeSize () { + uint64_t free = 0; + + READ_LOCKER(_logfilesLock); + + for (auto it = _logfiles.begin(); it != _logfiles.end(); ++it) { + Logfile* logfile = (*it).second; + + assert(logfile != nullptr); + free += logfile->freeSize(); + } + + return free; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief allocate a new datafile +//////////////////////////////////////////////////////////////////////////////// + +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())); + + if (df == nullptr) { + int res = TRI_errno(); + + LOG_ERROR("unable to create datafile: %s", TRI_errno_string(res)); + return res; + } + + WRITE_LOCKER(_logfilesLock); + _logfiles.insert(make_pair(id, new Logfile(df))); + + return TRI_ERROR_NO_ERROR; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief run the recovery procedure +//////////////////////////////////////////////////////////////////////////////// + +int LogfileManager::runRecovery () { + // TODO + return TRI_ERROR_NO_ERROR; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get an id for the next logfile +//////////////////////////////////////////////////////////////////////////////// + +Logfile::IdType LogfileManager::nextId () { + MUTEX_LOCKER(_logfileIdLock); + return ++_logfileId; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief ensure the wal logfiles directory is actually there +//////////////////////////////////////////////////////////////////////////////// + +int LogfileManager::ensureDirectory () { + if (! basics::FileUtils::isDirectory(_directory)) { + int res; + + LOG_INFO("wal directory '%s' does not exist. creating it...", _directory.c_str()); + + if (! basics::FileUtils::createDirectory(_directory, &res)) { + LOG_ERROR("could not create wal directory: '%s': %s", _directory.c_str(), TRI_errno_string(res)); + return res; + } + } + + if (! basics::FileUtils::isDirectory(_directory)) { + LOG_ERROR("wal directory '%s' does not exist", _directory.c_str()); + return TRI_ERROR_FILE_NOT_FOUND; + } + + return TRI_ERROR_NO_ERROR; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return an absolute filename for a logfile id +//////////////////////////////////////////////////////////////////////////////// + +std::string LogfileManager::logfileName (Logfile::IdType id) const { + return _directory + std::string("logfile-") + basics::StringUtils::itoa(id) + std::string(".db"); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return the absolute name of the shutdown file +//////////////////////////////////////////////////////////////////////////////// + +std::string LogfileManager::shutdownFilename () const { + return _directory + std::string("SHUTDOWN"); +} + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/LogfileManager.h b/arangod/Wal/LogfileManager.h new file mode 100644 index 0000000000..bc4a63e3d1 --- /dev/null +++ b/arangod/Wal/LogfileManager.h @@ -0,0 +1,313 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log file manager +/// +/// @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 +//////////////////////////////////////////////////////////////////////////////// + +#ifndef TRIAGENS_WAL_LOGFILE_MANAGER_H +#define TRIAGENS_WAL_LOGFILE_MANAGER_H 1 + +#include "Basics/Common.h" +#include "Basics/Mutex.h" +#include "Basics/ReadWriteLock.h" +#include "Wal/LogEntry.h" +#include "Wal/Logfile.h" + +#include + +namespace triagens { + namespace wal { + + class AllocatorThread; + class CollectorThread; + class Configuration; + +// ----------------------------------------------------------------------------- +// --SECTION-- class LogfileManager +// ----------------------------------------------------------------------------- + + class LogfileManager { + + friend class AllocatorThread; + friend class CollectorThread; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief LogfileManager +//////////////////////////////////////////////////////////////////////////////// + + private: + LogfileManager (LogfileManager const&); + LogfileManager& operator= (LogfileManager const&); + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the logfile manager +//////////////////////////////////////////////////////////////////////////////// + + LogfileManager (Configuration*); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the logfile manager +//////////////////////////////////////////////////////////////////////////////// + + ~LogfileManager (); + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief startup the logfile manager +//////////////////////////////////////////////////////////////////////////////// + + int startup (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief shuts down and closes all open logfiles +//////////////////////////////////////////////////////////////////////////////// + + void shutdown (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief reserve space in a log file +//////////////////////////////////////////////////////////////////////////////// + + LogEntry reserve (size_t); + +// ----------------------------------------------------------------------------- +// --SECTION-- private methods +// ----------------------------------------------------------------------------- + + private: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief increases the tick value and returns it +//////////////////////////////////////////////////////////////////////////////// + + LogEntry::TickType nextTick (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief returns the last assigned tick +//////////////////////////////////////////////////////////////////////////////// + + LogEntry::TickType currentTick (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief reads the shutdown information +//////////////////////////////////////////////////////////////////////////////// + + int readShutdownInfo (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief writes the shutdown information +//////////////////////////////////////////////////////////////////////////////// + + int writeShutdownInfo (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief start the allocator thread +//////////////////////////////////////////////////////////////////////////////// + + int startAllocatorThread (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief stop the allocator thread +//////////////////////////////////////////////////////////////////////////////// + + void stopAllocatorThread (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief start the collector thread +//////////////////////////////////////////////////////////////////////////////// + + int startCollectorThread (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief stop the collector thread +//////////////////////////////////////////////////////////////////////////////// + + void stopCollectorThread (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief check which logfiles are present in the log directory +//////////////////////////////////////////////////////////////////////////////// + + int inventory (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief open the logfiles in the log directory +//////////////////////////////////////////////////////////////////////////////// + + int openLogfiles (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief reserve space in the logfile directory +//////////////////////////////////////////////////////////////////////////////// + + int reserveSpace (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief whether or not a new datafile must be allocated +//////////////////////////////////////////////////////////////////////////////// + + bool shouldAllocate (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief total number of bytes allocated in datafiles +//////////////////////////////////////////////////////////////////////////////// + + uint64_t allocatedSize (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief total number of free bytes in already allocated datafiles +//////////////////////////////////////////////////////////////////////////////// + + uint64_t freeSize (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief allocate a new datafile +//////////////////////////////////////////////////////////////////////////////// + + int allocateDatafile (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief run the recovery procedure +//////////////////////////////////////////////////////////////////////////////// + + int runRecovery (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief get an id for the next logfile +//////////////////////////////////////////////////////////////////////////////// + + Logfile::IdType nextId (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief ensure the wal logfiles directory is actually there +//////////////////////////////////////////////////////////////////////////////// + + int ensureDirectory (); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return an absolute filename for a logfile id +//////////////////////////////////////////////////////////////////////////////// + + std::string logfileName (Logfile::IdType) const; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return the absolute name of the shutdown file +//////////////////////////////////////////////////////////////////////////////// + + std::string shutdownFilename () const; + +// ----------------------------------------------------------------------------- +// --SECTION-- private variables +// ----------------------------------------------------------------------------- + + private: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the log file manager configuration +//////////////////////////////////////////////////////////////////////////////// + + Configuration* _configuration; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief a lock protecting _tick +//////////////////////////////////////////////////////////////////////////////// + + basics::ReadWriteLock _tickLock; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the last assigned tick +//////////////////////////////////////////////////////////////////////////////// + + LogEntry::TickType _tick; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the allocator thread +//////////////////////////////////////////////////////////////////////////////// + + AllocatorThread* _allocatorThread; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the collector thread +//////////////////////////////////////////////////////////////////////////////// + + CollectorThread* _collectorThread; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief a lock protecting the _logfileId value +//////////////////////////////////////////////////////////////////////////////// + + basics::Mutex _logfileIdLock; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief last allocated logfile id +//////////////////////////////////////////////////////////////////////////////// + + Logfile::IdType _logfileId; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief a lock protecting the _logfiles map +//////////////////////////////////////////////////////////////////////////////// + + basics::ReadWriteLock _logfilesLock; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the logfiles +//////////////////////////////////////////////////////////////////////////////// + + std::map _logfiles; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief logfile directory +//////////////////////////////////////////////////////////////////////////////// + + std::string const _directory; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief regex to match logfiles +//////////////////////////////////////////////////////////////////////////////// + + regex_t _regex; + + }; + + } +} + +#endif + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/Logger.cpp b/arangod/Wal/Logger.cpp new file mode 100644 index 0000000000..6190b856b3 --- /dev/null +++ b/arangod/Wal/Logger.cpp @@ -0,0 +1,73 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log logger +/// +/// @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 "Logger.h" +#include "Wal/LogfileManager.h" + +using namespace triagens::wal; + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the logger +//////////////////////////////////////////////////////////////////////////////// + +Logger::Logger (LogfileManager* manager) + : _manager(manager) { +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy the logger +//////////////////////////////////////////////////////////////////////////////// + +Logger::~Logger () { +} + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @brief reserve space in a log file +//////////////////////////////////////////////////////////////////////////////// + +LogEntry Logger::reserve (size_t size) { + LogEntry entry(_manager->reserve(size)); + + return entry; +} + +// ----------------------------------------------------------------------------- +// --SECTION-- private methods +// ----------------------------------------------------------------------------- + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/arangod/Wal/Logger.h b/arangod/Wal/Logger.h new file mode 100644 index 0000000000..d7fe68885b --- /dev/null +++ b/arangod/Wal/Logger.h @@ -0,0 +1,111 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Write-ahead log logger +/// +/// @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 +//////////////////////////////////////////////////////////////////////////////// + +#ifndef TRIAGENS_WAL_LOGGER_H +#define TRIAGENS_WAL_LOGGER_H 1 + +#include "Basics/Common.h" +#include "Wal/LogEntry.h" + +namespace triagens { + namespace wal { + +// ----------------------------------------------------------------------------- +// --SECTION-- class Logger +// ----------------------------------------------------------------------------- + + class LogfileManager; + + class Logger { + +//////////////////////////////////////////////////////////////////////////////// +/// @brief Logger +//////////////////////////////////////////////////////////////////////////////// + + private: + Logger (Logger const&); + Logger& operator= (Logger const&); + +// ----------------------------------------------------------------------------- +// --SECTION-- constructors and destructors +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief create a logger component +//////////////////////////////////////////////////////////////////////////////// + + Logger (LogfileManager*); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destroy a logger component +//////////////////////////////////////////////////////////////////////////////// + + ~Logger (); + +// ----------------------------------------------------------------------------- +// --SECTION-- public methods +// ----------------------------------------------------------------------------- + + public: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief reserve space in a log file +//////////////////////////////////////////////////////////////////////////////// + + LogEntry reserve (size_t); + +// ----------------------------------------------------------------------------- +// --SECTION-- private methods +// ----------------------------------------------------------------------------- + + private: + +// ----------------------------------------------------------------------------- +// --SECTION-- private variables +// ----------------------------------------------------------------------------- + + private: + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the log file manager +//////////////////////////////////////////////////////////////////////////////// + + LogfileManager* _manager; + + }; + + } +} + +#endif + +// Local Variables: +// mode: outline-minor +// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" +// End: diff --git a/js/apps/system/aardvark/frontend/css/databaseView.css b/js/apps/system/aardvark/frontend/css/databaseView.css deleted file mode 100644 index e62b06bbf7..0000000000 --- a/js/apps/system/aardvark/frontend/css/databaseView.css +++ /dev/null @@ -1,89 +0,0 @@ -#databaseDiv { - padding: 13px 5px 0px 5px; -} - -.databaseButtons { - clear:both; - width: 100%; -} - -.databaseButtons #createDatabase { - margin-left: 0; -} - -.databaseButtons { - margin-bottom: 10px; -} - -#databaseTable thead { - text-align: left; -} - -#databaseTable thead tr { - border-bottom: 1px solid #C2C2C2; - background-color: #FFFFFF !important; -} - -#databaseTable { - width: 100%; - margin-bottom: 10px; -} - -#databaseTable .dbThFirst { - width: 90%; -} - -#databaseTable .dbThSecond { - width: 10%; -} - -#databaseTable td.dbThSecond span { - color: #8AA050; -} - -#databaseTable td span { - float: right; - color: #B30000; - font-size: 22px; -} - -#databaseTable td { - padding:12px 18px; -} - -#createDatabaseModal table { - width: 100%; -} - -#databaseTable .collectionThSec { - width: 80%; - margin-right: 0; -} - -#databaseTable .collectionTh { - width: 5%; - margin-right: 0; -} - -.databaseActive { - background-color: #BDCC92 !important; - font-weight: 400; -} - -.databaseActive a { - color: black !important; -} - -.databaseActive span { - display:none; -} - -.databaseInactive a { - color: black !important; -} - -.databaseInactive a:hover { - font-weight: 400; - color: black !important; - cursor: pointer; -} diff --git a/js/apps/system/aardvark/frontend/css/logsView.css b/js/apps/system/aardvark/frontend/css/logsView.css index 9d564af4f1..4fb8955834 100644 --- a/js/apps/system/aardvark/frontend/css/logsView.css +++ b/js/apps/system/aardvark/frontend/css/logsView.css @@ -1,13 +1,3 @@ -#logPages { - float:left; - margin-top: -6px !important; - padding-left: 10px; -} - -#logButtons button { - margin-top: -10px !important; -} - .tab-content { min-height: 390px; } @@ -29,21 +19,6 @@ word-break: break-all; } -#logToolbar { - padding-top: 10px; - padding-bottom: 15px; - border: 1px solid #C1BDBA; - background-color: #F7F6F6 !important; -} - -#logToolbar button { - float:right; - border: medium none; - padding-left: 10px; - background-color: transparent; -} - - #logTableID thead, #infoTableID thead, #debugTableID thead, #critTableID thead, #warnTableID thead { background-color: #F9F9F9; text-align: center; @@ -89,10 +64,6 @@ padding-bottom: 8px; } - -#logTableID_wrapper, #infoTableID_wrapper, #debugTableID_wrapper, #critTableID_wrapper, #warnTableID_wrapper{ -} - #logContent .dataTable { table-layout:fixed !important; border-collapse:separate; diff --git a/js/apps/system/aardvark/frontend/css/queryView.css b/js/apps/system/aardvark/frontend/css/queryView.css deleted file mode 100644 index 22e3aa76b1..0000000000 --- a/js/apps/system/aardvark/frontend/css/queryView.css +++ /dev/null @@ -1,308 +0,0 @@ -.ui-resizable-s { - bottom: 0; - height: 0px; - background-color: #F0F0F0 !important; - border: 1px solid #C0C0C0; - cursor: ns-resize; - line-height: 1; - background-image: url(../img/stripes.gif); - background-repeat:no-repeat; - background-position: 50% 50%; -} - -#queryOutput .ace_cursor-layer { - display:none; -} - -#queryOutput .ui-resizable-handle { - border-left: 0; - border-bottom: 0; - border-top: 0; -} - -.queryToolbar, #aqlEditor { - margin-left: 0px; - margin-right: 0px; - border-width: 1px; - border-style: solid; - border-bottom: 0px; - height: 27px; - background-color: #F0F0F0; - font-size: 20px; -} - -#editorToolbar { - margin-top: 5px; - border-color: #A0A0A0; -} - -#outputToolbar { - position: relative; - width: auto; - border-color: #C0C0C0; -} - -#aqlEditor { - border-bottom: 1px; - width: auto; - border-color: #A0A0A0; - min-width: 99.8%; - height: 200px; - min-height: 100px; - margin-bottom: 5px; -} - -#outputToolbar span, #editorToolbar span { - position: relative; - margin-right: 5px; - margin-left: 5px; - top: 2px; - float:right; -} - -#editorToolbar i:hover, #outputToolbar i:hover { - cursor: pointer; -} - -#editorToolbar i , #outputToolbar i { - margin-right: 5px; - margin-top: 3px; -} - -#editor { - min-width: 100px; -} - -#editorLabel, #outputLabel { - width: 100%; -} - -#editorLabel h6, #outputLabel h6 { - font-family: 'Open Sans', sans-serif; - margin-bottom: 5px; - font-weight: 400; - font-size: 16px; -} - -#aqlEditor .ace_error, #aqlEditor .ace_info, #queryOutput .ace_error, #queryOutput .ace_info { - background:none; -} - -/* -#aqlEditor .ui-resizable-handle { - border-left: 0 !important; - border-bottom: 0 !important; - border-top: 0 !important; -}*/ - -#aqlEditor { - border-left: 0 !important; - border-bottom: 0 !important; - border-top: 0 !important; -} - -#wideButtonDiv { - width: 100%; - height: 20px; - margin-bottom: 15px; - padding-top: 5px; -} - -#submitQueryButton, #clearQueryButton { - float: right; -} - -.querynavbar { - width: 940px !important; - background-color: #FAFAFA; - background-image: linear-gradient(to bottom, #FFFFFF, #F2F2F2); - background-repeat: repeat-x; - margin-bottom: 20px; -} - -.querynavbar h3 { - padding-top: 5px; -} - -#queryOutput { - width: auto; - background-color: white; - height: 200px; - margin-right: 0px; - margin-left: 0px; - margin-bottom: 10px; - min-height: 100px; - overflow-y: hidden; - border: 1px solid #c0c0c0; -} - -.preQuery { - border: 0; - border-radius: 0; - background-color: white !important; -} - -#querySelect { - line-height: 20px !important; - z-index: 9999 !important; - border-radius: 0 !important; - margin-bottom: 0; - border: 0 !important; -} - -#querySelect option { - z-index: 9999 !important; -} - - -.queryTH { - width: 20% !important; -} - -.queryTH2 { - width: 75% !important; -} - -#edit-aql-body table { - margin-left: 0; - width: 100%; -} - -#edit-aql-body select { - width: 100%; -} - -#edit-aql-body textarea { - width: 515px; - resize: vertical !important; -} - -/*#queryOutput .ace_gutter-cell { - color: white; - background-color: #686766 !important; -}*/ - -.ace_print-margin { - visibility: hidden !important; -} - -#queryOutput .ace_replace_form { - display:none; -} - -#editorToolbar .arango-icon-disk, -#commentText, #redoText, #undoText, #clearInput, #clearOutput { - margin-top: 1px; -} - -#shortcutDiv { - float: left; - width: auto; - margin-top: -5px; - padding-left: 45px; -} - - -#queryDiv > * { - border: 0 !important; -} - -.styled-select select { - background: white; - padding: 5px; - font-size: 14px; - font-weight: 300; - line-height: 1; - border: 0; - border-radius: 0; - height: 30px; - padding-left: 5px !important; - padding-top: 3px !important; -} - -.styled-select { - float: right; - width: 220px; - height: 30px; - overflow: hidden; -} - -.querySizeDiv { - margin-right: 10px; - height: 30px !important; - width: 130px !important; -} - -.querySizeDiv select { - height: 30px !important; -} - -#querySize { - width: 130px !important; - line-height: 20px !important; - z-index: 9999 !important; - border-radius: 0 !important; -} - -#queryDropdown { - margin-left: 0; - margin-right: 0; - padding-left: 5px; - padding-right: 5px; - background-color: #D9D9D9; -} - -#queryDropdownIn { - background-color: #FFFFFF; - padding: 10px; -} - -#queryDropdownIn a { - width: 100%; - margin-bottom: 5px; - font-size: 16px; - font-weight: bolder; - color: #686766; -} - -#queryDropdownRight { - width: 100%; -} - -#queryModalSelect { - width: 100%; - padding-left: 0; -} - -#queryDropdownRight textarea { - width: 100%; - padding: 5px 0 0 0px; - resize: vertical; -} - -#queryDropdownRight textarea:focus { - outline: none; - border-color: #8AA051; - box-shadow: 0 0 3px #8AA051; -} - -#queryDropdownLeft { - width: 100%; - margin-top: 10px; -} - -#queryDropdownIn #save-edit-query { - margin-left: 7px !important; -} - -#queryDropdownIn #delete-edit-query { - margin-left: 0 !important; -} - -#queryDiv .icon_arangodb { - margin-bottom: 5px; -} - -#queryDiv .icon_arangodb:hover { - cursor: pointer; -} diff --git a/js/apps/system/aardvark/frontend/img/arangodblogo.png b/js/apps/system/aardvark/frontend/img/arangodblogo.png deleted file mode 100644 index 4f98b5df8c..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/arangodblogo.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/blog.png b/js/apps/system/aardvark/frontend/img/blog.png deleted file mode 100644 index 13a7293e28..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/blog.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/database.gif b/js/apps/system/aardvark/frontend/img/database.gif deleted file mode 100644 index 8db9135a90..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/database.gif and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/delete_icon16.png b/js/apps/system/aardvark/frontend/img/delete_icon16.png deleted file mode 100644 index cf21615d17..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/delete_icon16.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/discuss.png b/js/apps/system/aardvark/frontend/img/discuss.png deleted file mode 100644 index bb6bebdf73..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/discuss.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/doc_delete_icon16.png b/js/apps/system/aardvark/frontend/img/doc_delete_icon16.png deleted file mode 100644 index 0ad48768d8..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/doc_delete_icon16.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/doc_edit_icon16.png b/js/apps/system/aardvark/frontend/img/doc_edit_icon16.png deleted file mode 100644 index 53c0b15ee2..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/doc_edit_icon16.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/download.png b/js/apps/system/aardvark/frontend/img/download.png deleted file mode 100644 index 84ad333093..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/download.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/footer_hd_bg.png b/js/apps/system/aardvark/frontend/img/footer_hd_bg.png deleted file mode 100644 index aca42541c8..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/footer_hd_bg.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/gritter-light.png b/js/apps/system/aardvark/frontend/img/gritter-light.png deleted file mode 100755 index 1b5238efc5..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/gritter-light.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/gritter-long.png b/js/apps/system/aardvark/frontend/img/gritter-long.png deleted file mode 100755 index 578b89104f..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/gritter-long.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/gritter.png b/js/apps/system/aardvark/frontend/img/gritter.png deleted file mode 100755 index 0ca3bc0a0f..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/gritter.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/gv_add.png b/js/apps/system/aardvark/frontend/img/gv_add.png deleted file mode 100644 index f91f3b303c..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/gv_add.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/gv_button_bg.png b/js/apps/system/aardvark/frontend/img/gv_button_bg.png deleted file mode 100644 index cd4fad99a1..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/gv_button_bg.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/gv_connect.png b/js/apps/system/aardvark/frontend/img/gv_connect.png deleted file mode 100644 index 716d8306db..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/gv_connect.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/gv_drag.png b/js/apps/system/aardvark/frontend/img/gv_drag.png deleted file mode 100644 index 0c59e252e0..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/gv_drag.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/gv_edit.png b/js/apps/system/aardvark/frontend/img/gv_edit.png deleted file mode 100644 index 690a86591c..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/gv_edit.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/gv_expand.png b/js/apps/system/aardvark/frontend/img/gv_expand.png deleted file mode 100644 index 40bfea6d44..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/gv_expand.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/gv_trash.png b/js/apps/system/aardvark/frontend/img/gv_trash.png deleted file mode 100644 index 83d2ceb075..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/gv_trash.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/gv_view.png b/js/apps/system/aardvark/frontend/img/gv_view.png deleted file mode 100644 index 7f7c020a9f..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/gv_view.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/icon_add.png b/js/apps/system/aardvark/frontend/img/icon_add.png deleted file mode 100644 index 27226207b9..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/icon_add.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/icon_compass-24.png b/js/apps/system/aardvark/frontend/img/icon_compass-24.png deleted file mode 100644 index 5a7c6e85c5..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/icon_compass-24.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/icon_database-24.png b/js/apps/system/aardvark/frontend/img/icon_database-24.png deleted file mode 100644 index 64b0c6eb79..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/icon_database-24.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/icon_edit.png b/js/apps/system/aardvark/frontend/img/icon_edit.png deleted file mode 100644 index ed44442180..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/icon_edit.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/icon_graph.png b/js/apps/system/aardvark/frontend/img/icon_graph.png deleted file mode 100644 index 4f1d792ed4..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/icon_graph.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/ie-spacer.gif b/js/apps/system/aardvark/frontend/img/ie-spacer.gif deleted file mode 100755 index 5bfd67a2d6..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/ie-spacer.gif and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/logo_arangodb_white.gif b/js/apps/system/aardvark/frontend/img/logo_arangodb_white.gif deleted file mode 100644 index 9c4700f42c..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/logo_arangodb_white.gif and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/multiMachineAsym.png b/js/apps/system/aardvark/frontend/img/multiMachineAsym.png deleted file mode 100644 index 0e904b89ba..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/multiMachineAsym.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/multiMachineSym.png b/js/apps/system/aardvark/frontend/img/multiMachineSym.png deleted file mode 100644 index e61fe6ff55..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/multiMachineSym.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/right_icon.png b/js/apps/system/aardvark/frontend/img/right_icon.png deleted file mode 100644 index 89f4ed41e8..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/right_icon.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/rnd_br_first_icon16.png b/js/apps/system/aardvark/frontend/img/rnd_br_first_icon16.png deleted file mode 100644 index fc964a9998..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/rnd_br_first_icon16.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/rnd_br_last_icon16.png b/js/apps/system/aardvark/frontend/img/rnd_br_last_icon16.png deleted file mode 100644 index 5101fe61b1..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/rnd_br_last_icon16.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/rnd_br_next_icon16.png b/js/apps/system/aardvark/frontend/img/rnd_br_next_icon16.png deleted file mode 100644 index 8c28b09391..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/rnd_br_next_icon16.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/rnd_br_prev_icon16.png b/js/apps/system/aardvark/frontend/img/rnd_br_prev_icon16.png deleted file mode 100644 index 2556721e69..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/rnd_br_prev_icon16.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/saveIcon.png b/js/apps/system/aardvark/frontend/img/saveIcon.png deleted file mode 100644 index c19d634d58..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/saveIcon.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/singleMachine.png b/js/apps/system/aardvark/frontend/img/singleMachine.png deleted file mode 100644 index d984bbca54..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/singleMachine.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/sourceView.png b/js/apps/system/aardvark/frontend/img/sourceView.png deleted file mode 100644 index e0cdcafa2a..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/sourceView.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/sprite.png b/js/apps/system/aardvark/frontend/img/sprite.png deleted file mode 100644 index 2e0c048bb5..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/sprite.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/statusBar-cpu-16.png b/js/apps/system/aardvark/frontend/img/statusBar-cpu-16.png deleted file mode 100644 index 4588dbcecb..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/statusBar-cpu-16.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/statusBar-ram-16.png b/js/apps/system/aardvark/frontend/img/statusBar-ram-16.png deleted file mode 100644 index 297004aca7..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/statusBar-ram-16.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/statusBar-req-16.png b/js/apps/system/aardvark/frontend/img/statusBar-req-16.png deleted file mode 100644 index e015e88c52..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/statusBar-req-16.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/tableView.png b/js/apps/system/aardvark/frontend/img/tableView.png deleted file mode 100644 index 728acf1088..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/tableView.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/img/twitter.png b/js/apps/system/aardvark/frontend/img/twitter.png deleted file mode 100644 index 27df82eafe..0000000000 Binary files a/js/apps/system/aardvark/frontend/img/twitter.png and /dev/null differ diff --git a/js/apps/system/aardvark/frontend/js/templates/queryView.ejs b/js/apps/system/aardvark/frontend/js/templates/queryView.ejs index 26e15ab43b..acfdd156fb 100644 --- a/js/apps/system/aardvark/frontend/js/templates/queryView.ejs +++ b/js/apps/system/aardvark/frontend/js/templates/queryView.ejs @@ -11,13 +11,13 @@
-
-