use of com.sequenceiq.cloudbreak.common.event.Payload in project cloudbreak by hortonworks.
the class EventBusConfigTest method uncaughtErrorButFlowFound.
@Test
@DirtiesContext(methodMode = DirtiesContext.MethodMode.AFTER_METHOD)
public void uncaughtErrorButFlowFound() {
FlowLog flowLog = new FlowLog();
flowLog.setFlowId("123");
when(flowLogDBService.getLastFlowLog("123")).thenReturn(Optional.of(flowLog));
Event.Headers headers = new Event.Headers();
headers.set("FLOW_ID", "123");
eventBus.on(Selectors.regex("exampleselector"), (Consumer<Event<? extends Payload>>) event -> {
throw new RuntimeException("uncaught exception");
});
eventBus.notify("exampleselector", new Event<>(headers, null));
verify(flowLogDBService, timeout(2000).times(1)).getLastFlowLog("123");
verify(applicationFlowInformation, timeout(1000).times(1)).handleFlowFail(flowLog);
verify(flowLogDBService, timeout(1000).times(1)).updateLastFlowLogStatus(flowLog, true);
verify(flowLogDBService, timeout(1000).times(1)).finalize(flowLog.getFlowId());
}
use of com.sequenceiq.cloudbreak.common.event.Payload in project cloudbreak by hortonworks.
the class FlowCancelService method cancelRunningFlows.
public void cancelRunningFlows(Long resourceId) {
LOGGER.info("Cancel running flow for id: [{}]", resourceId);
Payload cancelEvent = () -> resourceId;
reactor.notify(FlowConstants.FLOW_CANCEL, eventFactory.createEventWithErrHandler(eventParameterFactory.createEventParameters(resourceId), cancelEvent));
}
use of com.sequenceiq.cloudbreak.common.event.Payload in project cloudbreak by hortonworks.
the class FlowLogDBServiceTest method updateLastFlowLogPayload.
@Test
public void updateLastFlowLogPayload() {
FlowLog flowLog = new FlowLog();
flowLog.setId(ID);
Payload payload = mock(Selectable.class);
Map<Object, Object> variables = Map.of("repeated", 2);
underTest.updateLastFlowLogPayload(flowLog, payload, variables);
ArgumentCaptor<FlowLog> flowLogCaptor = ArgumentCaptor.forClass(FlowLog.class);
verify(flowLogRepository, times(1)).save(flowLogCaptor.capture());
FlowLog savedFlowLog = flowLogCaptor.getValue();
assertEquals(flowLog.getId(), savedFlowLog.getId());
String payloadJson = JsonWriter.objectToJson(payload, Map.of());
String variablesJson = JsonWriter.objectToJson(variables, Map.of());
assertEquals(payloadJson, savedFlowLog.getPayload());
assertEquals(variablesJson, savedFlowLog.getVariables());
}
use of com.sequenceiq.cloudbreak.common.event.Payload in project cloudbreak by hortonworks.
the class FillInMemoryStateStoreRestartAction method restart.
@Override
public void restart(FlowParameters flowParameters, String flowChainId, String event, Object payload) {
Payload stackPayload = (Payload) payload;
Stack stack = stackService.getByIdWithListsInTransaction(stackPayload.getResourceId());
restart(flowParameters, flowChainId, event, payload, stack);
}
use of com.sequenceiq.cloudbreak.common.event.Payload in project cloudbreak by hortonworks.
the class StackStopRestartAction method restart.
@Override
public void restart(FlowParameters flowParameters, String flowChainId, String event, Object payload) {
Payload stackPayload = (Payload) payload;
stackUpdater.updateStackStatus(stackPayload.getResourceId(), DetailedStackStatus.STOP_REQUESTED, "Stop/restart");
Stack stack = stackService.getByIdWithListsInTransaction(stackPayload.getResourceId());
MDCBuilder.buildMdcContext(stack);
super.restart(flowParameters, flowChainId, event, payload);
}
Aggregations