Search in sources :

Example 11 with PollerStoppedException

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

the class DatalakeDatabaseRestoreWaitHandler method doAccept.

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

Example 12 with PollerStoppedException

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

the class DatalakeFullRestoreWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeFullRestoreWaitRequest> event) {
    DatalakeFullRestoreWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling datalake full restore status for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        sdxBackupRestoreService.waitForDatalakeDrRestoreToComplete(sdxId, request.getOperationId(), request.getUserId(), pollingConfig, "Full restore");
        response = new DatalakeRestoreSuccessEvent(sdxId, userId, request.getOperationId());
    } catch (UserBreakException userBreakException) {
        LOGGER.info("Full restore polling exited before timeout. Cause: ", userBreakException);
        response = new DatalakeRestoreFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.info("Full restore poller stopped for cluster: {}", sdxId);
        response = new DatalakeRestoreFailedEvent(sdxId, userId, new PollerStoppedException("Data lake restore timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.info("Full restore polling failed for cluster: {}", sdxId);
        response = new DatalakeRestoreFailedEvent(sdxId, userId, exception);
    } catch (CloudbreakApiException exception) {
        LOGGER.info("Datalake restore failed. Reason: " + exception.getMessage());
        response = new DatalakeRestoreFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : DatalakeRestoreSuccessEvent(com.sequenceiq.datalake.flow.dr.restore.event.DatalakeRestoreSuccessEvent) UserBreakException(com.dyngr.exception.UserBreakException) DatalakeRestoreFailedEvent(com.sequenceiq.datalake.flow.dr.restore.event.DatalakeRestoreFailedEvent) DatalakeFullRestoreWaitRequest(com.sequenceiq.datalake.flow.dr.restore.event.DatalakeFullRestoreWaitRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 13 with PollerStoppedException

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

the class DatalakeFullBackupWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeFullBackupWaitRequest> event) {
    DatalakeFullBackupWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling datalake full backup status for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        sdxBackupRestoreService.waitForDatalakeDrBackupToComplete(sdxId, request.getOperationId(), request.getUserId(), pollingConfig, "Full backup");
        response = new DatalakeBackupSuccessEvent(sdxId, userId, request.getOperationId());
    } catch (UserBreakException userBreakException) {
        LOGGER.info("Full backup polling exited before timeout. Cause: ", userBreakException);
        response = new DatalakeBackupFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.info("Full backup poller stopped for cluster: {}", sdxId);
        response = new DatalakeBackupFailedEvent(sdxId, userId, new PollerStoppedException("Datalake backup timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.info("Full backup polling failed for cluster: {}", sdxId);
        response = new DatalakeBackupFailedEvent(sdxId, userId, exception);
    } catch (CloudbreakApiException exception) {
        LOGGER.info("Datalake backup failed. Reason: " + exception.getMessage());
        response = new DatalakeBackupFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : DatalakeBackupFailedEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeBackupFailedEvent) DatalakeFullBackupWaitRequest(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeFullBackupWaitRequest) UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) DatalakeBackupSuccessEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeBackupSuccessEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 14 with PollerStoppedException

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

the class SdxRepairWaitHandler method doAccept.

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

Example 15 with PollerStoppedException

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

the class RdsStopHandler method doAccept.

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