mirror of https://gitee.com/bigwinds/arangodb
Applied suggestions.
This commit is contained in:
parent
b1f14c3a3c
commit
87dd009e0d
|
@ -1302,16 +1302,17 @@ bool HeartbeatThread::sendServerState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeartbeatThread::updateAgentPool(VPackSlice const& agentPool) {
|
void HeartbeatThread::updateAgentPool(VPackSlice const& agentPool) {
|
||||||
if (agentPool.isObject() && agentPool.get("pool").isObject() &&
|
if (agentPool.isObject() && agentPool.get("pool").isObject() && agentPool.hasKey("size") &&
|
||||||
agentPool.hasKey("size") && agentPool.get("size").getUInt() > 0) {
|
agentPool.get("size").getUInt() > 0 && agentPool.get("id").isString()) {
|
||||||
try {
|
try {
|
||||||
std::vector<std::string> values;
|
std::vector<std::string> values;
|
||||||
// we have to make sure that the leader is on the front
|
// we have to make sure that the leader is on the front
|
||||||
auto leaderId = agentPool.get("id").stringRef();
|
auto leaderId = agentPool.get("id").stringRef();
|
||||||
auto pool = agentPool.get("pool");
|
auto pool = agentPool.get("pool");
|
||||||
|
values.reserve(pool.length());
|
||||||
values.emplace_back(pool.get(leaderId).copyString());
|
values.emplace_back(pool.get(leaderId).copyString());
|
||||||
// now add all non leaders
|
// now add all non leaders
|
||||||
for (auto pair : VPackObjectIterator(agentPool.get("pool"))) {
|
for (auto pair : VPackObjectIterator(pool)) {
|
||||||
if (!pair.key.isEqualString(leaderId)) {
|
if (!pair.key.isEqualString(leaderId)) {
|
||||||
values.emplace_back(pair.value.copyString());
|
values.emplace_back(pair.value.copyString());
|
||||||
}
|
}
|
||||||
|
@ -1319,15 +1320,15 @@ void HeartbeatThread::updateAgentPool(VPackSlice const& agentPool) {
|
||||||
AgencyCommManager::MANAGER->updateEndpoints(values);
|
AgencyCommManager::MANAGER->updateEndpoints(values);
|
||||||
} catch (basics::Exception const& e) {
|
} catch (basics::Exception const& e) {
|
||||||
LOG_TOPIC("1cec6", WARN, Logger::HEARTBEAT)
|
LOG_TOPIC("1cec6", WARN, Logger::HEARTBEAT)
|
||||||
<< "Error updating agency pool: " << e.message();
|
<< "Error updating agency pool: " << e.message();
|
||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
LOG_TOPIC("889d4", WARN, Logger::HEARTBEAT)
|
LOG_TOPIC("889d4", WARN, Logger::HEARTBEAT)
|
||||||
<< "Error updating agency pool: " << e.what();
|
<< "Error updating agency pool: " << e.what();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_TOPIC("92522", ERR, Logger::AGENCYCOMM)
|
LOG_TOPIC("92522", ERR, Logger::AGENCYCOMM)
|
||||||
<< "Cannot find an agency persisted in RAFT 8|";
|
<< "Cannot find an agency persisted in RAFT 8|";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue