1
0
Fork 0

Register version and storage engine info in agency to facilitate rolling upgrades (#6062)

This commit is contained in:
Dan Larkin-York 2018-08-03 03:46:42 -04:00 committed by Jan
parent 1ffcfd63ba
commit fc7976b92d
2 changed files with 42 additions and 25 deletions

View File

@ -35,10 +35,12 @@
#include "Logger/Logger.h" #include "Logger/Logger.h"
#include "ProgramOptions/ProgramOptions.h" #include "ProgramOptions/ProgramOptions.h"
#include "ProgramOptions/Section.h" #include "ProgramOptions/Section.h"
#include "Rest/Version.h"
#include "RestServer/DatabaseFeature.h" #include "RestServer/DatabaseFeature.h"
#include "Scheduler/Scheduler.h" #include "Scheduler/Scheduler.h"
#include "Scheduler/SchedulerFeature.h" #include "Scheduler/SchedulerFeature.h"
#include "SimpleHttpClient/ConnectionManager.h" #include "SimpleHttpClient/ConnectionManager.h"
#include "StorageEngine/EngineSelectorFeature.h"
#include "V8Server/V8DealerFeature.h" #include "V8Server/V8DealerFeature.h"
using namespace arangodb; using namespace arangodb;
@ -79,10 +81,10 @@ void ClusterFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
options->addSection("cluster", "Configure the cluster"); options->addSection("cluster", "Configure the cluster");
options->addObsoleteOption("--cluster.username", options->addObsoleteOption("--cluster.username",
"username used for cluster-internal communication", "username used for cluster-internal communication",
true); true);
options->addObsoleteOption("--cluster.password", options->addObsoleteOption("--cluster.password",
"password used for cluster-internal communication", "password used for cluster-internal communication",
true); true);
options->addObsoleteOption("--cluster.disable-dispatcher-kickstarter", options->addObsoleteOption("--cluster.disable-dispatcher-kickstarter",
"The dispatcher feature isn't available anymore; Use ArangoDBStarter for this now!", "The dispatcher feature isn't available anymore; Use ArangoDBStarter for this now!",
@ -105,7 +107,7 @@ void ClusterFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
options->addObsoleteOption("--cluster.arangod-path", options->addObsoleteOption("--cluster.arangod-path",
"path to the arangod for the cluster", "path to the arangod for the cluster",
true); true);
options->addOption("--cluster.agency-endpoint", options->addOption("--cluster.agency-endpoint",
"agency endpoint to connect to", "agency endpoint to connect to",
new VectorParameter<StringParameter>(&_agencyEndpoints)); new VectorParameter<StringParameter>(&_agencyEndpoints));
@ -132,7 +134,7 @@ void ClusterFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
options->addHiddenOption("--cluster.create-waits-for-sync-replication", options->addHiddenOption("--cluster.create-waits-for-sync-replication",
"active coordinator will wait for all replicas to create collection", "active coordinator will wait for all replicas to create collection",
new BooleanParameter(&_createWaitsForSyncReplication)); new BooleanParameter(&_createWaitsForSyncReplication));
options->addHiddenOption("--cluster.index-create-timeout", options->addHiddenOption("--cluster.index-create-timeout",
"amount of time (in seconds) the coordinator will wait for an index to be created before giving up", "amount of time (in seconds) the coordinator will wait for an index to be created before giving up",
new DoubleParameter(&_indexCreationTimeout)); new DoubleParameter(&_indexCreationTimeout));
@ -145,7 +147,7 @@ void ClusterFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
<< "The dispatcher feature isn't available anymore. Use ArangoDBStarter for this now! See https://github.com/arangodb-helper/ArangoDBStarter/ for more details."; << "The dispatcher feature isn't available anymore. Use ArangoDBStarter for this now! See https://github.com/arangodb-helper/ArangoDBStarter/ for more details.";
FATAL_ERROR_EXIT(); FATAL_ERROR_EXIT();
} }
// check if the cluster is enabled // check if the cluster is enabled
_enableCluster = !_agencyEndpoints.empty(); _enableCluster = !_agencyEndpoints.empty();
@ -200,8 +202,8 @@ void ClusterFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
if (!_myRole.empty()) { if (!_myRole.empty()) {
_requestedRole = ServerState::stringToRole(_myRole); _requestedRole = ServerState::stringToRole(_myRole);
std::vector<arangodb::ServerState::RoleEnum> const disallowedRoles= { std::vector<arangodb::ServerState::RoleEnum> const disallowedRoles= {
/*ServerState::ROLE_SINGLE,*/ ServerState::ROLE_AGENT, ServerState::ROLE_UNDEFINED /*ServerState::ROLE_SINGLE,*/ ServerState::ROLE_AGENT, ServerState::ROLE_UNDEFINED
}; };
if (std::find(disallowedRoles.begin(), disallowedRoles.end(), _requestedRole) != disallowedRoles.end()) { if (std::find(disallowedRoles.begin(), disallowedRoles.end(), _requestedRole) != disallowedRoles.end()) {
@ -276,7 +278,7 @@ void ClusterFeature::prepare() {
// register the prefix with the communicator // register the prefix with the communicator
AgencyCommManager::initialize(_agencyPrefix); AgencyCommManager::initialize(_agencyPrefix);
TRI_ASSERT(AgencyCommManager::MANAGER != nullptr); TRI_ASSERT(AgencyCommManager::MANAGER != nullptr);
for (size_t i = 0; i < _agencyEndpoints.size(); ++i) { for (size_t i = 0; i < _agencyEndpoints.size(); ++i) {
std::string const unified = Endpoint::unifiedForm(_agencyEndpoints[i]); std::string const unified = Endpoint::unifiedForm(_agencyEndpoints[i]);
@ -312,8 +314,8 @@ void ClusterFeature::prepare() {
auto role = ServerState::instance()->getRole(); auto role = ServerState::instance()->getRole();
auto endpoints = AgencyCommManager::MANAGER->endpointsString(); auto endpoints = AgencyCommManager::MANAGER->endpointsString();
if (role == ServerState::ROLE_UNDEFINED) { if (role == ServerState::ROLE_UNDEFINED) {
// no role found // no role found
LOG_TOPIC(FATAL, arangodb::Logger::CLUSTER) << "unable to determine unambiguous role for server '" LOG_TOPIC(FATAL, arangodb::Logger::CLUSTER) << "unable to determine unambiguous role for server '"
@ -337,7 +339,7 @@ void ClusterFeature::prepare() {
auto ci = ClusterInfo::instance(); auto ci = ClusterInfo::instance();
double start = TRI_microtime(); double start = TRI_microtime();
while (true) { while (true) {
LOG_TOPIC(INFO, arangodb::Logger::CLUSTER) << "Waiting for DBservers to show up..."; LOG_TOPIC(INFO, arangodb::Logger::CLUSTER) << "Waiting for DBservers to show up...";
ci->loadCurrentDBServers(); ci->loadCurrentDBServers();
@ -349,7 +351,7 @@ void ClusterFeature::prepare() {
} }
sleep(1); sleep(1);
} }
} }
if (_myAddress.empty()) { if (_myAddress.empty()) {
@ -366,7 +368,7 @@ void ClusterFeature::prepare() {
<< "' specified for --cluster.my-address"; << "' specified for --cluster.my-address";
FATAL_ERROR_EXIT(); FATAL_ERROR_EXIT();
} }
} }
void ClusterFeature::start() { void ClusterFeature::start() {
@ -445,6 +447,8 @@ void ClusterFeature::start() {
VPackObjectBuilder b(&builder); VPackObjectBuilder b(&builder);
builder.add("endpoint", VPackValue(_myAddress)); builder.add("endpoint", VPackValue(_myAddress));
builder.add("host", VPackValue(ServerState::instance()->getHost())); builder.add("host", VPackValue(ServerState::instance()->getHost()));
builder.add("version", VPackValue(rest::Version::getNumericServerVersion()));
builder.add("storageEngine", VPackValue(EngineSelectorFeature::engineName()));
} catch (...) { } catch (...) {
LOG_TOPIC(FATAL, arangodb::Logger::CLUSTER) << "out of memory"; LOG_TOPIC(FATAL, arangodb::Logger::CLUSTER) << "out of memory";
FATAL_ERROR_EXIT(); FATAL_ERROR_EXIT();
@ -477,7 +481,7 @@ void ClusterFeature::stop() {
if (_heartbeatThread != nullptr) { if (_heartbeatThread != nullptr) {
_heartbeatThread->beginShutdown(); _heartbeatThread->beginShutdown();
} }
if (_heartbeatThread != nullptr) { if (_heartbeatThread != nullptr) {
int counter = 0; int counter = 0;
while (_heartbeatThread->isRunning()) { while (_heartbeatThread->isRunning()) {
@ -540,7 +544,7 @@ void ClusterFeature::unprepare() {
ServerState::RoleEnum role = ServerState::instance()->getRole(); ServerState::RoleEnum role = ServerState::instance()->getRole();
std::string alk = ServerState::roleToAgencyListKey(role); std::string alk = ServerState::roleToAgencyListKey(role);
std::string me = ServerState::instance()->getId(); std::string me = ServerState::instance()->getId();
AgencyWriteTransaction unreg; AgencyWriteTransaction unreg;
unreg.operations.push_back(AgencyOperation("Current/" + alk + "/" + me, unreg.operations.push_back(AgencyOperation("Current/" + alk + "/" + me,
AgencySimpleOperationType::DELETE_OP)); AgencySimpleOperationType::DELETE_OP));

View File

@ -47,7 +47,7 @@
using namespace arangodb::rest; using namespace arangodb::rest;
std::map<std::string, std::string> Version::Values; std::map<std::string, std::string> Version::Values;
/// @brief parse a version string into major, minor /// @brief parse a version string into major, minor
/// returns -1, -1 when the version string has an invalid format /// returns -1, -1 when the version string has an invalid format
/// returns major, -1 when only the major version can be determined /// returns major, -1 when only the major version can be determined
@ -75,7 +75,7 @@ std::pair<int, int> Version::parseVersionString(std::string const& str) {
result.second = std::stoi(std::string(p, q - p)); result.second = std::stoi(std::string(p, q - p));
} }
} }
} }
return result; return result;
} }
@ -191,7 +191,7 @@ void Version::initialize() {
#else #else
Values["fd-client-event-handler"] = "select"; Values["fd-client-event-handler"] = "select";
#endif #endif
for (auto& it : Values) { for (auto& it : Values) {
arangodb::basics::StringUtils::trimInPlace(it.second); arangodb::basics::StringUtils::trimInPlace(it.second);
} }
@ -220,7 +220,21 @@ int32_t Version::getNumericServerVersion() {
TRI_ASSERT((*p == '.' || *p == '-' || *p == '\0') && p != apiVersion); TRI_ASSERT((*p == '.' || *p == '-' || *p == '\0') && p != apiVersion);
int32_t minor = TRI_Int32String(apiVersion, (p - apiVersion)); int32_t minor = TRI_Int32String(apiVersion, (p - apiVersion));
return (int32_t)(minor * 100L + major * 10000L); int32_t patch = 0;
if (*p == '.') {
apiVersion = ++p;
// read minor version
while (*p >= '0' && *p <= '9') {
++p;
}
if (p != apiVersion) {
patch = TRI_Int32String(apiVersion, (p - apiVersion));
}
}
return (int32_t)(patch + minor * 100L + major * 10000L);
} }
/// @brief get server version /// @brief get server version
@ -249,7 +263,7 @@ std::string Version::getBoostReactorType() {
return std::string("select"); return std::string("select");
#endif #endif
} }
/// @brief get RocksDB version /// @brief get RocksDB version
std::string Version::getRocksDBVersion() { std::string Version::getRocksDBVersion() {
return std::to_string(ROCKSDB_MAJOR) + "." + std::to_string(ROCKSDB_MINOR) + "." + std::to_string(ROCKSDB_PATCH); return std::to_string(ROCKSDB_MAJOR) + "." + std::to_string(ROCKSDB_MINOR) + "." + std::to_string(ROCKSDB_PATCH);
@ -321,7 +335,7 @@ std::string Version::getEndianness() {
if (p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78 && p[4] == 0xab && p[5] == 0xcd && p[6] == 0xef && p[7] == 0x99) { if (p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78 && p[4] == 0xab && p[5] == 0xcd && p[6] == 0xef && p[7] == 0x99) {
return "big"; return "big";
} }
if (p[0] == 0x99 && p[1] == 0xef && p[2] == 0xcd && p[3] == 0xab && p[4] == 0x78 && p[5] == 0x56 && p[6] == 0x34 && p[7] == 0x12) { if (p[0] == 0x99 && p[1] == 0xef && p[2] == 0xcd && p[3] == 0xab && p[4] == 0x78 && p[5] == 0x56 && p[6] == 0x34 && p[7] == 0x12) {
return "little"; return "little";
} }
@ -363,13 +377,13 @@ std::string Version::getVerboseVersionString() {
#ifdef ARANGODB_HAVE_JEMALLOC #ifdef ARANGODB_HAVE_JEMALLOC
<< "jemalloc, " << "jemalloc, "
#endif #endif
#ifdef HAVE_ARANGODB_BUILD_REPOSITORY #ifdef HAVE_ARANGODB_BUILD_REPOSITORY
<< "build " << getBuildRepository() << ", " << "build " << getBuildRepository() << ", "
#endif #endif
<< "VPack " << getVPackVersion() << ", " << "VPack " << getVPackVersion() << ", "
<< "RocksDB " << getRocksDBVersion() << ", " << "RocksDB " << getRocksDBVersion() << ", "
<< "ICU " << getICUVersion() << ", " << "ICU " << getICUVersion() << ", "
<< "V8 " << getV8Version() << ", " << "V8 " << getV8Version() << ", "
<< getOpenSSLVersion(); << getOpenSSLVersion();
return version.str(); return version.str();
@ -409,4 +423,3 @@ void Version::getVPack(VPackBuilder& dst) {
} }
} }
} }