use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_COMPLETED in project cloudbreak by hortonworks.
the class StackUpdater method doUpdateStackStatus.
private Stack doUpdateStackStatus(Long stackId, Status newStatus, DetailedStackStatus newDetailedStatus, String statusReason) {
Stack stack = stackService.getByIdWithTransaction(stackId);
StackStatus actualStackStatus = stack.getStackStatus();
LOGGER.info("Update stack status from: {}/{} to: {}/{} stack: {} reason: {}", actualStackStatus.getStatus(), actualStackStatus.getDetailedStackStatus(), newStatus, newDetailedStatus, stackId, statusReason);
if (actualStackStatus.getStatus().equals(newStatus)) {
LOGGER.debug("New status is the same as previous status {}/{}, skip status update.", actualStackStatus.getStatus(), actualStackStatus.getDetailedStackStatus());
return stack;
} else if (!stack.isDeleteCompleted()) {
stack.setStackStatus(new StackStatus(stack, newStatus, statusReason, newDetailedStatus));
Cluster cluster = stack.getCluster();
if (newStatus.isRemovableStatus()) {
InMemoryStateStore.deleteStack(stackId);
if (cluster != null) {
InMemoryStateStore.deleteCluster(cluster.getId());
}
} else {
InMemoryStateStore.putStack(stackId, statusToPollGroupConverter.convert(newStatus));
if (cluster != null) {
InMemoryStateStore.putCluster(cluster.getId(), statusToPollGroupConverter.convert(newStatus));
}
}
stack = stackService.save(stack);
saveDeprecatedClusterStatus(statusReason, stack, newStatus);
usageLoggingUtil.logClusterStatusChangeUsageEvent(actualStackStatus.getStatus(), newStatus, cluster);
} else {
LOGGER.info("Stack is in DELETE_COMPLETED status, cannot update status.");
}
return stack;
}
Aggregations