From 949985dff1bcc8bc7100efbbd69d1ea0d13cef31 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Tue, 4 Apr 2017 12:03:29 +0200 Subject: [PATCH] report a path, make it restartable --- arangod/RocksDBEngine/RocksDBEngine.cpp | 12 ++++++++++-- arangod/RocksDBEngine/RocksDBEngine.h | 1 + js/server/upgrade-database.js | 13 +++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/arangod/RocksDBEngine/RocksDBEngine.cpp b/arangod/RocksDBEngine/RocksDBEngine.cpp index 54c26bd118..339b13750c 100644 --- a/arangod/RocksDBEngine/RocksDBEngine.cpp +++ b/arangod/RocksDBEngine/RocksDBEngine.cpp @@ -92,7 +92,15 @@ void RocksDBEngine::validateOptions(std::shared_ptr) {} // preparation phase for storage engine. can be used for internal setup. // the storage engine must not start any threads here or write any files -void RocksDBEngine::prepare() {} +void RocksDBEngine::prepare() { + // get base path from DatabaseServerFeature + auto databasePathFeature = + application_features::ApplicationServer::getFeature( + "DatabasePath"); + _basePath = databasePathFeature->directory(); + + TRI_ASSERT(!_basePath.empty()); +} void RocksDBEngine::start() { // it is already decided that rocksdb is used @@ -342,7 +350,7 @@ int RocksDBEngine::getViews(TRI_vocbase_t* vocbase, } std::string RocksDBEngine::databasePath(TRI_vocbase_t const* vocbase) const { - return std::string(); // no path to be returned here! + return _basePath; } std::string RocksDBEngine::collectionPath(TRI_vocbase_t const* vocbase, diff --git a/arangod/RocksDBEngine/RocksDBEngine.h b/arangod/RocksDBEngine/RocksDBEngine.h index d03511cdb9..7beafe7e8c 100644 --- a/arangod/RocksDBEngine/RocksDBEngine.h +++ b/arangod/RocksDBEngine/RocksDBEngine.h @@ -260,6 +260,7 @@ class RocksDBEngine final : public StorageEngine { rocksdb::Options _options; std::unique_ptr _cmp; std::string _path; + std::string _basePath; std::unique_ptr _counterManager; }; diff --git a/js/server/upgrade-database.js b/js/server/upgrade-database.js index c16f142199..81311c8311 100644 --- a/js/server/upgrade-database.js +++ b/js/server/upgrade-database.js @@ -94,10 +94,7 @@ constant2name[DATABASE_EXISTING] = 'existing'; // path to version file - let versionFile; - if (internal.db._path()) { - versionFile = internal.db._path() + '/VERSION'; - } + let versionFile = internal.db._path() + '/VERSION'; // all defined tasks const allTasks = []; @@ -287,7 +284,7 @@ lastTasks[task.name] = true; // save/update version info - if (isLocal && versionFile) { + if (isLocal) { fs.write( versionFile, JSON.stringify({ @@ -303,7 +300,7 @@ } // save file so version gets saved even if there are no tasks - if (isLocal && versionFile) { + if (isLocal) { fs.write( versionFile, JSON.stringify({ @@ -350,7 +347,7 @@ } // VERSION file exists, read its contents - if (versionFile && fs.exists(versionFile)) { + if (fs.exists(versionFile)) { var versionInfo = fs.read(versionFile); if (versionInfo === '') { @@ -490,7 +487,7 @@ return false; } - if (db._engine().name != "rocksdb") { + if (db._engine().name !== "rocksdb") { users.ensureIndex({ type: 'hash', fields: ['user'],