in src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java [67:118]
public Type compareTopology(final DefaultTopologyView other) {
if (other == null) {
throw new IllegalArgumentException("other must not be null");
}
if ((localClusterSyncTokenId == null && other.localClusterSyncTokenId != null)
|| (other.localClusterSyncTokenId == null && localClusterSyncTokenId != null)
|| (localClusterSyncTokenId != null && !localClusterSyncTokenId.equals(other.localClusterSyncTokenId))) {
logger.debug("compareTopology: different localClusterSyncTokenId");
return Type.TOPOLOGY_CHANGED;
}
if (this.instances.size() != other.instances.size()) {
logger.debug("compareTopology: different number of instances");
return Type.TOPOLOGY_CHANGED;
}
boolean propertiesChanged = false;
for(final InstanceDescription instance : this.instances) {
final Iterator<InstanceDescription> it2 = other.instances.iterator();
InstanceDescription matchingInstance = null;
while (it2.hasNext()) {
final InstanceDescription otherInstance = it2.next();
if (instance.getSlingId().equals(otherInstance.getSlingId())) {
matchingInstance = otherInstance;
break;
}
}
if (matchingInstance == null) {
if (logger.isDebugEnabled()) {
logger.debug("compareTopology: no matching instance found for {}", instance);
}
return Type.TOPOLOGY_CHANGED;
}
if (!instance.getClusterView().getId()
.equals(matchingInstance.getClusterView().getId())) {
logger.debug("compareTopology: cluster view id does not match");
return Type.TOPOLOGY_CHANGED;
}
if (!instance.isLeader()==matchingInstance.isLeader()) {
logger.debug("compareTopology: leaders differ");
return Type.TOPOLOGY_CHANGED;
}
if (!instance.getProperties().equals(
matchingInstance.getProperties())) {
propertiesChanged = true;
}
}
if (propertiesChanged) {
return Type.PROPERTIES_CHANGED;
} else {
return null;
}
}