mirror of https://gitee.com/bigwinds/arangodb
no commlockers in ClusterFeature anymore
This commit is contained in:
parent
2cceb1bdea
commit
d55c85f8fa
|
@ -417,32 +417,24 @@ void ClusterFeature::start() {
|
|||
AgencyCommResult result;
|
||||
|
||||
while (true) {
|
||||
AgencyCommLocker locker("Current", "WRITE");
|
||||
bool success = locker.successful();
|
||||
|
||||
if (success) {
|
||||
VPackBuilder builder;
|
||||
try {
|
||||
VPackObjectBuilder b(&builder);
|
||||
builder.add("endpoint", VPackValue(_myAddress));
|
||||
} catch (...) {
|
||||
locker.unlock();
|
||||
LOG(FATAL) << "out of memory";
|
||||
FATAL_ERROR_EXIT();
|
||||
}
|
||||
|
||||
result = comm.setValue("Current/ServersRegistered/" + _myId,
|
||||
builder.slice(), 0.0);
|
||||
}
|
||||
|
||||
if (!result.successful()) {
|
||||
locker.unlock();
|
||||
LOG(FATAL) << "unable to register server in agency: http code: "
|
||||
<< result.httpCode() << ", body: " << result.body();
|
||||
VPackBuilder builder;
|
||||
try {
|
||||
VPackObjectBuilder b(&builder);
|
||||
builder.add("endpoint", VPackValue(_myAddress));
|
||||
} catch (...) {
|
||||
LOG(FATAL) << "out of memory";
|
||||
FATAL_ERROR_EXIT();
|
||||
}
|
||||
|
||||
if (success) {
|
||||
result = comm.setValue("Current/ServersRegistered/" + _myId,
|
||||
builder.slice(), 0.0);
|
||||
|
||||
if (!result.successful()) {
|
||||
LOG(FATAL) << "unable to register server in agency: http code: "
|
||||
<< result.httpCode() << ", body: " << result.body();
|
||||
FATAL_ERROR_EXIT();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -502,26 +494,31 @@ void ClusterFeature::unprepare() {
|
|||
AgencyComm comm;
|
||||
comm.sendServerState(0.0);
|
||||
|
||||
{
|
||||
// Try only once to unregister because maybe the agencycomm
|
||||
// is shutting down as well...
|
||||
AgencyCommLocker locker("Current", "WRITE", 120.0, 1.000);
|
||||
// Try only once to unregister because maybe the agencycomm
|
||||
// is shutting down as well...
|
||||
|
||||
if (locker.successful()) {
|
||||
// unregister ourselves
|
||||
ServerState::RoleEnum role = ServerState::instance()->getRole();
|
||||
ServerState::RoleEnum role = ServerState::instance()->getRole();
|
||||
|
||||
if (role == ServerState::ROLE_PRIMARY) {
|
||||
comm.removeValues("Current/DBServers/" + _myId, false);
|
||||
} else if (role == ServerState::ROLE_COORDINATOR) {
|
||||
comm.removeValues("Current/Coordinators/" + _myId, false);
|
||||
}
|
||||
AgencyWriteTransaction unreg;
|
||||
|
||||
// unregister ourselves
|
||||
comm.removeValues("Current/ServersRegistered/" + _myId, false);
|
||||
}
|
||||
// Remove from role
|
||||
if (role == ServerState::ROLE_PRIMARY) {
|
||||
unreg.operations.push_back(
|
||||
AgencyOperation("Current/DBServers/" + _myId,
|
||||
AgencySimpleOperationType::DELETE_OP));
|
||||
} else if (role == ServerState::ROLE_COORDINATOR) {
|
||||
unreg.operations.push_back(
|
||||
AgencyOperation("Current/Coordinators/" + _myId,
|
||||
AgencySimpleOperationType::DELETE_OP));
|
||||
}
|
||||
|
||||
// Unregister
|
||||
unreg.operations.push_back(
|
||||
AgencyOperation("Current/ServersRegistered/" + _myId,
|
||||
AgencySimpleOperationType::DELETE_OP));
|
||||
|
||||
comm.sendTransactionWithFailover(unreg, 120.0);
|
||||
|
||||
while (_heartbeatThread->isRunning()) {
|
||||
usleep(50000);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue