1
0
Fork 0

engine selection

This commit is contained in:
jsteemann 2016-07-15 12:40:29 +02:00
parent 7742e709a3
commit 87a96ece67
4 changed files with 30 additions and 1 deletions

View File

@ -31,6 +31,8 @@
using namespace arangodb;
using namespace arangodb::options;
StorageEngine* EngineSelectorFeature::ENGINE = nullptr;
EngineSelectorFeature::EngineSelectorFeature(
application_features::ApplicationServer* server)
: ApplicationFeature(server, "EngineSelector"), _engine(MMFilesEngine::EngineName) {
@ -54,15 +56,25 @@ void EngineSelectorFeature::prepare() {
// this is the selected engine
LOG(TRACE) << "enabling storage engine " << engine;
e->enable();
// register storage engine
ENGINE = e;
} else {
// turn off all other storage engines
LOG(TRACE) << "disabling storage engine " << engine;
e->disable();
}
}
TRI_ASSERT(ENGINE != nullptr);
}
// all available storage engines
void EngineSelectorFeature::unprepare() {
// unregister storage engine
ENGINE = nullptr;
}
// return all available storage engines
std::unordered_set<std::string> EngineSelectorFeature::availableEngines() {
return std::unordered_set<std::string>{
MMFilesEngine::EngineName,

View File

@ -27,6 +27,8 @@
#include "ProgramOptions/ProgramOptions.h"
namespace arangodb {
class StorageEngine;
class EngineSelectorFeature final : public application_features::ApplicationFeature {
public:
explicit EngineSelectorFeature(application_features::ApplicationServer* server);
@ -34,8 +36,15 @@ class EngineSelectorFeature final : public application_features::ApplicationFeat
public:
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
void prepare() override final;
void unprepare() override final;
// return the names of all available storage engines
static std::unordered_set<std::string> availableEngines();
public:
// selected storage engine. this will contain a pointer to the storage engine after
// prepare() and before unprepare()
static StorageEngine* ENGINE;
private:
std::string _engine;

View File

@ -22,6 +22,7 @@
////////////////////////////////////////////////////////////////////////////////
#include "MMFilesEngine.h"
#include "StorageEngine/EngineSelectorFeature.h"
using namespace arangodb;
@ -46,17 +47,20 @@ void MMFilesEngine::validateOptions(std::shared_ptr<options::ProgramOptions>) {
// 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 MMFilesEngine::prepare() {
TRI_ASSERT(EngineSelectorFeature::ENGINE = this);
}
// start the engine. now it's allowed to start engine-specific threads,
// write files etc.
void MMFilesEngine::start() {
TRI_ASSERT(EngineSelectorFeature::ENGINE = this);
}
// stop the storage engine. this can be used to flush all data to disk,
// shutdown threads etc. it is guaranteed that there will be no read and
// write requests to the storage engine after this call
void MMFilesEngine::stop() {
TRI_ASSERT(EngineSelectorFeature::ENGINE = this);
}
// fill the Builder object with an array of databases that were detected

View File

@ -22,6 +22,7 @@
////////////////////////////////////////////////////////////////////////////////
#include "OtherEngine.h"
#include "StorageEngine/EngineSelectorFeature.h"
using namespace arangodb;
@ -46,17 +47,20 @@ void OtherEngine::validateOptions(std::shared_ptr<options::ProgramOptions>) {
// 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 OtherEngine::prepare() {
TRI_ASSERT(EngineSelectorFeature::ENGINE = this);
}
// start the engine. now it's allowed to start engine-specific threads,
// write files etc.
void OtherEngine::start() {
TRI_ASSERT(EngineSelectorFeature::ENGINE = this);
}
// stop the storage engine. this can be used to flush all data to disk,
// shutdown threads etc. it is guaranteed that there will be no read and
// write requests to the storage engine after this call
void OtherEngine::stop() {
TRI_ASSERT(EngineSelectorFeature::ENGINE = this);
}
// fill the Builder object with an array of databases that were detected