Search in sources :

Example 46 with Status

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

the class StackUpdater method saveDeprecatedClusterStatus.

private void saveDeprecatedClusterStatus(String statusReason, Stack stack, Status newStatus) {
    Cluster cluster = stack.getCluster();
    if (cluster != null) {
        Status previous = cluster.getStatus();
        LOGGER.debug("Update deprecated cluster status from: {} to: {} reason: {} cluster: {}", previous, newStatus, statusReason, cluster.getId());
        cluster.setStatus(newStatus);
        cluster.setStatusReason(statusReason);
        clusterService.save(cluster);
    }
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)

Example 47 with Status

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

the class ClusterCommonService method saveAndFireEventOnClusterStatusChange.

private void saveAndFireEventOnClusterStatusChange(Stack stack, DetailedStackStatus newDetailedStackStatus, ResourceEvent event) {
    Status actualStatus = stack.getStatus();
    if (!actualStatus.equals(newDetailedStackStatus.getStatus())) {
        clusterService.updateClusterStatusByStackId(stack.getId(), newDetailedStackStatus);
        cloudbreakEventService.fireCloudbreakEvent(stack.getId(), event.name(), event);
    }
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) EnvironmentStatus(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus) MaintenanceModeStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.MaintenanceModeStatus)

Example 48 with Status

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

the class LoadBalancerPollerService method periodicCheckForCompletion.

private AttemptResult<List<FlowIdentifier>> periodicCheckForCompletion(List<FlowIdentifier> flowIdentifiers) {
    try {
        boolean anyFlowsActive = false;
        for (FlowIdentifier flowIdentifier : flowIdentifiers) {
            Boolean hasActiveFlow = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> flowEndpoint.hasFlowRunningByFlowId(flowIdentifier.getPollableId()).getHasActiveFlow());
            if (hasActiveFlow) {
                LOGGER.debug("Flow {} is still running", flowIdentifier.getPollableId());
            } else {
                LOGGER.debug("Flow {} is complete", flowIdentifier.getPollableId());
            }
            anyFlowsActive = anyFlowsActive || hasActiveFlow;
        }
        if (anyFlowsActive) {
            return AttemptResults.justContinue();
        } else {
            List<FlowIdentifier> failedFlows = flowIdentifiers.stream().filter(flowId -> hasFlowFailed(ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> flowEndpoint.getFlowLogsByFlowId(flowId.getPollableId())))).collect(Collectors.toList());
            return AttemptResults.finishWith(failedFlows);
        }
    } catch (Exception e) {
        LOGGER.warn("Failure checking status of flows {}, error is: {}", flowIdentifiers, e.getMessage());
        return AttemptResults.breakFor(e);
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) UpdateFailedException(com.sequenceiq.environment.exception.UpdateFailedException) Value(org.springframework.beans.factory.annotation.Value) AttemptResults(com.dyngr.core.AttemptResults) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Service(org.springframework.stereotype.Service) PublicEndpointAccessGateway(com.sequenceiq.common.api.type.PublicEndpointAccessGateway) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) AttemptResult(com.dyngr.core.AttemptResult) FlowLogResponse(com.sequenceiq.flow.api.model.FlowLogResponse) SdxService(com.sequenceiq.environment.environment.service.sdx.SdxService) DatahubService(com.sequenceiq.environment.environment.service.datahub.DatahubService) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Logger(org.slf4j.Logger) FlowEndpoint(com.sequenceiq.flow.api.FlowEndpoint) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) RegionAwareInternalCrnGeneratorFactory(com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Polling(com.dyngr.Polling) Stream(java.util.stream.Stream) StackService(com.sequenceiq.environment.environment.service.stack.StackService) PollerStoppedException(com.dyngr.exception.PollerStoppedException) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) UpdateFailedException(com.sequenceiq.environment.exception.UpdateFailedException) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 49 with Status

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

the class ClusterStatusUpdater method updateClusterStatus.

private boolean updateClusterStatus(Stack stack, ClusterStatus clusterStatus) {
    boolean result = false;
    Cluster cluster = stack.getCluster();
    Status actualStatus = stack.getStatus();
    DetailedStackStatus newDetailedStackStatus = clusterStatus.getDetailedStackStatus();
    Status newStatus = newDetailedStackStatus.getStatus();
    if (actualStatus != newStatus) {
        if (!actualStatus.equals(Status.MAINTENANCE_MODE_ENABLED) || !newStatus.equals(Status.AVAILABLE)) {
            LOGGER.debug("Cluster {} status is updated from {} to {}/{}", cluster.getId(), actualStatus, newStatus, newDetailedStackStatus);
            clusterService.updateClusterStatusByStackId(stack.getId(), newDetailedStackStatus, clusterStatus.getStatusReason());
            result = true;
        }
    } else {
        LOGGER.debug("Cluster {} status hasn't changed: {}", cluster.getId(), actualStatus);
    }
    return result;
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) ClusterStatus(com.sequenceiq.cloudbreak.cluster.status.ClusterStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)

Example 50 with Status

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

the class UpgradePreconditionServiceTest method createClusterResponse.

private ClusterViewV4Response createClusterResponse(Status clusterStatus, BlueprintBasedUpgradeOption upgradeable) {
    ClusterViewV4Response dataHubCluster = new ClusterViewV4Response();
    dataHubCluster.setStatus(clusterStatus);
    BlueprintV4ViewResponse blueprint = new BlueprintV4ViewResponse();
    blueprint.setUpgradeable(upgradeable);
    dataHubCluster.setBlueprint(blueprint);
    return dataHubCluster;
}
Also used : BlueprintV4ViewResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4ViewResponse) ClusterViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response)

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