Search in sources :

Example 6 with DatalakeStatusEnum

use of com.sequenceiq.datalake.entity.DatalakeStatusEnum in project cloudbreak by hortonworks.

the class SdxStartActions method failedAction.

@Bean(name = "SDX_START_FAILED_STATE")
public Action<?, ?> failedAction() {
    return new AbstractSdxAction<>(SdxFailedEvent.class) {

        @Override
        protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxFailedEvent payload) {
            return SdxContext.from(flowParameters, payload);
        }

        @Override
        protected void doExecute(SdxContext context, SdxFailedEvent payload, Map<Object, Object> variables) throws Exception {
            Exception exception = payload.getException();
            DatalakeStatusEnum failedStatus = DatalakeStatusEnum.START_FAILED;
            LOGGER.info("Update SDX status to {} for resource: {}", failedStatus, payload.getResourceId(), exception);
            String statusReason = "SDX start failed";
            if (exception.getMessage() != null) {
                statusReason = exception.getMessage();
            }
            SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(failedStatus, statusReason, payload.getResourceId());
            metricService.incrementMetricCounter(MetricType.SDX_START_FAILED, sdxCluster);
            sendEvent(context, SDX_START_FAILED_HANDLED_EVENT.event(), payload);
        }

        @Override
        protected Object getFailurePayload(SdxFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return null;
        }
    };
}
Also used : SdxFailedEvent(com.sequenceiq.datalake.flow.SdxFailedEvent) DatalakeStatusEnum(com.sequenceiq.datalake.entity.DatalakeStatusEnum) FlowParameters(com.sequenceiq.flow.core.FlowParameters) AbstractSdxAction(com.sequenceiq.datalake.service.AbstractSdxAction) Optional(java.util.Optional) StateContext(org.springframework.statemachine.StateContext) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Map(java.util.Map) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Example 7 with DatalakeStatusEnum

use of com.sequenceiq.datalake.entity.DatalakeStatusEnum in project cloudbreak by hortonworks.

the class UpgradeCcmActions method failedAction.

@Bean(name = "UPGRADE_CCM_FAILED_STATE")
public Action<?, ?> failedAction() {
    return new AbstractUpgradeCcmSdxAction<>(UpgradeCcmFailedEvent.class) {

        @Override
        protected void doExecute(SdxContext context, UpgradeCcmFailedEvent payload, Map<Object, Object> variables) {
            Exception exception = payload.getException();
            DatalakeStatusEnum failedStatus = DatalakeStatusEnum.DATALAKE_UPGRADE_CCM_FAILED;
            LOGGER.info("Update SDX status to {} for resource: {}", failedStatus, payload.getResourceId(), exception);
            String statusReason = "Cluster Connectivity Manager upgrade failed";
            if (exception.getMessage() != null) {
                statusReason = exception.getMessage();
            }
            SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(failedStatus, statusReason, payload.getResourceId());
            metricService.incrementMetricCounter(MetricType.UPGRADE_CCM_FAILED, sdxCluster);
            sendEvent(context, UPGRADE_CCM_FAILED_HANDLED_EVENT.event(), payload);
        }
    };
}
Also used : DatalakeStatusEnum(com.sequenceiq.datalake.entity.DatalakeStatusEnum) UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Map(java.util.Map) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Example 8 with DatalakeStatusEnum

use of com.sequenceiq.datalake.entity.DatalakeStatusEnum in project cloudbreak by hortonworks.

the class SdxClusterStatusCheckerJob method syncSdxStatus.

private void syncSdxStatus(JobExecutionContext context) {
    getCluster().ifPresent(sdx -> {
        StackStatusV4Response stack = cloudbreakInternalCrnClient.withInternalCrn().autoscaleEndpoint().getStatusByCrn(getRemoteResourceCrn());
        updateCertExpirationStateIfDifferent(sdx, stack);
        SdxStatusEntity sdxStatus = sdxStatusService.getActualStatusForSdx(sdx);
        DatalakeStatusEnum originalStatus = sdxStatus.getStatus();
        DatalakeStatusEnum updatedStatus = updateStatusIfNecessary(stack, sdx, sdxStatus);
        if (!Objects.equals(originalStatus, updatedStatus)) {
            logStateChange(originalStatus, updatedStatus);
            updateSyncScheduleIfNecessary(updatedStatus, sdx, context);
        }
    });
}
Also used : DatalakeStatusEnum(com.sequenceiq.datalake.entity.DatalakeStatusEnum) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)

Aggregations

DatalakeStatusEnum (com.sequenceiq.datalake.entity.DatalakeStatusEnum)8 SdxContext (com.sequenceiq.datalake.flow.SdxContext)4 Map (java.util.Map)4 Bean (org.springframework.context.annotation.Bean)4 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)3 FlowParameters (com.sequenceiq.flow.core.FlowParameters)3 Optional (java.util.Optional)3 StateContext (org.springframework.statemachine.StateContext)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)2 SdxStatusEntity (com.sequenceiq.datalake.entity.SdxStatusEntity)2 SdxFailedEvent (com.sequenceiq.datalake.flow.SdxFailedEvent)2 Flow (com.sequenceiq.flow.core.Flow)2 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)1 StartDatahubFailedEvent (com.sequenceiq.datalake.flow.datahub.event.StartDatahubFailedEvent)1 UpgradeCcmFailedEvent (com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent)1 FlowChainLog (com.sequenceiq.flow.domain.FlowChainLog)1 FlowLog (com.sequenceiq.flow.domain.FlowLog)1 SdxRecoverableResponse (com.sequenceiq.sdx.api.model.SdxRecoverableResponse)1