Search in sources :

Example 26 with PollerStoppedException

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

the class DatalakeDatabaseBackupWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeDatabaseBackupWaitRequest> event) {
    DatalakeDatabaseBackupWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling datalake database backup  for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        sdxBackupRestoreService.waitCloudbreakFlow(sdxId, pollingConfig, "Database backup");
        response = new DatalakeFullBackupInProgressEvent(sdxId, userId, request.getOperationId());
    } catch (UserBreakException userBreakException) {
        LOGGER.info("Database backup polling exited before timeout. Cause: ", userBreakException);
        sdxBackupRestoreService.updateDatabaseStatusEntry(event.getData().getOperationId(), SdxOperationStatus.FAILED, userBreakException.getLocalizedMessage());
        response = new DatalakeDatabaseBackupFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.info("Database backup poller stopped for cluster: {}", sdxId);
        sdxBackupRestoreService.updateDatabaseStatusEntry(event.getData().getOperationId(), SdxOperationStatus.FAILED, pollerStoppedException.getLocalizedMessage());
        response = new DatalakeDatabaseBackupFailedEvent(sdxId, userId, new PollerStoppedException("Database backup timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.info("Database backup polling failed for cluster: {}", sdxId);
        sdxBackupRestoreService.updateDatabaseStatusEntry(event.getData().getOperationId(), SdxOperationStatus.FAILED, exception.getLocalizedMessage());
        response = new DatalakeDatabaseBackupFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : DatalakeDatabaseBackupWaitRequest(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeDatabaseBackupWaitRequest) UserBreakException(com.dyngr.exception.UserBreakException) DatalakeFullBackupInProgressEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeFullBackupInProgressEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) DatalakeDatabaseBackupFailedEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeDatabaseBackupFailedEvent) PollerException(com.dyngr.exception.PollerException) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 27 with PollerStoppedException

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

the class DatalakeRecoveryWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeRecoveryWaitRequest> event) {
    DatalakeRecoveryWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling cluster recovery process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        recoveryService.waitCloudbreakFlow(sdxId, pollingConfig, "Stack Recovery");
        response = new DatalakeRecoverySuccessEvent(sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Recovery polling exited before timeout. Cause: ", userBreakException);
        response = new DatalakeRecoveryFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Recovery poller stopped for cluster: {}", sdxId);
        response = new DatalakeRecoveryFailedEvent(sdxId, userId, new PollerStoppedException("Datalake recovery timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Recovery polling failed for cluster: {}", sdxId);
        response = new DatalakeRecoveryFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : DatalakeRecoverySuccessEvent(com.sequenceiq.datalake.flow.datalake.recovery.event.DatalakeRecoverySuccessEvent) DatalakeRecoveryWaitRequest(com.sequenceiq.datalake.flow.datalake.recovery.event.DatalakeRecoveryWaitRequest) UserBreakException(com.dyngr.exception.UserBreakException) DatalakeRecoveryFailedEvent(com.sequenceiq.datalake.flow.datalake.recovery.event.DatalakeRecoveryFailedEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 28 with PollerStoppedException

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

the class DatahubRefreshWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatahubRefreshWaitEvent> event) {
    SdxEvent sdxEvent = event.getData();
    Long sdxId = sdxEvent.getResourceId();
    String userId = sdxEvent.getUserId();
    Selectable response;
    try {
        LOGGER.debug("Start polling datahub refresh process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        sdxRefreshService.waitCloudbreakCluster(sdxId, pollingConfig);
        response = new SdxEvent(DatahubRefreshFlowEvent.DATAHUB_REFRESH_FINISHED_EVENT.event(), sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Datahub refresh polling exited before timeout. Cause: ", userBreakException);
        response = new DatahubRefreshFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Datahub refresh poller stopped for stack: {}", sdxId);
        response = new DatahubRefreshFailedEvent(sdxId, userId, new PollerStoppedException("Datahub refresh timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Datahub refresh polling failed for stack: {}", sdxId);
        response = new DatahubRefreshFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) DatahubRefreshFailedEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshFailedEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) SdxEvent(com.sequenceiq.datalake.flow.SdxEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 29 with PollerStoppedException

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

the class SdxDiagnosticsCollectionHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SdxDiagnosticsWaitRequest> event) {
    SdxDiagnosticsWaitRequest 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());
        response = new SdxDiagnosticsSuccessEvent(sdxId, userId, properties);
        LOGGER.debug("SDX diagnostics collection event finished");
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Polling exited before timeout for SDX (diagnostic collection): {}. Cause: ", sdxId, userBreakException);
        response = new SdxDiagnosticsFailedEvent(sdxId, userId, properties, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Poller stopped for SDX (diagnostic collection): {}", sdxId, pollerStoppedException);
        response = new SdxDiagnosticsFailedEvent(sdxId, userId, properties, new PollerStoppedException("Datalake diagnostic collection timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Polling failed for stack (diagnostic collection): {}", sdxId, exception);
        response = new SdxDiagnosticsFailedEvent(sdxId, userId, properties, exception);
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened in diagnostic collection wait phase", anotherException);
        response = new SdxDiagnosticsFailedEvent(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) SdxDiagnosticsFailedEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsFailedEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) SdxDiagnosticsSuccessEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent) SdxDiagnosticsWaitRequest(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsWaitRequest) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 30 with PollerStoppedException

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

the class DatalakeChangeImageWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeChangeImageWaitRequest> event) {
    DatalakeChangeImageWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling change image process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        upgradeService.waitCloudbreakFlow(sdxId, pollingConfig, "Change image");
        String imageId = upgradeService.getImageId(sdxId);
        String expectedImageId = request.getUpgradeOption().getUpgrade().getImageId();
        if (Objects.equals(imageId, expectedImageId)) {
            LOGGER.info("Image changed in cloudbreak side for SDX {}, actual image: {}", sdxId, imageId);
            response = new DatalakeVmReplaceEvent(sdxId, userId);
        } else {
            String message = String.format("Image not changed in cloudbreak side, expected image: %s, actual image: %s", expectedImageId, imageId);
            LOGGER.info(message);
            response = new DatalakeUpgradeFailedEvent(sdxId, userId, new IllegalStateException(message));
        }
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Change image polling exited before timeout. Cause: ", userBreakException);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Change image poller stopped for cluster: {}", sdxId);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, new PollerStoppedException("Change image poller timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Change image polling failed for cluster: {}", sdxId);
        response = new DatalakeUpgradeFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) DatalakeVmReplaceEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeVmReplaceEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) DatalakeUpgradeFailedEvent(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeFailedEvent) DatalakeChangeImageWaitRequest(com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeChangeImageWaitRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) 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