1
0
Fork 0

Merge branch 'devel' of github.com:arangodb/arangodb into devel

This commit is contained in:
hkernbach 2016-06-22 19:03:29 +02:00
commit a10ce3888c
1 changed files with 41 additions and 44 deletions

View File

@ -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();
FATAL_ERROR_EXIT();
}
if (success) {
} else {
break;
}
@ -502,25 +494,30 @@ 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);
if (locker.successful()) {
// unregister ourselves
ServerState::RoleEnum role = ServerState::instance()->getRole();
AgencyWriteTransaction unreg;
// Remove from role
if (role == ServerState::ROLE_PRIMARY) {
comm.removeValues("Current/DBServers/" + _myId, false);
unreg.operations.push_back(
AgencyOperation("Current/DBServers/" + _myId,
AgencySimpleOperationType::DELETE_OP));
} else if (role == ServerState::ROLE_COORDINATOR) {
comm.removeValues("Current/Coordinators/" + _myId, false);
unreg.operations.push_back(
AgencyOperation("Current/Coordinators/" + _myId,
AgencySimpleOperationType::DELETE_OP));
}
// unregister ourselves
comm.removeValues("Current/ServersRegistered/" + _myId, false);
}
}
// Unregister
unreg.operations.push_back(
AgencyOperation("Current/ServersRegistered/" + _myId,
AgencySimpleOperationType::DELETE_OP));
comm.sendTransactionWithFailover(unreg, 120.0);
while (_heartbeatThread->isRunning()) {
usleep(50000);