mirror of https://gitee.com/bigwinds/arangodb
Clean up code without changing behaviour.
This commit is contained in:
parent
95a165d5f4
commit
f62042ef3a
|
@ -2360,35 +2360,19 @@ void ClusterInfo::loadCurrentDBServers() {
|
||||||
|
|
||||||
std::vector<ServerID> ClusterInfo::getCurrentDBServers() {
|
std::vector<ServerID> ClusterInfo::getCurrentDBServers() {
|
||||||
std::vector<ServerID> result;
|
std::vector<ServerID> result;
|
||||||
int tries = 0;
|
|
||||||
|
|
||||||
if (!_DBServersProt.isValid) {
|
if (!_DBServersProt.isValid) {
|
||||||
loadCurrentDBServers();
|
loadCurrentDBServers();
|
||||||
tries++;
|
|
||||||
}
|
}
|
||||||
while (true) {
|
// return a consistent state of servers
|
||||||
{
|
READ_LOCKER(readLocker, _DBServersProt.lock);
|
||||||
// return a consistent state of servers
|
|
||||||
READ_LOCKER(readLocker, _DBServersProt.lock);
|
|
||||||
|
|
||||||
result.reserve(_DBServers.size());
|
result.reserve(_DBServers.size());
|
||||||
|
|
||||||
for (auto& it : _DBServers) {
|
for (auto& it : _DBServers) {
|
||||||
result.emplace_back(it.first);
|
result.emplace_back(it.first);
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (++tries >= 2) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// loadCurrentDBServers needs the write lock
|
|
||||||
loadCurrentDBServers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// note that the result will be empty if we get here
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2560,35 +2544,20 @@ int ClusterInfo::getResponsibleShard(LogicalCollection* collInfo,
|
||||||
|
|
||||||
std::vector<ServerID> ClusterInfo::getCurrentCoordinators() {
|
std::vector<ServerID> ClusterInfo::getCurrentCoordinators() {
|
||||||
std::vector<ServerID> result;
|
std::vector<ServerID> result;
|
||||||
int tries = 0;
|
|
||||||
|
|
||||||
if (!_coordinatorsProt.isValid) {
|
if (!_coordinatorsProt.isValid) {
|
||||||
loadCurrentCoordinators();
|
loadCurrentCoordinators();
|
||||||
tries++;
|
|
||||||
}
|
|
||||||
while (true) {
|
|
||||||
{
|
|
||||||
// return a consistent state of servers
|
|
||||||
READ_LOCKER(readLocker, _coordinatorsProt.lock);
|
|
||||||
|
|
||||||
result.reserve(_coordinators.size());
|
|
||||||
|
|
||||||
for (auto& it : _coordinators) {
|
|
||||||
result.emplace_back(it.first);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (++tries >= 2) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// loadCurrentCoordinators needs the write lock
|
|
||||||
loadCurrentCoordinators();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// note that the result will be empty if we get here
|
// return a consistent state of servers
|
||||||
|
READ_LOCKER(readLocker, _coordinatorsProt.lock);
|
||||||
|
|
||||||
|
result.reserve(_coordinators.size());
|
||||||
|
|
||||||
|
for (auto& it : _coordinators) {
|
||||||
|
result.emplace_back(it.first);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue