1
0
Fork 0

allow passing a serverId value of "none" to replication APIs (#3909)

This commit is contained in:
Jan 2017-12-08 11:35:53 +01:00 committed by GitHub
parent 715e9567f9
commit eb0190066b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 20 deletions

View File

@ -61,8 +61,8 @@ void MMFilesRestReplicationHandler::insertClient(
bool found;
std::string const& value = _request->value("serverId", found);
if (found) {
TRI_server_id_t serverId = (TRI_server_id_t)StringUtils::uint64(value);
if (found && !value.empty() && value != "none") {
TRI_server_id_t serverId = static_cast<TRI_server_id_t>(StringUtils::uint64(value));
if (serverId > 0) {
_vocbase->updateReplicationClient(serverId, lastServedTick);

View File

@ -1361,6 +1361,7 @@ void RocksDBEngine::pruneWalFiles() {
/* no hoisting */) {
// check if WAL file is expired
if ((*it).second < TRI_microtime()) {
LOG_TOPIC(DEBUG, Logger::ROCKSDB) << "deleting RocksDB WAL file '" << (*it).first << "'";
auto s = _db->DeleteFile((*it).first);
// apparently there is a case where a file was already deleted
// but is still in _prunableWalFiles. In this case we get an invalid

View File

@ -87,16 +87,21 @@ void RocksDBRestReplicationHandler::handleCommandBatch() {
// add client
bool found;
std::string const& value = _request->value("serverId", found);
TRI_server_id_t serverId = 0;
if (found) {
serverId = (TRI_server_id_t)StringUtils::uint64(value);
} else {
serverId = ctx->id();
if (!found) {
LOG_TOPIC(DEBUG, Logger::FIXME) << "no serverId parameter found in request to " << _request->fullUrl();
}
if (!found || (!value.empty() && value != "none")) {
TRI_server_id_t serverId = 0;
_vocbase->updateReplicationClient(serverId, ctx->lastTick());
if (found) {
serverId = static_cast<TRI_server_id_t>(StringUtils::uint64(value));
} else {
serverId = ctx->id();
}
_vocbase->updateReplicationClient(serverId, ctx->lastTick());
}
generateResult(rest::ResponseCode::OK, b.slice());
return;
}
@ -134,16 +139,21 @@ void RocksDBRestReplicationHandler::handleCommandBatch() {
// add client
bool found;
std::string const& value = _request->value("serverId", found);
TRI_server_id_t serverId = 0;
if (found) {
serverId = (TRI_server_id_t)StringUtils::uint64(value);
} else {
serverId = ctx->id();
if (!found) {
LOG_TOPIC(DEBUG, Logger::FIXME) << "no serverId parameter found in request to " << _request->fullUrl();
}
if (!found || (!value.empty() && value != "none")) {
TRI_server_id_t serverId = 0;
_vocbase->updateReplicationClient(serverId, ctx->lastTick());
if (found) {
serverId = static_cast<TRI_server_id_t>(StringUtils::uint64(value));
} else {
serverId = ctx->id();
}
_vocbase->updateReplicationClient(serverId, ctx->lastTick());
}
resetResponse(rest::ResponseCode::NO_CONTENT);
return;
}
@ -314,11 +324,10 @@ void RocksDBRestReplicationHandler::handleCommandLoggerFollow() {
bool found;
std::string const& value = _request->value("serverId", found);
TRI_server_id_t serverId = 0;
if (found) {
serverId = (TRI_server_id_t)StringUtils::uint64(value);
if (!found || (!value.empty() && value != "none")) {
TRI_server_id_t serverId = static_cast<TRI_server_id_t>(StringUtils::uint64(value));
_vocbase->updateReplicationClient(serverId, result.maxTick());
}
_vocbase->updateReplicationClient(serverId, result.maxTick());
}
}