use of com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent in project cloudbreak by hortonworks.
the class DatahubRefreshHandlerTest method acceptWithExceptions.
@ParameterizedTest
@ValueSource(classes = { UserBreakException.class, PollerStoppedException.class, PollerException.class })
void acceptWithExceptions(Class<? extends Throwable> errorClass) throws Exception {
DatahubRefreshWaitEvent request = new DatahubRefreshWaitEvent(SDX_ID, "user");
Event.Headers headers = new Event.Headers();
Event<DatahubRefreshWaitEvent> event = new Event<>(headers, request);
doThrow(errorClass).when(sdxRefreshService).waitCloudbreakCluster(eq(SDX_ID), any(PollingConfig.class));
Selectable selectable = new ExceptionCatcherEventHandlerTestSupport<>(underTest).doAccept(event);
DatahubRefreshFailedEvent failedEvent = new DatahubRefreshFailedEvent(SDX_ID, "user", new Exception("error"));
assertThat(selectable).usingRecursiveComparison().isEqualTo(failedEvent);
}
use of com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent in project cloudbreak by hortonworks.
the class DatahubRefreshHandlerTest method defaultFailureEvent.
@Test
void defaultFailureEvent() {
Selectable failureEvent = underTest.defaultFailureEvent(SDX_ID, new Exception("error"), new Event<>(new DatahubRefreshWaitEvent(SDX_ID, "user")));
assertThat(failureEvent.selector()).isEqualTo("DATAHUBREFRESHFAILEDEVENT");
}
use of com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent in project cloudbreak by hortonworks.
the class DatahubRefreshHandlerTest method acceptSuccess.
@Test
void acceptSuccess() throws Exception {
DatahubRefreshWaitEvent request = new DatahubRefreshWaitEvent(SDX_ID, "user");
PollingConfig expectedPollingConfig = new PollingConfig(1, TimeUnit.SECONDS, 2, TimeUnit.MINUTES);
Event.Headers headers = new Event.Headers();
Event<DatahubRefreshWaitEvent> event = new Event<>(headers, request);
Selectable selectable = new ExceptionCatcherEventHandlerTestSupport<>(underTest).doAccept(event);
assertEquals(selectable.selector(), DatahubRefreshFlowEvent.DATAHUB_REFRESH_FINISHED_EVENT.selector());
verify(sdxRefreshService).waitCloudbreakCluster(eq(SDX_ID), refEq(expectedPollingConfig));
}
use of com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent in project cloudbreak by hortonworks.
the class DatahubRefreshActions method datahubRefreshInProgressAction.
@Bean(name = "DATAHUB_REFRESH_IN_PROGRESS_STATE")
public Action<?, ?> datahubRefreshInProgressAction() {
return new AbstractSdxAction<>(DatahubRefreshStartEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatahubRefreshStartEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, DatahubRefreshStartEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Datahub refresh in progress for: {}", payload.getResourceId());
sendEvent(context, new DatahubRefreshWaitEvent(payload.getResourceId(), payload.getUserId()));
}
@Override
protected Object getFailurePayload(DatahubRefreshStartEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new DatahubRefreshFailedEvent(payload.getResourceId(), payload.getUserId(), ex);
}
};
}
Aggregations