Search in sources :

Example 6 with PollerStoppedException

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

the class StackDeletionHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<StackDeletionWaitRequest> event) {
    StackDeletionWaitRequest stackDeletionWaitRequest = event.getData();
    Long sdxId = stackDeletionWaitRequest.getResourceId();
    String userId = stackDeletionWaitRequest.getUserId();
    Selectable response;
    try {
        LOGGER.debug("Start polling stack deletion process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        provisionerService.waitCloudbreakClusterDeletion(sdxId, pollingConfig);
        response = new StackDeletionSuccessEvent(sdxId, userId, stackDeletionWaitRequest.isForced());
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Deletion polling exited before timeout. Cause: ", userBreakException);
        response = new SdxDeletionFailedEvent(sdxId, userId, userBreakException, stackDeletionWaitRequest.isForced());
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Deletion poller stopped for stack: {}", sdxId);
        response = new SdxDeletionFailedEvent(sdxId, userId, new PollerStoppedException("Datalake stack deletion timed out after " + durationInMinutes + " minutes"), stackDeletionWaitRequest.isForced());
    } catch (PollerException exception) {
        LOGGER.error("Deletion polling failed for stack: {}", sdxId);
        response = new SdxDeletionFailedEvent(sdxId, userId, exception, stackDeletionWaitRequest.isForced());
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) SdxDeletionFailedEvent(com.sequenceiq.datalake.flow.delete.event.SdxDeletionFailedEvent) StackDeletionWaitRequest(com.sequenceiq.datalake.flow.delete.event.StackDeletionWaitRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException) StackDeletionSuccessEvent(com.sequenceiq.datalake.flow.delete.event.StackDeletionSuccessEvent)

Example 7 with PollerStoppedException

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

the class RdsWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<RdsWaitRequest> event) {
    RdsWaitRequest rdsWaitRequest = event.getData();
    Long sdxId = rdsWaitRequest.getResourceId();
    String userId = rdsWaitRequest.getUserId();
    try {
        DetailedEnvironmentResponse env = environmentService.waitNetworkAndGetEnvironment(sdxId);
        Optional<SdxCluster> sdxCluster = sdxClusterRepository.findById(sdxId);
        if (sdxCluster.isPresent()) {
            if (sdxCluster.get().hasExternalDatabase()) {
                validForDatabaseCreation(sdxId, env);
                LOGGER.debug("start polling database for sdx: {}", sdxId);
                databaseService.create(sdxCluster.get(), env);
                setRdsCreatedStatus(sdxCluster.get());
                return new RdsWaitSuccessEvent(sdxId, userId);
            } else {
                LOGGER.debug("skipping creation of database for sdx: {}", sdxId);
                return new RdsWaitSuccessEvent(sdxId, userId);
            }
        } else {
            throw notFound("SDX cluster", sdxId).get();
        }
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Database polling exited before timeout. Cause: ", userBreakException);
        return new SdxCreateFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Database poller stopped for sdx: {}", sdxId, pollerStoppedException);
        return new SdxCreateFailedEvent(sdxId, userId, new PollerStoppedException("Database creation timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Database polling failed for sdx: {}", sdxId, exception);
        return new SdxCreateFailedEvent(sdxId, userId, exception);
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened in sdx database creation wait phase", anotherException);
        return new SdxCreateFailedEvent(sdxId, userId, anotherException);
    }
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) SdxCreateFailedEvent(com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent) RdsWaitSuccessEvent(com.sequenceiq.datalake.flow.create.event.RdsWaitSuccessEvent) PollerException(com.dyngr.exception.PollerException) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) RdsWaitRequest(com.sequenceiq.datalake.flow.create.event.RdsWaitRequest) PollerStoppedException(com.dyngr.exception.PollerStoppedException) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 8 with PollerStoppedException

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

the class DatalakeVmReplaceWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeVmReplaceWaitRequest> event) {
    DatalakeVmReplaceWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling cluster VM replacement process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        upgradeService.waitCloudbreakFlow(sdxId, pollingConfig, "VM replace");
        response = new DatalakeUpgradeSuccessEvent(sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("VM replace polling exited before timeout. Cause: ", userBreakException);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("VM replace poller stopped for cluster: {}", sdxId);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, new PollerStoppedException("VM replace timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("VM replace polling failed for cluster: {}", sdxId);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, exception);
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened during VM replacement wait phase", anotherException);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, anotherException);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) DatalakeUpgradeFailedEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeFailedEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException) DatalakeVmReplaceWaitRequest(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeVmReplaceWaitRequest) DatalakeUpgradeSuccessEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeSuccessEvent)

Example 9 with PollerStoppedException

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

the class SdxCmDiagnosticsCollectionHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SdxCmDiagnosticsWaitRequest> event) {
    SdxCmDiagnosticsWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Map<String, Object> properties = request.getProperties();
    Selectable response;
    try {
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        diagnosticsFlowService.waitForDiagnosticsCollection(sdxId, pollingConfig, request.getFlowIdentifier(), true);
        response = new SdxDiagnosticsSuccessEvent(sdxId, userId, properties);
        LOGGER.debug("SDX CM based diagnostics collection event finished");
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Polling exited before timeout for SDX (CM based diagnostic collection): {}. Cause: ", sdxId, userBreakException);
        response = new SdxCmDiagnosticsFailedEvent(sdxId, userId, properties, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Poller stopped for SDX (CM based diagnostic collection): {}", sdxId, pollerStoppedException);
        response = new SdxCmDiagnosticsFailedEvent(sdxId, userId, properties, new PollerStoppedException("Datalake CM based diagnostic collection timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Polling failed for stack (CM based diagnostic collection): {}", sdxId, exception);
        response = new SdxCmDiagnosticsFailedEvent(sdxId, userId, properties, exception);
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened in CM based diagnostic collection wait phase", anotherException);
        response = new SdxCmDiagnosticsFailedEvent(sdxId, userId, properties, anotherException);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) SdxDiagnosticsSuccessEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent) SdxCmDiagnosticsWaitRequest(com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsWaitRequest) PollerStoppedException(com.dyngr.exception.PollerStoppedException) SdxCmDiagnosticsFailedEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsFailedEvent)

Example 10 with PollerStoppedException

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

the class EnvWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<EnvWaitRequest> event) {
    EnvWaitRequest envWaitRequest = event.getData();
    Long datalakeId = envWaitRequest.getResourceId();
    String userId = envWaitRequest.getUserId();
    Selectable response;
    try {
        LOGGER.debug("start polling env for sdx: {}", datalakeId);
        DetailedEnvironmentResponse detailedEnvironmentResponse = environmentService.waitAndGetEnvironment(datalakeId);
        response = new EnvWaitSuccessEvent(datalakeId, userId, detailedEnvironmentResponse);
        setEnvCreatedStatus(datalakeId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Env polling exited before timeout. Cause: ", userBreakException);
        response = new SdxCreateFailedEvent(datalakeId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Env poller stopped for sdx: {}", datalakeId, pollerStoppedException);
        response = new SdxCreateFailedEvent(datalakeId, userId, new PollerStoppedException("Env wait timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Env polling failed for sdx: {}", datalakeId, exception);
        response = new SdxCreateFailedEvent(datalakeId, userId, exception);
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened in sdx creation wait phase", anotherException);
        response = new SdxCreateFailedEvent(datalakeId, userId, anotherException);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) SdxCreateFailedEvent(com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent) PollerException(com.dyngr.exception.PollerException) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) EnvWaitRequest(com.sequenceiq.datalake.flow.create.event.EnvWaitRequest) EnvWaitSuccessEvent(com.sequenceiq.datalake.flow.create.event.EnvWaitSuccessEvent) PollerStoppedException(com.dyngr.exception.PollerStoppedException) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) 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