Search in sources :

Example 26 with UserBreakException

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

the class SdxCertRotationWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SdxCertRotationWaitEvent> event) {
    SdxEvent sdxEvent = event.getData();
    Long sdxId = sdxEvent.getResourceId();
    String userId = sdxEvent.getUserId();
    Selectable response;
    try {
        LOGGER.debug("Start polling stack cert rotation process for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        certRotationService.waitForCloudbreakClusterCertRotation(sdxId, pollingConfig);
        response = new SdxEvent(SdxCertRotationEvent.CERT_ROTATION_FINISHED_EVENT.event(), sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Cert rotation polling exited before timeout. Cause: ", userBreakException);
        response = new SdxCertRotationFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Cert rotation poller stopped for stack: {}", sdxId);
        response = new SdxCertRotationFailedEvent(sdxId, userId, new PollerStoppedException("Datalake cert rotation timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Cert rotation polling failed for stack: {}", sdxId);
        response = new SdxCertRotationFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : SdxCertRotationFailedEvent(com.sequenceiq.datalake.flow.cert.rotation.event.SdxCertRotationFailedEvent) UserBreakException(com.dyngr.exception.UserBreakException) 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 27 with UserBreakException

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

the class CloudbreakPollerTest method testCancelledFlow.

@Test
public void testCancelledFlow() {
    DatalakeInMemoryStateStore.put(ID, PollGroup.CANCELLED);
    UserBreakException exception = assertThrows(UserBreakException.class, () -> underTest.pollStartUntilAvailable(sdxCluster, pollingConfig));
    assertEquals("Start polling cancelled on 'clusterName' cluster.", exception.getMessage());
    verifyNoInteractions(cloudbreakFlowService, stackV4Endpoint, sdxStatusService);
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Test(org.junit.jupiter.api.Test)

Example 28 with UserBreakException

use of com.dyngr.exception.UserBreakException 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 29 with UserBreakException

use of com.dyngr.exception.UserBreakException 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 30 with UserBreakException

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

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