Search in sources :

Example 21 with PollerException

use of com.dyngr.exception.PollerException 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 22 with PollerException

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

the class SdxWaitTaskServiceTest method testWaitForWithPollerException.

@Test
void testWaitForWithPollerException() {
    try (MockedStatic<Polling> polling = mockStatic(Polling.class)) {
        SdxWaitTask<?> sdxWaitTask = new TestWaitTask(new SdxCluster(), POLLING_CONFIG, "My Sdx task");
        setupPolling(polling);
        doThrow(new PollerException()).when(pollingOptions).run(sdxWaitTask);
        Assertions.assertThrows(SdxWaitException.class, () -> {
            underTest.waitFor(sdxWaitTask);
        });
        verify(pollingOptions).stopAfterDelay(DURATION, DURATION_TIME_UNIT);
        verify(pollingOptions).stopIfException(Boolean.TRUE);
        verify(pollingOptions).run(sdxWaitTask);
    }
}
Also used : Polling(com.dyngr.Polling) PollerException(com.dyngr.exception.PollerException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Test(org.junit.jupiter.api.Test)

Example 23 with PollerException

use of com.dyngr.exception.PollerException 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 24 with PollerException

use of com.dyngr.exception.PollerException 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 25 with PollerException

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

PollerException (com.dyngr.exception.PollerException)37 PollerStoppedException (com.dyngr.exception.PollerStoppedException)31 UserBreakException (com.dyngr.exception.UserBreakException)30 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)28 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)22 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)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 Test (org.junit.jupiter.api.Test)4 DatalakeUpgradeFailedEvent (com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeUpgradeFailedEvent)3 SdxDiagnosticsSuccessEvent (com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent)3 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 SdxDeletionFailedEvent (com.sequenceiq.datalake.flow.delete.event.SdxDeletionFailedEvent)2 SdxDiagnosticsFailedEvent (com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsFailedEvent)2