@Autowired
private InstanceMetaDataRepository metadataRepository;
@Override
public void accept(Event<UpdateAmbariHostsSuccess> event) {
UpdateAmbariHostsSuccess data = event.getData();
Cluster cluster = clusterRepository.findById(data.getClusterId());
Set<String> hostNames = data.getHostNames();
MDCBuilder.buildMdcContext(cluster);
LOGGER.info("Accepted {} event.", ReactorConfig.UPDATE_AMBARI_HOSTS_SUCCESS_EVENT);
Stack stack = stackRepository.findStackWithListsForCluster(data.getClusterId());
for (String hostName : hostNames) {
InstanceMetaData metadataEntry = metadataRepository.findHostInStack(stack.getId(), hostName);
if (data.isDecommision()) {
metadataEntry.setRemovable(true);
} else {
metadataEntry.setRemovable(false);
}
metadataRepository.save(metadataEntry);
}
stackUpdater.updateStackStatus(stack.getId(), Status.AVAILABLE, "");
websocketService.sendToTopicUser(cluster.getOwner(), WebsocketEndPoint.CLUSTER,
new StatusMessage(data.getClusterId(), cluster.getName(), Status.AVAILABLE.name()));
}