Search in sources :

Example 1 with SdxRepairFailedEvent

use of com.sequenceiq.datalake.flow.repair.event.SdxRepairFailedEvent in project cloudbreak by hortonworks.

the class SdxRepairWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SdxRepairWaitRequest> event) {
    SdxRepairWaitRequest sdxRepairWaitRequest = event.getData();
    Long sdxId = sdxRepairWaitRequest.getResourceId();
    String userId = sdxRepairWaitRequest.getUserId();
    Selectable response;
    try {
        LOGGER.debug("Start polling stack repair process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        repairService.waitCloudbreakClusterRepair(sdxId, pollingConfig);
        response = new SdxRepairSuccessEvent(sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Repair polling exited before timeout. Cause: ", userBreakException);
        response = new SdxRepairFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Repair poller stopped for stack: {}", sdxId);
        response = new SdxRepairFailedEvent(sdxId, userId, new PollerStoppedException("Datalake repair timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Repair polling failed for stack: {}", sdxId);
        response = new SdxRepairFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) SdxRepairFailedEvent(com.sequenceiq.datalake.flow.repair.event.SdxRepairFailedEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) SdxRepairSuccessEvent(com.sequenceiq.datalake.flow.repair.event.SdxRepairSuccessEvent) SdxRepairWaitRequest(com.sequenceiq.datalake.flow.repair.event.SdxRepairWaitRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 2 with SdxRepairFailedEvent

use of com.sequenceiq.datalake.flow.repair.event.SdxRepairFailedEvent in project cloudbreak by hortonworks.

the class SdxRepairActions method failedAction.

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

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

        @Override
        protected void doExecute(SdxContext context, SdxRepairFailedEvent payload, Map<Object, Object> variables) throws Exception {
            Exception exception = payload.getException();
            LOGGER.error("Datalake repair failed for datalakeId: {}", payload.getResourceId(), exception);
            String statusReason = "Datalake stack repair failed";
            if (exception.getMessage() != null) {
                statusReason = exception.getMessage();
            }
            Flow flow = getFlow(context.getFlowParameters().getFlowId());
            flow.setFlowFailed(payload.getException());
            SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.REPAIR_FAILED, statusReason, payload.getResourceId());
            metricService.incrementMetricCounter(MetricType.SDX_REPAIR_FAILED, sdxCluster);
            sendEvent(context, SDX_REPAIR_FAILED_HANDLED_EVENT.event(), payload);
        }

        @Override
        protected Object getFailurePayload(SdxRepairFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return null;
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) SdxRepairFailedEvent(com.sequenceiq.datalake.flow.repair.event.SdxRepairFailedEvent) 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) Flow(com.sequenceiq.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Aggregations

SdxRepairFailedEvent (com.sequenceiq.datalake.flow.repair.event.SdxRepairFailedEvent)2 PollerException (com.dyngr.exception.PollerException)1 PollerStoppedException (com.dyngr.exception.PollerStoppedException)1 UserBreakException (com.dyngr.exception.UserBreakException)1 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 SdxRepairSuccessEvent (com.sequenceiq.datalake.flow.repair.event.SdxRepairSuccessEvent)1 SdxRepairWaitRequest (com.sequenceiq.datalake.flow.repair.event.SdxRepairWaitRequest)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)1 Flow (com.sequenceiq.flow.core.Flow)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1