mirror of https://gitee.com/bigwinds/arangodb
fix startup
This commit is contained in:
parent
1566654fae
commit
f74fe77a40
|
@ -46,24 +46,24 @@ void EngineSelectorFeature::collectOptions(std::shared_ptr<ProgramOptions> optio
|
||||||
|
|
||||||
options->addHiddenOption("--server.storage-engine",
|
options->addHiddenOption("--server.storage-engine",
|
||||||
"storage engine type",
|
"storage engine type",
|
||||||
new DiscreteValuesParameter<StringParameter>(&_engine, availableEngines()));
|
new DiscreteValuesParameter<StringParameter>(&_engine, availableEngineNames()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EngineSelectorFeature::prepare() {
|
void EngineSelectorFeature::prepare() {
|
||||||
// deactivate all engines but the selected one
|
// deactivate all engines but the selected one
|
||||||
for (auto& engine : availableEngines()) {
|
for (auto const& engine : availableEngines()) {
|
||||||
StorageEngine* e = application_features::ApplicationServer::getFeature<StorageEngine>(engine);
|
StorageEngine* e = application_features::ApplicationServer::getFeature<StorageEngine>(engine.second);
|
||||||
|
|
||||||
if (engine == _engine) {
|
if (engine.first == _engine) {
|
||||||
// this is the selected engine
|
// this is the selected engine
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP) << "using storage engine " << engine;
|
LOG_TOPIC(TRACE, Logger::STARTUP) << "using storage engine " << engine.first;
|
||||||
e->enable();
|
e->enable();
|
||||||
|
|
||||||
// register storage engine
|
// register storage engine
|
||||||
ENGINE = e;
|
ENGINE = e;
|
||||||
} else {
|
} else {
|
||||||
// turn off all other storage engines
|
// turn off all other storage engines
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP) << "disabling storage engine " << engine;
|
LOG_TOPIC(TRACE, Logger::STARTUP) << "disabling storage engine " << engine.first;
|
||||||
e->disable();
|
e->disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,9 +76,19 @@ void EngineSelectorFeature::unprepare() {
|
||||||
ENGINE = nullptr;
|
ENGINE = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return the names of all available storage engines
|
||||||
|
std::unordered_set<std::string> EngineSelectorFeature::availableEngineNames() {
|
||||||
|
std::unordered_set<std::string> result;
|
||||||
|
for (auto const& it : availableEngines()) {
|
||||||
|
result.emplace(it.first);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// return all available storage engines
|
// return all available storage engines
|
||||||
std::unordered_set<std::string> EngineSelectorFeature::availableEngines() {
|
std::unordered_map<std::string, std::string> EngineSelectorFeature::availableEngines() {
|
||||||
return std::unordered_set<std::string>{
|
return std::unordered_map<std::string, std::string>{
|
||||||
MMFilesEngine::EngineName, RocksDBEngine::EngineName
|
{MMFilesEngine::EngineName, MMFilesEngine::FeatureName},
|
||||||
|
{RocksDBEngine::EngineName, RocksDBEngine::FeatureName}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,10 @@ class EngineSelectorFeature final : public application_features::ApplicationFeat
|
||||||
void unprepare() override final;
|
void unprepare() override final;
|
||||||
|
|
||||||
// return the names of all available storage engines
|
// return the names of all available storage engines
|
||||||
static std::unordered_set<std::string> availableEngines();
|
static std::unordered_set<std::string> availableEngineNames();
|
||||||
|
|
||||||
|
// return all available storage engines
|
||||||
|
static std::unordered_map<std::string, std::string> availableEngines();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// selected storage engine. this will contain a pointer to the storage engine after
|
// selected storage engine. this will contain a pointer to the storage engine after
|
||||||
|
|
|
@ -115,11 +115,12 @@ struct DatabaseIdStringComparator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const MMFilesEngine::EngineName("MMFiles");
|
std::string const MMFilesEngine::EngineName("mmfiles");
|
||||||
|
std::string const MMFilesEngine::FeatureName("MMFilesEngine");
|
||||||
|
|
||||||
// create the storage engine
|
// create the storage engine
|
||||||
MMFilesEngine::MMFilesEngine(application_features::ApplicationServer* server)
|
MMFilesEngine::MMFilesEngine(application_features::ApplicationServer* server)
|
||||||
: StorageEngine(server, EngineName),
|
: StorageEngine(server, EngineName, FeatureName),
|
||||||
_isUpgrade(false),
|
_isUpgrade(false),
|
||||||
_maxTick(0) {
|
_maxTick(0) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,6 +330,7 @@ class MMFilesEngine final : public StorageEngine {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::string const EngineName;
|
static std::string const EngineName;
|
||||||
|
static std::string const FeatureName;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _basePath;
|
std::string _basePath;
|
||||||
|
|
|
@ -47,11 +47,12 @@
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
|
|
||||||
std::string const RocksDBEngine::EngineName("RocksDB");
|
std::string const RocksDBEngine::EngineName("rocksdb");
|
||||||
|
std::string const RocksDBEngine::FeatureName("RocksDBEngine");
|
||||||
|
|
||||||
// create the storage engine
|
// create the storage engine
|
||||||
RocksDBEngine::RocksDBEngine(application_features::ApplicationServer* server)
|
RocksDBEngine::RocksDBEngine(application_features::ApplicationServer* server)
|
||||||
: StorageEngine(server, EngineName) {
|
: StorageEngine(server, EngineName, FeatureName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RocksDBEngine::~RocksDBEngine() {
|
RocksDBEngine::~RocksDBEngine() {
|
||||||
|
|
|
@ -238,6 +238,7 @@ class RocksDBEngine final : public StorageEngine {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::string const EngineName;
|
static std::string const EngineName;
|
||||||
|
static std::string const FeatureName;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _basePath;
|
std::string _basePath;
|
||||||
|
|
|
@ -42,9 +42,9 @@ class StorageEngine : public application_features::ApplicationFeature {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// create the storage engine
|
// create the storage engine
|
||||||
StorageEngine(application_features::ApplicationServer* server, std::string const& name)
|
StorageEngine(application_features::ApplicationServer* server, std::string const& engineName, std::string const& featureName)
|
||||||
: application_features::ApplicationFeature(server, name), _typeName(name) {
|
: application_features::ApplicationFeature(server, featureName), _typeName(engineName) {
|
||||||
|
|
||||||
// each specific storage engine feature is optional. the storage engine selection feature
|
// each specific storage engine feature is optional. the storage engine selection feature
|
||||||
// will make sure that exactly one engine is selected at startup
|
// will make sure that exactly one engine is selected at startup
|
||||||
setOptional(true);
|
setOptional(true);
|
||||||
|
|
|
@ -2816,6 +2816,7 @@ static void JS_DatafilesVocbaseCol(
|
||||||
|
|
||||||
TRI_THROW_SHARDING_COLLECTION_NOT_YET_IMPLEMENTED(collection);
|
TRI_THROW_SHARDING_COLLECTION_NOT_YET_IMPLEMENTED(collection);
|
||||||
|
|
||||||
|
// TODO: move this into engine
|
||||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
if (std::string(engine->typeName()) != MMFilesEngine::EngineName) {
|
if (std::string(engine->typeName()) != MMFilesEngine::EngineName) {
|
||||||
TRI_V8_THROW_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "operation only supported in MMFiles engine");
|
TRI_V8_THROW_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "operation only supported in MMFiles engine");
|
||||||
|
@ -2827,7 +2828,7 @@ static void JS_DatafilesVocbaseCol(
|
||||||
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_UNLOADED);
|
TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_UNLOADED);
|
||||||
}
|
}
|
||||||
|
|
||||||
MMFilesEngineCollectionFiles structure= dynamic_cast<MMFilesEngine*>(engine)->scanCollectionDirectory(collection->path());
|
MMFilesEngineCollectionFiles structure = dynamic_cast<MMFilesEngine*>(engine)->scanCollectionDirectory(collection->path());
|
||||||
|
|
||||||
// build result
|
// build result
|
||||||
v8::Handle<v8::Object> result = v8::Object::New(isolate);
|
v8::Handle<v8::Object> result = v8::Object::New(isolate);
|
||||||
|
|
|
@ -116,7 +116,7 @@ LogfileManager::LogfileManager(ApplicationServer* server)
|
||||||
startsAfter("RevisionCache");
|
startsAfter("RevisionCache");
|
||||||
|
|
||||||
for (auto const& it : EngineSelectorFeature::availableEngines()) {
|
for (auto const& it : EngineSelectorFeature::availableEngines()) {
|
||||||
startsAfter(it);
|
startsAfter(it.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue