use of com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.TERMINATED in project cloudbreak by hortonworks.
the class MetadataSetupService method cleanupRequestedInstancesWithoutFQDN.
public void cleanupRequestedInstancesWithoutFQDN(Long stackId, Set<String> instanceGroups) {
try {
transactionService.required(() -> {
for (String instanceGroupName : instanceGroups) {
Optional<InstanceGroup> ig = instanceGroupService.findOneWithInstanceMetadataByGroupNameInStack(stackId, instanceGroupName);
if (ig.isPresent()) {
List<InstanceMetaData> requestedInstances = instanceMetaDataService.findAllByInstanceGroupAndInstanceStatus(ig.get(), InstanceStatus.REQUESTED);
List<InstanceMetaData> requestedInstancesWithoutFQDN = requestedInstances.stream().filter(instanceMetaData -> instanceMetaData.getDiscoveryFQDN() == null).collect(Collectors.toList());
LOGGER.info("Set requested instances without FQDN to terminated: {}", requestedInstancesWithoutFQDN);
for (InstanceMetaData inst : requestedInstancesWithoutFQDN) {
inst.setTerminationDate(clock.getCurrentTimeMillis());
inst.setInstanceStatus(InstanceStatus.TERMINATED);
}
instanceMetaDataService.saveAll(requestedInstances);
}
}
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
Aggregations