Search in sources :

Example 11 with PollerException

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

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

Example 13 with PollerException

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

the class SdxStopWaitHandler method doAccept.

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

Example 14 with PollerException

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

the class StackCreationHandlerTest method acceptTestPollerStackOtherError.

@Test
void acceptTestPollerStackOtherError() {
    long stackId = 2L;
    StackCreationWaitRequest stackCreationWaitRequest = new StackCreationWaitRequest(stackId, userId);
    Event receivedEvent = new Event<>(stackCreationWaitRequest);
    doThrow(new PollerException("stack error")).when(provisionerService).waitCloudbreakClusterCreation(eq(stackId), any(PollingConfig.class));
    stackCreationHandler.accept(receivedEvent);
    verify(provisionerService, times(1)).waitCloudbreakClusterCreation(eq(stackId), any(PollingConfig.class));
    final ArgumentCaptor<String> eventSelector = ArgumentCaptor.forClass(String.class);
    final ArgumentCaptor<Event> sentEvent = ArgumentCaptor.forClass(Event.class);
    verify(eventBus, times(1)).notify(eventSelector.capture(), sentEvent.capture());
    String eventNotified = eventSelector.getValue();
    Event event = sentEvent.getValue();
    Assertions.assertEquals("SdxCreateFailedEvent", eventNotified);
    Assertions.assertEquals(SdxCreateFailedEvent.class, event.getData().getClass());
    Assertions.assertEquals(stackId, ((SdxCreateFailedEvent) event.getData()).getResourceId());
    Assertions.assertEquals(PollerException.class, ((SdxCreateFailedEvent) event.getData()).getException().getClass());
}
Also used : StackCreationWaitRequest(com.sequenceiq.datalake.flow.create.event.StackCreationWaitRequest) SdxCreateFailedEvent(com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent) PollerException(com.dyngr.exception.PollerException) SdxCreateFailedEvent(com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent) Event(reactor.bus.Event) StackCreationSuccessEvent(com.sequenceiq.datalake.flow.create.event.StackCreationSuccessEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 15 with PollerException

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

the class SdxCertRenewWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SdxCertRenewalWaitEvent> event) {
    SdxEvent sdxEvent = event.getData();
    Long sdxId = sdxEvent.getResourceId();
    String userId = sdxEvent.getUserId();
    Selectable response;
    try {
        LOGGER.debug("Start polling stack cert renewal process.");
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        certRenewalService.waitForCloudbreakClusterCertRenewal(sdxId, pollingConfig);
        response = new SdxEvent(SdxCertRenewalEvent.CERT_RENEWAL_FINISHED_EVENT.event(), sdxId, userId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Cert renewal polling exited before timeout. Cause: ", userBreakException);
        response = new SdxCertRenewalFailedEvent(sdxId, userId, userBreakException.getMessage());
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Cert renewal poller stopped.");
        response = new SdxCertRenewalFailedEvent(sdxId, userId, "Datalake cert renewal timed out after " + durationInMinutes + " minutes");
    } catch (PollerException exception) {
        LOGGER.error("Cert renewal polling failed. Cause: ", exception);
        response = new SdxCertRenewalFailedEvent(sdxId, userId, exception.getMessage());
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) SdxEvent(com.sequenceiq.datalake.flow.SdxEvent) SdxCertRenewalFailedEvent(com.sequenceiq.datalake.flow.cert.renew.event.SdxCertRenewalFailedEvent) 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