Set<InstanceDescription> newInstances = event.getNewView()
.getInstances();
StringBuilder sb = new StringBuilder();
for (Iterator<InstanceDescription> it = newInstances.iterator(); it
.hasNext();) {
final InstanceDescription newInstanceDescription = it.next();
InstanceDescription oldInstanceDescription = findInstance(
event.getOldView(), newInstanceDescription.getSlingId());
if (oldInstanceDescription == null) {
logger.error("handleTopologyEvent: got a property changed but did not find instance "
+ newInstanceDescription
+ " in oldview.. event="
+ event);
addEventLog(event.getType(), event.getType().toString());
return;
}
Map<String, String> oldProps = oldInstanceDescription
.getProperties();
Map<String, String> newProps = newInstanceDescription
.getProperties();
StringBuilder diff = diff(oldProps, newProps);
if (diff.length() > 0) {
if (sb.length() != 0) {
sb.append(", ");
}
sb.append("on instance "
+ newInstanceDescription.getSlingId() + ": " + diff);
}
}
addEventLog(event.getType(), sb.toString());
} else if (event.getType() == Type.TOPOLOGY_INIT) {
this.currentView = event.getNewView();
StringBuilder details = new StringBuilder();
for (Iterator<InstanceDescription> it = event.getNewView()
.getInstances().iterator(); it.hasNext();) {
InstanceDescription newInstance = it.next();
if (details.length() != 0) {
details.append(", ");
}
details.append(newInstance.getSlingId());
}
addEventLog(event.getType(),
"view: " + shortViewInfo(event.getNewView()) + ". "
+ details);
} else if (event.getType() == Type.TOPOLOGY_CHANGING) {
this.currentView = event.getOldView();
addEventLog(event.getType(),
"old view: " + shortViewInfo(event.getOldView()));
} else {
this.currentView = event.getNewView();
if (event.getOldView() == null) {
addEventLog(event.getType(),
"new view: " + shortViewInfo(event.getNewView()));
} else {
StringBuilder details = new StringBuilder();
for (Iterator<InstanceDescription> it = event.getNewView()
.getInstances().iterator(); it.hasNext();) {
InstanceDescription newInstance = it.next();
if (findInstance(event.getOldView(),
newInstance.getSlingId()) == null) {
if (details.length() != 0) {
details.append(", ");
}
details.append(newInstance.getSlingId() + " joined");
}
}
for (Iterator<InstanceDescription> it = event.getOldView()
.getInstances().iterator(); it.hasNext();) {
InstanceDescription oldInstance = it.next();
if (findInstance(event.getNewView(),
oldInstance.getSlingId()) == null) {
if (details.length() != 0) {
details.append(", ");
}
details.append(oldInstance.getSlingId() + " left");
}
}
addEventLog(
event.getType(),