// Return if topology has not been initialized
if (!topology.isInitialized())
return false;
// Parse complete message and build event
ServiceRemovedEvent event = (ServiceRemovedEvent) Util.jsonToObject(message, ServiceRemovedEvent.class);
// Apply service filter
if (TopologyServiceFilter.getInstance().isActive()) {
if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) {
// Service is excluded, do not update topology or fire event
if (log.isDebugEnabled()) {
log.debug(String.format("Service is excluded: [service] %s", event.getServiceName()));
}
return false;
}
}
// Validate event against the existing topology
Service service = topology.getService(event.getServiceName());
if (service == null) {
if (log.isWarnEnabled()) {
log.warn(String.format("Service does not exist: [service] %s",
event.getServiceName()));
}
} else {
// Apply changes to the topology
topology.removeService(service);
if (log.isInfoEnabled()) {
log.info(String.format("Service removed: [service] %s", event.getServiceName()));
}
}
// Notify event listeners