Search in sources :

Example 1 with SdxStartFailedEvent

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

the class RdsStartHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<RdsWaitingToStartRequest> event) {
    RdsWaitingToStartRequest 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_START_IN_PROGRESS, "External database start in progress", sdxCluster);
                LOGGER.debug("start polling database start for sdx: {}", sdxId);
                databaseService.start(sdxCluster);
            } else {
                LOGGER.debug("skipping start of database for sdx: {}", sdxId);
            }
            sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.EXTERNAL_DATABASE_STARTED, "External database started", sdxCluster);
        });
        response = new RdsStartSuccessEvent(sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Database polling exited before timeout. Cause: ", userBreakException);
        response = new SdxStartFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Database poller stopped for sdx: {}", sdxId, pollerStoppedException);
        response = new SdxStartFailedEvent(sdxId, userId, new PollerStoppedException("Database start timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Database polling failed for sdx: {}", sdxId, exception);
        response = new SdxStartFailedEvent(sdxId, userId, exception);
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened in sdx database start wait phase", anotherException);
        response = new SdxStartFailedEvent(sdxId, userId, anotherException);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) RdsStartSuccessEvent(com.sequenceiq.datalake.flow.start.event.RdsStartSuccessEvent) PollerException(com.dyngr.exception.PollerException) RdsWaitingToStartRequest(com.sequenceiq.datalake.flow.start.event.RdsWaitingToStartRequest) PollerStoppedException(com.dyngr.exception.PollerStoppedException) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException) SdxStartFailedEvent(com.sequenceiq.datalake.flow.start.event.SdxStartFailedEvent)

Example 2 with SdxStartFailedEvent

use of com.sequenceiq.datalake.flow.start.event.SdxStartFailedEvent 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)

Aggregations

PollerException (com.dyngr.exception.PollerException)2 PollerStoppedException (com.dyngr.exception.PollerStoppedException)2 UserBreakException (com.dyngr.exception.UserBreakException)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)2 SdxStartFailedEvent (com.sequenceiq.datalake.flow.start.event.SdxStartFailedEvent)2 RdsStartSuccessEvent (com.sequenceiq.datalake.flow.start.event.RdsStartSuccessEvent)1 RdsWaitingToStartRequest (com.sequenceiq.datalake.flow.start.event.RdsWaitingToStartRequest)1 SdxStartSuccessEvent (com.sequenceiq.datalake.flow.start.event.SdxStartSuccessEvent)1 SdxStartWaitRequest (com.sequenceiq.datalake.flow.start.event.SdxStartWaitRequest)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)1