mirror of https://gitee.com/bigwinds/arangodb
added static helper methods for cluster state
This commit is contained in:
parent
7a81b43082
commit
343c9b4bea
|
@ -227,8 +227,10 @@ void Collection::fillIndexes () const {
|
|||
if (! indexes.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto const role = triagens::arango::ServerState::instance()->getRole();
|
||||
|
||||
if (triagens::arango::ServerState::instance()->isCoordinator()) {
|
||||
if (triagens::arango::ServerState::instance()->isCoordinator(role)) {
|
||||
fillIndexesCoordinator();
|
||||
return;
|
||||
}
|
||||
|
@ -236,7 +238,7 @@ void Collection::fillIndexes () const {
|
|||
// must have a collection
|
||||
TRI_ASSERT(collection != nullptr);
|
||||
|
||||
if (triagens::arango::ServerState::instance()->isDBServer() &&
|
||||
if (triagens::arango::ServerState::instance()->isDBServer(role) &&
|
||||
documentCollection()->_info._planId > 0) {
|
||||
fillIndexesDBServer();
|
||||
return;
|
||||
|
|
|
@ -901,8 +901,9 @@ ExecutionEngine* ExecutionEngine::instanciateFromPlan (QueryRegistry* queryRegis
|
|||
Query* query,
|
||||
ExecutionPlan* plan,
|
||||
bool planRegisters) {
|
||||
bool const isCoordinator = triagens::arango::ServerState::instance()->isCoordinator();
|
||||
bool const isDBServer = triagens::arango::ServerState::instance()->isDBServer();
|
||||
auto role = triagens::arango::ServerState::instance()->getRole();
|
||||
bool const isCoordinator = triagens::arango::ServerState::instance()->isCoordinator(role);
|
||||
bool const isDBServer = triagens::arango::ServerState::instance()->isDBServer(role);
|
||||
|
||||
ExecutionEngine* engine = nullptr;
|
||||
|
||||
|
|
|
@ -491,15 +491,18 @@ bool HeartbeatThread::handlePlanChangeCoordinator (uint64_t currentPlanVersion,
|
|||
++it;
|
||||
}
|
||||
|
||||
// get the list of databases that we know about locally
|
||||
TRI_voc_tick_t* localIds = TRI_GetIdsCoordinatorDatabaseServer(_server);
|
||||
|
||||
if (localIds != nullptr) {
|
||||
TRI_voc_tick_t* p = localIds;
|
||||
|
||||
// now check which of the local databases are also in the plan
|
||||
while (*p != 0) {
|
||||
std::vector<TRI_voc_tick_t>::const_iterator r = std::find(ids.begin(), ids.end(), *p);
|
||||
|
||||
if (r == ids.end()) {
|
||||
// local database not found in the plan...
|
||||
TRI_DropByIdCoordinatorDatabaseServer(_server, *p, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ ServerState* ServerState::instance () {
|
|||
/// @brief get the string representation of a role
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string ServerState::roleToString (RoleEnum role) {
|
||||
std::string ServerState::roleToString (ServerState::RoleEnum role) {
|
||||
switch (role) {
|
||||
case ROLE_UNDEFINED:
|
||||
return "UNDEFINED";
|
||||
|
@ -238,7 +238,15 @@ bool ServerState::isCoordinator () {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether the server is a DB server (primary or secondory)
|
||||
/// @brief check whether the server is a coordinator
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool ServerState::isCoordinator (ServerState::RoleEnum role) {
|
||||
return (role == ServerState::ROLE_COORDINATOR);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether the server is a DB server (primary or secondary)
|
||||
/// running in cluster mode.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -249,6 +257,16 @@ bool ServerState::isDBServer () {
|
|||
role == ServerState::ROLE_SECONDARY);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether the server is a DB server (primary or secondary)
|
||||
/// running in cluster mode.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool ServerState::isDBServer (ServerState::RoleEnum role) {
|
||||
return (role == ServerState::ROLE_PRIMARY ||
|
||||
role == ServerState::ROLE_SECONDARY);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether the server is running in a cluster
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -316,7 +334,7 @@ ServerState::RoleEnum ServerState::getRole () {
|
|||
/// @brief set the server role
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ServerState::setRole (RoleEnum role) {
|
||||
void ServerState::setRole (ServerState::RoleEnum role) {
|
||||
storeRole(role);
|
||||
}
|
||||
|
||||
|
|
|
@ -188,12 +188,25 @@ namespace triagens {
|
|||
bool isCoordinator ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether the server is a DB server (primary or secondory)
|
||||
/// @brief check whether the server is a coordinator
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool isCoordinator (RoleEnum);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether the server is a DB server (primary or secondary)
|
||||
/// running in cluster mode.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool isDBServer ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether the server is a DB server (primary or secondary)
|
||||
/// running in cluster mode.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool isDBServer (RoleEnum);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether the server is running in a cluster
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -986,7 +986,9 @@ int ArangoServer::startupServer () {
|
|||
// for a cluster coordinator, the users are loaded at a later stage;
|
||||
// the kickstarter will trigger a bootstrap process
|
||||
//
|
||||
if (role != ServerState::ROLE_COORDINATOR && role != ServerState::ROLE_PRIMARY && role != ServerState::ROLE_SECONDARY) {
|
||||
if (role != ServerState::ROLE_COORDINATOR &&
|
||||
role != ServerState::ROLE_PRIMARY &&
|
||||
role != ServerState::ROLE_SECONDARY) {
|
||||
|
||||
// if the authentication info could not be loaded, but authentication is turned on,
|
||||
// then we refuse to start
|
||||
|
|
Loading…
Reference in New Issue