Search in sources :

Example 1 with SdxStopSuccessEvent

use of com.sequenceiq.datalake.flow.stop.event.SdxStopSuccessEvent in project cloudbreak by hortonworks.

the class SdxStopWaitHandler method doAccept.

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

Aggregations

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 SdxStopFailedEvent (com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent)1 SdxStopSuccessEvent (com.sequenceiq.datalake.flow.stop.event.SdxStopSuccessEvent)1 SdxStopWaitRequest (com.sequenceiq.datalake.flow.stop.event.SdxStopWaitRequest)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)1