Search in sources :

Example 1 with RdsStopSuccessEvent

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

the class RdsStopHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<RdsWaitingToStopRequest> event) {
    RdsWaitingToStopRequest rdsWaitRequest = event.getData();
    Long sdxId = rdsWaitRequest.getResourceId();
    String userId = rdsWaitRequest.getUserId();
    Selectable response;
    try {
        sdxClusterRepository.findById(sdxId).ifPresent(sdxCluster -> {
            if (databasePauseSupportService.isDatabasePauseSupported(sdxCluster)) {
                sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.EXTERNAL_DATABASE_STOP_IN_PROGRESS, "External database stop in progress", sdxCluster);
                LOGGER.debug("stop polling database stop for sdx: {}", sdxId);
                databaseService.stop(sdxCluster);
            } else {
                LOGGER.debug("skipping stop of database for sdx: {}", sdxId);
            }
            sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.EXTERNAL_DATABASE_STOPPED, "External database stopped", sdxCluster);
        });
        response = new RdsStopSuccessEvent(sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Database polling exited before timeout. Cause: ", userBreakException);
        response = new SdxStopFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Database poller stopped for sdx: {}", sdxId, pollerStoppedException);
        response = new SdxStopFailedEvent(sdxId, userId, new PollerStoppedException("Database stop timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Database polling failed for sdx: {}", sdxId, exception);
        response = new SdxStopFailedEvent(sdxId, userId, exception);
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened in sdx database stop wait phase", anotherException);
        response = new SdxStopFailedEvent(sdxId, userId, anotherException);
    }
    return response;
}
Also used : RdsWaitingToStopRequest(com.sequenceiq.datalake.flow.stop.event.RdsWaitingToStopRequest) UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) RdsStopSuccessEvent(com.sequenceiq.datalake.flow.stop.event.RdsStopSuccessEvent) SdxStopFailedEvent(com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent) PollerStoppedException(com.dyngr.exception.PollerStoppedException) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) 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 RdsStopSuccessEvent (com.sequenceiq.datalake.flow.stop.event.RdsStopSuccessEvent)1 RdsWaitingToStopRequest (com.sequenceiq.datalake.flow.stop.event.RdsWaitingToStopRequest)1 SdxStopFailedEvent (com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent)1