use of com.torodb.mongodb.commands.pojos.MemberConfig in project torodb by torodb.
the class TopologyCoordinator method updateHeartbeatDataForReconfig.
/**
* Updates {@link #_hbdata} based on the newConfig, ensuring that every member in the newConfig
* has an entry in _hbdata.
* <p>
* If any nodes in the newConfig are also present in {@link #_currentConfig}, copies their
* heartbeat info into the corresponding entry in the updated _hbdata vector.
*/
private void updateHeartbeatDataForReconfig(ReplicaSetConfig newConfig, Instant now) {
if (newConfig == null) {
return;
}
List<MemberHeartbeatData> oldHeartbeats = _hbdata;
_hbdata = new ArrayList<>(newConfig.getMembers().size());
for (int index = 0; index < newConfig.getMembers().size(); index++) {
MemberConfig newMemberConfig = newConfig.getMembers().get(index);
MemberHeartbeatData newHeartbeatData = new MemberHeartbeatData();
if (_rsConfig != null) {
for (int oldIndex = 0; oldIndex < _rsConfig.getMembers().size(); oldIndex++) {
MemberConfig oldMemberConfig = _rsConfig.getMembers().get(oldIndex);
if (oldMemberConfig.getId() == newMemberConfig.getId() && oldMemberConfig.getHostAndPort().equals(newMemberConfig.getHostAndPort())) {
// This member existed in the old config with the same member ID and
// HostAndPort, so copy its heartbeat data over.
newHeartbeatData = oldHeartbeats.get(oldIndex);
break;
}
}
}
_hbdata.add(newHeartbeatData);
}
}
Aggregations