Search in sources :

Example 31 with PollerStoppedException

use of com.dyngr.exception.PollerStoppedException 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 32 with PollerStoppedException

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

the class SdxStopAllDatahubHandlerTest method testPollerStoppedException.

@Test
public void testPollerStoppedException() {
    PollerStoppedException pollerStoppedException = new PollerStoppedException("");
    doThrow(pollerStoppedException).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("Datalake stop timed out after 40 minutes", sdxStopFailedEvent.getException().getMessage());
}
Also used : SdxStopAllDatahubRequest(com.sequenceiq.datalake.flow.stop.event.SdxStopAllDatahubRequest) SdxStopFailedEvent(com.sequenceiq.datalake.flow.stop.event.SdxStopFailedEvent) PollerStoppedException(com.dyngr.exception.PollerStoppedException) Test(org.junit.jupiter.api.Test)

Example 33 with PollerStoppedException

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

the class StackCreationHandlerTest method acceptTestPollerStackTimeout.

@Test
void acceptTestPollerStackTimeout() {
    long stackId = 2L;
    StackCreationWaitRequest stackCreationWaitRequest = new StackCreationWaitRequest(stackId, userId);
    Event receivedEvent = new Event<>(stackCreationWaitRequest);
    doThrow(new PollerStoppedException("stack timeout")).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(PollerStoppedException.class, ((SdxCreateFailedEvent) event.getData()).getException().getClass());
}
Also used : StackCreationWaitRequest(com.sequenceiq.datalake.flow.create.event.StackCreationWaitRequest) SdxCreateFailedEvent(com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent) 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) PollerStoppedException(com.dyngr.exception.PollerStoppedException) Test(org.junit.jupiter.api.Test)

Example 34 with PollerStoppedException

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

the class StackDeletionHandlerTest method acceptTestPollerStackTimeout.

@Test
void acceptTestPollerStackTimeout() {
    long id = 2L;
    StackDeletionWaitRequest stackCreationWaitRequest = new StackDeletionWaitRequest(id, userId, true);
    Event receivedEvent = new Event<>(stackCreationWaitRequest);
    doThrow(new PollerStoppedException("stack deletion timeout")).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 : 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) PollerStoppedException(com.dyngr.exception.PollerStoppedException) Test(org.junit.jupiter.api.Test)

Example 35 with PollerStoppedException

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

the class SdxDiagnosticsCollectionHandlerTest method testAcceptWithPollerStoppedException.

@Test
void testAcceptWithPollerStoppedException() {
    Event<SdxDiagnosticsWaitRequest> event = initEvent();
    PollerStoppedException exception = new PollerStoppedException();
    doThrow(exception).when(diagnosticsFlowService).waitForDiagnosticsCollection(anyLong(), any(), any());
    underTest.accept(event);
    SdxDiagnosticsFailedEvent sdxDiagnosticsFailedEvent = new SdxDiagnosticsFailedEvent(1L, "userId", Map.of(), exception);
    Mockito.verify(eventBus, Mockito.times(1)).notify(eq(sdxDiagnosticsFailedEvent.selector()), any(Event.class));
}
Also used : SdxDiagnosticsFailedEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsFailedEvent) SdxDiagnosticsSuccessEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent) SdxDiagnosticsFailedEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsFailedEvent) Event(reactor.bus.Event) SdxDiagnosticsWaitRequest(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsWaitRequest) PollerStoppedException(com.dyngr.exception.PollerStoppedException) Test(org.junit.jupiter.api.Test)

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