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);
}
};
}
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);
}
}
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());
}
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));
}
Aggregations