Search in sources :

Example 36 with PollerStoppedException

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

the class SdxPollerProvider method upgradeCcmPoller.

public AttemptResult<Void> upgradeCcmPoller(Long envId, String datalakeCrn) {
    if (PollGroup.CANCELLED.equals(EnvironmentInMemoryStateStore.get(envId))) {
        String message = "SDX polling cancelled in inmemory store, environment id: " + envId;
        LOGGER.info(message);
        throw new PollerStoppedException(message);
    }
    OperationView operation = sdxService.getOperation(datalakeCrn, false);
    OperationProgressStatus progressStatus = operation.getProgressStatus();
    switch(progressStatus) {
        case CANCELLED:
            return AttemptResults.breakFor("SDX Upgrade CCM cancelled for datalake CRN " + datalakeCrn);
        case FAILED:
            return AttemptResults.breakFor("SDX Upgrade CCM failed for environment CRN " + datalakeCrn);
        case FINISHED:
            return AttemptResults.justFinish();
        case RUNNING:
            return AttemptResults.justContinue();
        default:
            return AttemptResults.breakFor("SDX Upgrade CCM is in ambiguous state " + progressStatus + " for environment CRN " + datalakeCrn);
    }
}
Also used : OperationProgressStatus(com.sequenceiq.flow.api.model.operation.OperationProgressStatus) OperationView(com.sequenceiq.flow.api.model.operation.OperationView) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 37 with PollerStoppedException

use of com.dyngr.exception.PollerStoppedException 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 38 with PollerStoppedException

use of com.dyngr.exception.PollerStoppedException 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)

Example 39 with PollerStoppedException

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

the class UpgradeCcmStackHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<UpgradeCcmStackRequest> event) {
    UpgradeCcmStackRequest request = event.getData();
    SdxCluster sdxCluster = sdxService.getById(request.getResourceId());
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.debug("Initiating CCM upgrade and start polling for SDX: {}", sdxCluster.getName());
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        ccmUpgradeService.initAndWaitForStackUpgrade(sdxCluster, pollingConfig);
        response = new UpgradeCcmSuccessEvent(sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Upgrade CCM poller exited before timeout. Cause: ", userBreakException);
        response = new UpgradeCcmFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Upgrade CCM poller stopped for stack: {}", sdxId);
        response = new UpgradeCcmFailedEvent(sdxId, userId, new PollerStoppedException("Upgrade CCM timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Upgrade CCM polling failed for stack: {}", sdxId);
        response = new UpgradeCcmFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : UpgradeCcmSuccessEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent) UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpgradeCcmFailedEvent(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) PollerException(com.dyngr.exception.PollerException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) UpgradeCcmStackRequest(com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmStackRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 40 with PollerStoppedException

use of com.dyngr.exception.PollerStoppedException 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

PollerStoppedException (com.dyngr.exception.PollerStoppedException)43 PollerException (com.dyngr.exception.PollerException)31 UserBreakException (com.dyngr.exception.UserBreakException)30 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)28 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)21 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)7 Test (org.junit.jupiter.api.Test)7 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)5 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 SdxDiagnosticsSuccessEvent (com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent)3 Event (reactor.bus.Event)3 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)2 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)2 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)2 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)2