use of com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsWaitRequest in project cloudbreak by hortonworks.
the class SdxDiagnosticsCollectionHandlerTest method initEvent.
private Event<SdxDiagnosticsWaitRequest> initEvent() {
FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW, "pollableId");
SdxDiagnosticsWaitRequest request = new SdxDiagnosticsWaitRequest(1L, "userId", Map.of(), flowIdentifier);
return new Event<>(new Event.Headers(), request);
}
use of com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsWaitRequest 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;
}
use of com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsWaitRequest 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));
}
use of com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsWaitRequest 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));
}
use of com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsWaitRequest 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));
}
Aggregations