mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into devel
This commit is contained in:
commit
f80b36b6ff
|
@ -414,7 +414,8 @@ void Constituent::run() {
|
||||||
std::vector<std::string> act = _agent->config().active();
|
std::vector<std::string> act = _agent->config().active();
|
||||||
while (!this->isStopping() && ((size_t)(find(act.begin(), act.end(), _id) -
|
while (!this->isStopping() && ((size_t)(find(act.begin(), act.end(), _id) -
|
||||||
act.begin()) >= size())) {
|
act.begin()) >= size())) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
CONDITION_LOCKER(guardv, _cv);
|
||||||
|
_cv.wait(5000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size() == 1) {
|
if (size() == 1) {
|
||||||
|
@ -428,33 +429,33 @@ void Constituent::run() {
|
||||||
MUTEX_LOCKER(guard, _castLock);
|
MUTEX_LOCKER(guard, _castLock);
|
||||||
_cast = false; // New round set not cast vote
|
_cast = false; // New round set not cast vote
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t left = static_cast<int32_t>(1000000.0 *
|
int32_t left = static_cast<int32_t>(1000000.0 *
|
||||||
_agent->config().minPing()),
|
_agent->config().minPing()),
|
||||||
right = static_cast<int32_t>(1000000.0 *
|
right = static_cast<int32_t>(1000000.0 *
|
||||||
_agent->config().maxPing());
|
_agent->config().maxPing());
|
||||||
long rand_wait =
|
long rand_wait =
|
||||||
static_cast<long>(RandomGenerator::interval(left, right));
|
static_cast<long>(RandomGenerator::interval(left, right));
|
||||||
|
|
||||||
{
|
{
|
||||||
CONDITION_LOCKER(guardv, _cv);
|
CONDITION_LOCKER(guardv, _cv);
|
||||||
_cv.wait(rand_wait);
|
_cv.wait(rand_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
MUTEX_LOCKER(guard, _castLock);
|
MUTEX_LOCKER(guard, _castLock);
|
||||||
cast = _cast;
|
cast = _cast;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cast) {
|
if (!cast) {
|
||||||
candidate(); // Next round, we are running
|
candidate(); // Next round, we are running
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (_role == CANDIDATE) {
|
} else if (_role == CANDIDATE) {
|
||||||
callElection(); // Run for office
|
callElection(); // Run for office
|
||||||
} else {
|
} else {
|
||||||
int32_t left =
|
int32_t left =
|
||||||
static_cast<int32_t>(100000.0 * _agent->config().minPing());
|
static_cast<int32_t>(100000.0 * _agent->config().minPing());
|
||||||
long rand_wait = static_cast<long>(left);
|
long rand_wait = static_cast<long>(left);
|
||||||
{
|
{
|
||||||
CONDITION_LOCKER(guardv, _cv);
|
CONDITION_LOCKER(guardv, _cv);
|
||||||
|
|
|
@ -1226,6 +1226,8 @@ function shutdownInstance (instanceInfo, options) {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
let bar = '[';
|
let bar = '[';
|
||||||
|
|
||||||
|
var shutdownTime = require('internal').time();
|
||||||
|
|
||||||
let toShutdown = instanceInfo.arangods.slice();
|
let toShutdown = instanceInfo.arangods.slice();
|
||||||
while (toShutdown.length > 0) {
|
while (toShutdown.length > 0) {
|
||||||
// Once all other servers are shut down, we take care of the agents,
|
// Once all other servers are shut down, we take care of the agents,
|
||||||
|
@ -1241,13 +1243,8 @@ function shutdownInstance (instanceInfo, options) {
|
||||||
arangod.exitStatus = statusExternal(arangod.pid, false);
|
arangod.exitStatus = statusExternal(arangod.pid, false);
|
||||||
|
|
||||||
if (arangod.exitStatus.status === 'RUNNING') {
|
if (arangod.exitStatus.status === 'RUNNING') {
|
||||||
++count;
|
|
||||||
|
|
||||||
if (count % 10 === 0) {
|
if ((require('internal').time() - shutdownTime) > timeout) {
|
||||||
bar = bar + '#';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count > timeout) {
|
|
||||||
print('forcefully terminating ' + yaml.safeDump(arangod.pid) +
|
print('forcefully terminating ' + yaml.safeDump(arangod.pid) +
|
||||||
' after ' + timeout + 's grace period; marking crashy.');
|
' after ' + timeout + 's grace period; marking crashy.');
|
||||||
serverCrashed = true;
|
serverCrashed = true;
|
||||||
|
|
Loading…
Reference in New Issue