Search in sources :

Example 56 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class ProvisionerService method waitCloudbreakClusterDeletion.

public void waitCloudbreakClusterDeletion(Long id, PollingConfig pollingConfig) {
    SdxCluster sdxCluster = sdxService.getById(id);
    AtomicInteger deleteFailedCount = new AtomicInteger(1);
    Polling.waitPeriodly(pollingConfig.getSleepTime(), pollingConfig.getSleepTimeUnit()).stopIfException(pollingConfig.getStopPollingIfExceptionOccurred()).stopAfterDelay(pollingConfig.getDuration(), pollingConfig.getDurationTimeUnit()).run(() -> {
        LOGGER.info("Deletion polling cloudbreak for stack status: '{}' in '{}' env", sdxCluster.getClusterName(), sdxCluster.getEnvName());
        try {
            StackV4Response stackV4Response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.get(0L, sdxCluster.getClusterName(), Collections.emptySet(), sdxCluster.getAccountId()));
            LOGGER.info("Stack status of SDX {} by response from cloudbreak: {}", sdxCluster.getClusterName(), stackV4Response.getStatus().name());
            LOGGER.debug("Response from cloudbreak: {}", JsonUtil.writeValueAsString(stackV4Response));
            ClusterV4Response cluster = stackV4Response.getCluster();
            if (cluster != null) {
                if (StatusKind.PROGRESS.equals(cluster.getStatus().getStatusKind())) {
                    return AttemptResults.justContinue();
                }
                if (Status.DELETE_FAILED.equals(cluster.getStatus())) {
                    // if it is implemented, please remove this
                    if (deleteFailedCount.getAndIncrement() >= DELETE_FAILED_RETRY_COUNT) {
                        LOGGER.error("Cluster deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getCluster().getStatusReason());
                        return AttemptResults.breakFor("Data Lake deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getCluster().getStatusReason());
                    } else {
                        return AttemptResults.justContinue();
                    }
                }
            }
            if (Status.DELETE_FAILED.equals(stackV4Response.getStatus())) {
                // if it is implemented, please remove this
                if (deleteFailedCount.getAndIncrement() >= DELETE_FAILED_RETRY_COUNT) {
                    LOGGER.error("Stack deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getStatusReason());
                    return AttemptResults.breakFor("Data Lake deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getStatusReason());
                } else {
                    return AttemptResults.justContinue();
                }
            } else {
                return AttemptResults.justContinue();
            }
        } catch (NotFoundException e) {
            return AttemptResults.finishWith(null);
        }
    });
    sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.STACK_DELETED, "Datalake stack deleted", sdxCluster);
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) NotFoundException(javax.ws.rs.NotFoundException)

Example 57 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class SdxClusterStatusCheckerJob method isNodeFailure.

private boolean isNodeFailure(StackStatusV4Response stack) {
    Status stackStatus = stack.getStatus();
    Status clusterStatus = stack.getClusterStatus();
    return stackStatus == Status.NODE_FAILURE || (stackStatus == Status.AVAILABLE && clusterStatus == Status.NODE_FAILURE);
}
Also used : Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)

Example 58 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class ClusterDeleteHandlerTest method getStackResponse.

private StackStatusV4Response getStackResponse(Status clusterStatus) {
    StackStatusV4Response stackResponse = new StackStatusV4Response();
    stackResponse.setStatus(clusterStatus);
    stackResponse.setClusterStatus(clusterStatus);
    return stackResponse;
}
Also used : StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)

Example 59 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class MetricTest method getStackResponse.

private StackV4Response getStackResponse(Status stackStatus, Status clusterStatus) {
    StackV4Response stackResponse = new StackV4Response();
    stackResponse.setStatus(stackStatus);
    stackResponse.setCluster(new ClusterV4Response());
    stackResponse.getCluster().setStatus(clusterStatus);
    return stackResponse;
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)

Example 60 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class ClusterDeleteHandler method onApplicationEvent.

@Override
public void onApplicationEvent(ClusterDeleteEvent event) {
    Cluster cluster = clusterService.findById(event.getClusterId());
    if (cluster == null) {
        return;
    }
    LoggingUtils.buildMdcContext(cluster);
    StackStatusV4Response statusResponse = cloudbreakCommunicator.getStackStatusByCrn(cluster.getStackCrn());
    if (DELETE_COMPLETED.equals(statusResponse.getStatus())) {
        beforeDeleteCleanup(cluster);
        clusterService.removeById(event.getClusterId());
        LOGGER.info("Deleted cluster: {}, CB Stack status: {}", cluster.getStackCrn(), statusResponse.getStatus());
    }
}
Also used : Cluster(com.sequenceiq.periscope.domain.Cluster) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)

Aggregations

DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)23 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)22 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)18 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)12 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)9 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)7 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)7 Map (java.util.Map)7 Collectors (java.util.stream.Collectors)7 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)6 Collection (java.util.Collection)6 List (java.util.List)6 Set (java.util.Set)6 Inject (javax.inject.Inject)6 PollerStoppedException (com.dyngr.exception.PollerStoppedException)5 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)5 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)5