Search in sources :

Example 1 with DatalakeRecoverySuccessEvent

use of com.sequenceiq.datalake.flow.datalake.recovery.event.DatalakeRecoverySuccessEvent in project cloudbreak by hortonworks.

the class DatalakeRecoveryWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeRecoveryWaitRequest> event) {
    DatalakeRecoveryWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling cluster recovery process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        recoveryService.waitCloudbreakFlow(sdxId, pollingConfig, "Stack Recovery");
        response = new DatalakeRecoverySuccessEvent(sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Recovery polling exited before timeout. Cause: ", userBreakException);
        response = new DatalakeRecoveryFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Recovery poller stopped for cluster: {}", sdxId);
        response = new DatalakeRecoveryFailedEvent(sdxId, userId, new PollerStoppedException("Datalake recovery timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Recovery polling failed for cluster: {}", sdxId);
        response = new DatalakeRecoveryFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : DatalakeRecoverySuccessEvent(com.sequenceiq.datalake.flow.datalake.recovery.event.DatalakeRecoverySuccessEvent) DatalakeRecoveryWaitRequest(com.sequenceiq.datalake.flow.datalake.recovery.event.DatalakeRecoveryWaitRequest) UserBreakException(com.dyngr.exception.UserBreakException) DatalakeRecoveryFailedEvent(com.sequenceiq.datalake.flow.datalake.recovery.event.DatalakeRecoveryFailedEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) 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 DatalakeRecoveryFailedEvent (com.sequenceiq.datalake.flow.datalake.recovery.event.DatalakeRecoveryFailedEvent)1 DatalakeRecoverySuccessEvent (com.sequenceiq.datalake.flow.datalake.recovery.event.DatalakeRecoverySuccessEvent)1 DatalakeRecoveryWaitRequest (com.sequenceiq.datalake.flow.datalake.recovery.event.DatalakeRecoveryWaitRequest)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)1