Search in sources :

Example 26 with PollerException

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

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

Example 28 with PollerException

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

the class DatalakeUpgradeWaitHandler method doAccept.

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

Example 29 with PollerException

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

the class SdxStopAllDatahubHandlerTest method testPollerException.

@Test
public void testPollerException() {
    PollerException pollerException = new PollerException("");
    doThrow(pollerException).when(sdxStopService).stopAllDatahub(anyLong());
    underTest.accept(new Event<>(new SdxStopAllDatahubRequest(SDX_ID, USER_ID)));
    verify(eventBus).notify(anyString(), captor.capture());
    SdxStopFailedEvent sdxStopFailedEvent = captor.getValue().getData();
    assertEquals(SDX_ID, sdxStopFailedEvent.getResourceId());
    assertEquals(USER_ID, sdxStopFailedEvent.getUserId());
    assertEquals(pollerException, sdxStopFailedEvent.getException());
}
Also used : SdxStopAllDatahubRequest(com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest) PollerException(com.dyngr.exception.PollerException) SdxStopFailedEvent(com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent) Test(org.junit.jupiter.api.Test)

Example 30 with PollerException

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

the class StackDeletionHandlerTest method acceptTestPollerStackOtherError.

@Test
void acceptTestPollerStackOtherError() {
    long id = 2L;
    StackDeletionWaitRequest stackCreationWaitRequest = new StackDeletionWaitRequest(id, userId, true);
    Event receivedEvent = new Event<>(stackCreationWaitRequest);
    doThrow(new PollerException("stack deletion error")).when(provisionerService).waitCloudbreakClusterDeletion(eq(id), any(PollingConfig.class));
    stackDeletionHandler.accept(receivedEvent);
    verify(provisionerService, times(1)).waitCloudbreakClusterDeletion(eq(id), 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("SdxDeletionFailedEvent", eventNotified);
    Assertions.assertEquals(SdxDeletionFailedEvent.class, event.getData().getClass());
    Assertions.assertEquals(id, ((SdxDeletionFailedEvent) event.getData()).getResourceId());
}
Also used : PollerException(com.dyngr.exception.PollerException) Event(reactor.bus.Event) SdxDeletionFailedEvent(com.sequenceiq.datalake.flow.delete.event.SdxDeletionFailedEvent) StackDeletionSuccessEvent(com.sequenceiq.datalake.flow.delete.event.StackDeletionSuccessEvent) StackDeletionWaitRequest(com.sequenceiq.datalake.flow.delete.event.StackDeletionWaitRequest) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) Test(org.junit.jupiter.api.Test)

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