Search in sources :

Example 1 with SdxCmSyncWaitEvent

use of com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncWaitEvent in project cloudbreak by hortonworks.

the class SdxCmSyncActions method waitForCoreCmSync.

@Bean(name = "CORE_CM_SYNC_IN_PROGRESS_STATE")
public Action<?, ?> waitForCoreCmSync() {
    return new AbstractSdxCmSyncAction<>(SdxEvent.class) {

        @Override
        protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) {
            SdxCmSyncWaitEvent sdxCmSyncWaitEvent = new SdxCmSyncWaitEvent(context);
            sendEvent(context, sdxCmSyncWaitEvent);
        }
    };
}
Also used : SdxCmSyncWaitEvent(com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncWaitEvent) SdxEvent(com.sequenceiq.datalake.flow.SdxEvent) Map(java.util.Map) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Example 2 with SdxCmSyncWaitEvent

use of com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncWaitEvent in project cloudbreak by hortonworks.

the class SdxCmSyncWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SdxCmSyncWaitEvent> event) {
    LOGGER.debug("Entering handler for calling sync CM and parcel versions from CM server");
    SdxCmSyncWaitEvent sdxCmSyncWaitEvent = event.getData();
    try {
        SdxCluster sdxCluster = sdxService.getById(sdxCmSyncWaitEvent.getResourceId());
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES).withStopPollingIfExceptionOccurred(true);
        sdxWaitService.waitForCloudbreakFlow(sdxCluster, pollingConfig, "Sync cm");
        return new SdxEvent(SDX_CM_SYNC_FINISHED_EVENT.event(), event.getData().getResourceId(), event.getData().getUserId());
    } catch (SdxWaitException e) {
        LOGGER.warn("Error happened during waiting for syncing CM and parcel versions from a datalake CM to component table {}, error: ", sdxCmSyncWaitEvent.getResourceId(), e);
        return new SdxCmSyncFailedEvent(sdxCmSyncWaitEvent.getResourceId(), sdxCmSyncWaitEvent.getUserId(), e);
    }
}
Also used : SdxCmSyncWaitEvent(com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncWaitEvent) SdxWaitException(com.sequenceiq.datalake.service.sdx.flowwait.exception.SdxWaitException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) SdxEvent(com.sequenceiq.datalake.flow.SdxEvent) SdxCmSyncFailedEvent(com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncFailedEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig)

Example 3 with SdxCmSyncWaitEvent

use of com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncWaitEvent in project cloudbreak by hortonworks.

the class SdxCmSyncWaitHandlerTest method testDefaultFailureEvent.

@Test
void testDefaultFailureEvent() {
    RuntimeException exception = new RuntimeException();
    SdxCmSyncWaitEvent sdxCmSyncWaitEvent = mock(SdxCmSyncWaitEvent.class);
    when(sdxCmSyncWaitEvent.getUserId()).thenReturn(USER_ID);
    Selectable failureSelectable = underTest.defaultFailureEvent(SDX_ID, exception, new Event<>(sdxCmSyncWaitEvent));
    assertEquals("SDXCMSYNCFAILEDEVENT", failureSelectable.selector());
    assertEquals(SDX_ID, failureSelectable.getResourceId());
    assertEquals(exception, ((SdxCmSyncFailedEvent) failureSelectable).getException());
}
Also used : SdxCmSyncWaitEvent(com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncWaitEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Test(org.junit.jupiter.api.Test)

Example 4 with SdxCmSyncWaitEvent

use of com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncWaitEvent in project cloudbreak by hortonworks.

the class SdxCmSyncWaitHandlerTest method getEvent.

private HandlerEvent<SdxCmSyncWaitEvent> getEvent() {
    SdxCmSyncWaitEvent sdxCmSyncWaitEvent = mock(SdxCmSyncWaitEvent.class);
    when(sdxCmSyncWaitEvent.getResourceId()).thenReturn(SDX_ID);
    return new HandlerEvent<>(new Event<>(sdxCmSyncWaitEvent));
}
Also used : SdxCmSyncWaitEvent(com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncWaitEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent)

Aggregations

SdxCmSyncWaitEvent (com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncWaitEvent)4 SdxEvent (com.sequenceiq.datalake.flow.SdxEvent)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 SdxCmSyncFailedEvent (com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncFailedEvent)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)1 SdxWaitException (com.sequenceiq.datalake.service.sdx.flowwait.exception.SdxWaitException)1 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)1 Map (java.util.Map)1 Test (org.junit.jupiter.api.Test)1 Bean (org.springframework.context.annotation.Bean)1