Search in sources :

Example 6 with StackStatusV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.

the class SdxClusterStatusCheckerJobTest method setUp.

@BeforeEach
void setUp() {
    underTest.setLocalId(SDX_ID.toString());
    underTest.setRemoteResourceCrn(STACK_ID.toString());
    sdxCluster = new SdxCluster();
    sdxCluster.setClusterName("data-lake-cluster");
    when(sdxClusterRepository.findById(SDX_ID)).thenReturn(Optional.of(sdxCluster));
    stack = new StackStatusV4Response();
    when(cloudbreakInternalCrnClient.withInternalCrn()).thenReturn(cloudbreakServiceCrnEndpoints);
    when(cloudbreakServiceCrnEndpoints.autoscaleEndpoint()).thenReturn(autoscaleV4Endpoint);
    when(autoscaleV4Endpoint.getStatusByCrn(STACK_ID.toString())).thenReturn(stack);
    status = new SdxStatusEntity();
    status.setDatalake(sdxCluster);
    when(sdxStatusService.getActualStatusForSdx(sdxCluster)).thenReturn(status);
    jobDataMap = new JobDataMap();
    when(jobExecutionContext.getMergedJobDataMap()).thenReturn(jobDataMap);
    when(flowLogService.isOtherFlowRunning(any())).thenReturn(false);
}
Also used : JobDataMap(org.quartz.JobDataMap) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with StackStatusV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.

the class CloudbreakPollerTest method statusResponse.

private StackStatusV4Response statusResponse(Status stackStatus, String stackStatusReason) {
    StackStatusV4Response statusV4Response = new StackStatusV4Response();
    statusV4Response.setStatus(stackStatus);
    statusV4Response.setStatusReason(stackStatusReason);
    return statusV4Response;
}
Also used : StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)

Example 8 with StackStatusV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.

the class CloudbreakPoller method getStackResponseAttemptResult.

private AttemptResult<StackStatusV4Response> getStackResponseAttemptResult(String process, SdxCluster sdxCluster, FlowState flowState, Set<Status> targetStatuses, Set<Status> failedStatuses) {
    StackStatusV4Response statusResponse = getStackAndClusterStatusWithInternalActor(sdxCluster);
    LOGGER.info("Response from cloudbreak: {}", statusResponse);
    if (FAILED.equals(flowState)) {
        String message = sdxStatusService.getShortStatusMessage(statusResponse);
        LOGGER.info("{} flow finished, but failed. {}", process, message);
        return failedPolling(process, sdxCluster, message);
    } else if (oneOf(statusResponse.getStatus(), targetStatuses) && oneOf(statusResponse.getClusterStatus(), targetStatuses)) {
        return AttemptResults.finishWith(statusResponse);
    } else if (oneOf(statusResponse.getStatus(), failedStatuses)) {
        LOGGER.info("{} failed. Stack is in {} status.", process, statusResponse.getStatus());
        return failedPolling(process, sdxCluster, statusResponse.getStatusReason());
    } else if (oneOf(statusResponse.getClusterStatus(), failedStatuses)) {
        LOGGER.info("{} failed. Cluster is in {} status.", process, statusResponse.getClusterStatus());
        return failedPolling(process, sdxCluster, statusResponse.getClusterStatusReason());
    } else if (FINISHED.equals(flowState)) {
        String message = sdxStatusService.getShortStatusMessage(statusResponse);
        LOGGER.info("{} flow finished, but stack or cluster is not available. {}", process, message);
        return failedPolling(process, sdxCluster, message);
    } else {
        return AttemptResults.justContinue();
    }
}
Also used : StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)

Example 9 with StackStatusV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.

the class ClusterStatusSyncHandler method onApplicationEvent.

@Override
public void onApplicationEvent(ClusterStatusSyncEvent event) {
    long autoscaleClusterId = event.getClusterId();
    Cluster cluster = clusterService.findById(autoscaleClusterId);
    if (cluster == null) {
        return;
    }
    LoggingUtils.buildMdcContext(cluster);
    StackStatusV4Response statusResponse = cloudbreakCommunicator.getStackStatusByCrn(cluster.getStackCrn());
    boolean clusterAvailable;
    if (Boolean.TRUE.equals(cluster.isStopStartScalingEnabled())) {
        clusterAvailable = Optional.ofNullable(statusResponse.getStatus()).map(Status::isAvailable).orElse(false);
    // TODO CB-15146: This may need to change depending on the final form of how we check which operations are to be allowed
    // when there are some STOPPED instances
    } else {
        clusterAvailable = Optional.ofNullable(statusResponse.getStatus()).map(Status::isAvailable).orElse(false) && Optional.ofNullable(statusResponse.getClusterStatus()).map(Status::isAvailable).orElse(false);
    }
    LOGGER.info("Computed clusterAvailable: {}", clusterAvailable);
    LOGGER.info("Analysing CBCluster Status '{}' for Cluster '{}. Available(Determined)={}' ", statusResponse, cluster.getStackCrn(), clusterAvailable);
    updateClusterState(cluster, statusResponse, clusterAvailable);
}
Also used : Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) Cluster(com.sequenceiq.periscope.domain.Cluster) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)

Example 10 with StackStatusV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.

the class StackToStatusConverter method convert.

public StackStatusV4Response convert(Stack source) {
    StackStatusV4Response response = new StackStatusV4Response();
    response.setId(source.getId());
    response.setStatus(source.getStatus());
    response.setStatusReason(source.getStatusReason());
    Optional<Cluster> cluster = Optional.ofNullable(source.getCluster());
    cluster.ifPresent(c -> response.setClusterStatus(source.getStatus()));
    cluster.ifPresent(c -> response.setClusterStatusReason(source.getStatusReason()));
    response.setCrn(source.getResourceCrn());
    return response;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)

Aggregations

StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)16 Cluster (com.sequenceiq.periscope.domain.Cluster)5 Test (org.junit.Test)4 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)3 ClusterStatusSyncEvent (com.sequenceiq.periscope.monitor.event.ClusterStatusSyncEvent)3 SdxStatusEntity (com.sequenceiq.datalake.entity.SdxStatusEntity)2 ClusterState (com.sequenceiq.periscope.api.model.ClusterState)2 StackV4Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint)1 AutoscaleStackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response)1 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)1 AbstractEntityConverterTest (com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1 DatalakeStatusEnum (com.sequenceiq.datalake.entity.DatalakeStatusEnum)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1