in wrapper/src/main/java/software/amazon/jdbc/PluginServiceImpl.java [545:583]
void setNodeList(@Nullable final List<HostSpec> oldHosts,
@Nullable final List<HostSpec> newHosts) {
final Map<String, HostSpec> oldHostMap = oldHosts == null
? new HashMap<>()
: oldHosts.stream().collect(Collectors.toMap(HostSpec::getUrl, (value) -> value));
final Map<String, HostSpec> newHostMap = newHosts == null
? new HashMap<>()
: newHosts.stream().collect(Collectors.toMap(HostSpec::getUrl, (value) -> value));
final Map<String, EnumSet<NodeChangeOptions>> changes = new HashMap<>();
for (final Entry<String, HostSpec> entry : oldHostMap.entrySet()) {
final HostSpec correspondingNewHost = newHostMap.get(entry.getKey());
if (correspondingNewHost == null) {
// host deleted
changes.put(entry.getKey(), EnumSet.of(NodeChangeOptions.NODE_DELETED));
} else {
// host maybe changed
final EnumSet<NodeChangeOptions> hostChanges = compare(entry.getValue(), correspondingNewHost);
if (!hostChanges.isEmpty()) {
changes.put(entry.getKey(), hostChanges);
}
}
}
for (final Entry<String, HostSpec> entry : newHostMap.entrySet()) {
if (!oldHostMap.containsKey(entry.getKey())) {
// host added
changes.put(entry.getKey(), EnumSet.of(NodeChangeOptions.NODE_ADDED));
}
}
if (!changes.isEmpty()) {
this.allHosts = newHosts != null ? newHosts : new ArrayList<>();
this.pluginManager.notifyNodeListChanged(changes);
}
}