Search in sources :

Example 1 with SdxDiagnosticsFailedEvent

use of com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsFailedEvent 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 2 with SdxDiagnosticsFailedEvent

use of com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsFailedEvent in project cloudbreak by hortonworks.

the class SdxDiagnosticsCollectionHandlerTest method testAcceptWithPollerException.

@Test
void testAcceptWithPollerException() {
    Event<SdxDiagnosticsWaitRequest> event = initEvent();
    PollerException exception = new PollerException();
    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) PollerException(com.dyngr.exception.PollerException) 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) Test(org.junit.jupiter.api.Test)

Example 3 with SdxDiagnosticsFailedEvent

use of com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsFailedEvent 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)

Example 4 with SdxDiagnosticsFailedEvent

use of com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsFailedEvent in project cloudbreak by hortonworks.

the class SdxDiagnosticsCollectionHandlerTest method testAcceptWithUserBreakException.

@Test
void testAcceptWithUserBreakException() {
    Event<SdxDiagnosticsWaitRequest> event = initEvent();
    UserBreakException exception = new UserBreakException();
    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 : UserBreakException(com.dyngr.exception.UserBreakException) 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) Test(org.junit.jupiter.api.Test)

Example 5 with SdxDiagnosticsFailedEvent

use of com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsFailedEvent in project cloudbreak by hortonworks.

the class SdxDiagnosticsCollectionHandlerTest method testAcceptWithUnspecifiedException.

@Test
void testAcceptWithUnspecifiedException() {
    Event<SdxDiagnosticsWaitRequest> event = initEvent();
    RuntimeException exception = new RuntimeException();
    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) Test(org.junit.jupiter.api.Test)

Aggregations

SdxDiagnosticsFailedEvent (com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsFailedEvent)5 SdxDiagnosticsSuccessEvent (com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent)5 SdxDiagnosticsWaitRequest (com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsWaitRequest)5 Test (org.junit.jupiter.api.Test)4 Event (reactor.bus.Event)4 PollerException (com.dyngr.exception.PollerException)2 PollerStoppedException (com.dyngr.exception.PollerStoppedException)2 UserBreakException (com.dyngr.exception.UserBreakException)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)1