Search in sources :

Example 1 with DatahubRefreshWaitEvent

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);
}
Also used : DatahubRefreshWaitEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent) DatahubRefreshFailedEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshFailedEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) DatahubRefreshFlowEvent(com.sequenceiq.datalake.flow.refresh.DatahubRefreshFlowEvent) Event(reactor.bus.Event) DatahubRefreshFailedEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshFailedEvent) DatahubRefreshWaitEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with DatahubRefreshWaitEvent

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");
}
Also used : DatahubRefreshWaitEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with DatahubRefreshWaitEvent

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));
}
Also used : DatahubRefreshWaitEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) DatahubRefreshFlowEvent(com.sequenceiq.datalake.flow.refresh.DatahubRefreshFlowEvent) Event(reactor.bus.Event) DatahubRefreshFailedEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshFailedEvent) DatahubRefreshWaitEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with DatahubRefreshWaitEvent

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);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) DatahubRefreshWaitEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent) AbstractSdxAction(com.sequenceiq.datalake.service.AbstractSdxAction) Optional(java.util.Optional) DatahubRefreshFailedEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshFailedEvent) StateContext(org.springframework.statemachine.StateContext) Map(java.util.Map) DatahubRefreshStartEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshStartEvent) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Aggregations

DatahubRefreshWaitEvent (com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent)4 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)3 DatahubRefreshFailedEvent (com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshFailedEvent)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 PollerException (com.dyngr.exception.PollerException)2 PollerStoppedException (com.dyngr.exception.PollerStoppedException)2 UserBreakException (com.dyngr.exception.UserBreakException)2 DatahubRefreshFlowEvent (com.sequenceiq.datalake.flow.refresh.DatahubRefreshFlowEvent)2 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)2 Test (org.junit.jupiter.api.Test)2 Event (reactor.bus.Event)2 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 DatahubRefreshStartEvent (com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshStartEvent)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1