Search in sources :

Example 1 with SdxStartSuccessEvent

use of com.sequenceiq.datalake.flow.start.event.SdxStartSuccessEvent in project cloudbreak by hortonworks.

the class SdxStartWaitHandler method doAccept.

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

Example 2 with SdxStartSuccessEvent

use of com.sequenceiq.datalake.flow.start.event.SdxStartSuccessEvent in project cloudbreak by hortonworks.

the class SdxStartActions method finishedAction.

@Bean(name = "SDX_START_FINISHED_STATE")
public Action<?, ?> finishedAction() {
    return new AbstractSdxAction<>(SdxStartSuccessEvent.class) {

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

        @Override
        protected void doExecute(SdxContext context, SdxStartSuccessEvent payload, Map<Object, Object> variables) throws Exception {
            LOGGER.info("SDX start finalized: {}", payload.getResourceId());
            SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.RUNNING, "Datalake is running", payload.getResourceId());
            metricService.incrementMetricCounter(MetricType.SDX_START_FINISHED, sdxCluster);
            sendEvent(context, SDX_START_FINALIZED_EVENT.event(), payload);
        }

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

Aggregations

SdxStartSuccessEvent (com.sequenceiq.datalake.flow.start.event.SdxStartSuccessEvent)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 SdxStartFailedEvent (com.sequenceiq.datalake.flow.start.event.SdxStartFailedEvent)1 SdxStartWaitRequest (com.sequenceiq.datalake.flow.start.event.SdxStartWaitRequest)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)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