Search in sources :

Example 41 with UserBreakException

use of com.dyngr.exception.UserBreakException in project cloudbreak by hortonworks.

the class SdxStopAllDatahubHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SdxStopAllDatahubRequest> event) {
    SdxStopAllDatahubRequest stopAllDatahubRequest = event.getData();
    Long sdxId = stopAllDatahubRequest.getResourceId();
    String userId = stopAllDatahubRequest.getUserId();
    Selectable response;
    try {
        LOGGER.debug("Polling is started for the operation of stopping all datahubs clusters for sdx with id: {}", sdxId);
        sdxStopService.stopAllDatahub(sdxId);
        response = new SdxEvent(SdxStopEvent.SDX_STOP_IN_PROGRESS_EVENT.event(), sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Polling exited before timeout. Cause ", userBreakException);
        response = new SdxStopFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Poller stopped for stack: " + sdxId, pollerStoppedException);
        response = new SdxStopFailedEvent(sdxId, userId, new PollerStoppedException("Datalake stop timed out after " + DURATION_IN_MINUTES + " minutes", pollerStoppedException));
    } catch (PollerException exception) {
        LOGGER.error("Polling failed for stack: {}", sdxId);
        response = new SdxStopFailedEvent(sdxId, userId, exception);
    } catch (BadRequestException badRequest) {
        LOGGER.error("Datahub stop failed.", badRequest);
        response = new SdxStopFailedEvent(sdxId, userId, badRequest);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) SdxStopAllDatahubRequest(com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) SdxStopFailedEvent(com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent) BadRequestException(javax.ws.rs.BadRequestException) SdxEvent(com.sequenceiq.datalake.flow.SdxEvent) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Aggregations

UserBreakException (com.dyngr.exception.UserBreakException)41 PollerException (com.dyngr.exception.PollerException)30 PollerStoppedException (com.dyngr.exception.PollerStoppedException)30 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)28 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)21 Test (org.junit.jupiter.api.Test)10 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)7 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)7 SdxCreateFailedEvent (com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent)5 DatabaseAvailabilityType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)4 SdxEvent (com.sequenceiq.datalake.flow.SdxEvent)4 SdxStopFailedEvent (com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent)4 DatalakeUpgradeFailedEvent (com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeFailedEvent)3 SdxDeletionFailedEvent (com.sequenceiq.datalake.flow.delete.event.SdxDeletionFailedEvent)3 SdxDiagnosticsSuccessEvent (com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent)3 UpgradeValidationFailedException (com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)2 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)2 StackCreationSuccessEvent (com.sequenceiq.datalake.flow.create.event.StackCreationSuccessEvent)2 StackCreationWaitRequest (com.sequenceiq.datalake.flow.create.event.StackCreationWaitRequest)2