Search in sources :

Example 1 with DELETE_COMPLETED

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;
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1