use of com.sequenceiq.cloudbreak.core.flow2.config.FlowConfiguration in project cloudbreak by hortonworks.
the class Flow2ConfigTest method testFlowConfigurationMapInitIfAlreadyExists.
@Test
public void testFlowConfigurationMapInitIfAlreadyExists() {
List<FlowConfiguration<?>> flowConfigs = new ArrayList<>();
StackSyncFlowConfig stackSyncFlowConfig = new StackSyncFlowConfig();
flowConfigs.add(stackSyncFlowConfig);
flowConfigs.add(stackSyncFlowConfig);
given(this.flowConfigs.iterator()).willReturn(flowConfigs.iterator());
thrown.expect(UnsupportedOperationException.class);
thrown.expectMessage("Event already registered: STACK_SYNC_TRIGGER_EVENT");
underTest.flowConfigurationMap();
}
use of com.sequenceiq.cloudbreak.core.flow2.config.FlowConfiguration in project cloudbreak by hortonworks.
the class Flow2InitializerTest method testInitialize.
@Test
public void testInitialize() {
List<FlowConfiguration<?>> flowConfigs = new ArrayList<>();
flowConfigs.add(new StackSyncFlowConfig());
flowConfigs.add(new StackTerminationFlowConfig());
given(this.flowConfigs.stream()).willReturn(flowConfigs.stream());
underTest.init();
verify(reactor, times(1)).on(any(Selector.class), any(Consumer.class));
}
use of com.sequenceiq.cloudbreak.core.flow2.config.FlowConfiguration in project cloudbreak by hortonworks.
the class Flow2Handler method restartFlow.
public void restartFlow(String flowId) {
FlowLog flowLog = flowLogRepository.findFirstByFlowIdOrderByCreatedDesc(flowId);
if (RESTARTABLE_FLOWS.contains(flowLog.getFlowType())) {
Optional<FlowConfiguration<?>> flowConfig = flowConfigs.stream().filter(fc -> fc.getClass().equals(flowLog.getFlowType())).findFirst();
Payload payload = (Payload) JsonReader.jsonToJava(flowLog.getPayload());
Flow flow = flowConfig.get().createFlow(flowId, payload.getStackId());
runningFlows.put(flow, flowLog.getFlowChainId());
if (flowLog.getFlowChainId() != null) {
flowChainHandler.restoreFlowChain(flowLog.getFlowChainId());
}
Map<Object, Object> variables = (Map<Object, Object>) JsonReader.jsonToJava(flowLog.getVariables());
flow.initialize(flowLog.getCurrentState(), variables);
RestartAction restartAction = flowConfig.get().getRestartAction(flowLog.getNextEvent());
if (restartAction != null) {
restartAction.restart(flowId, flowLog.getFlowChainId(), flowLog.getNextEvent(), payload);
return;
}
}
flowLogService.terminate(flowLog.getStackId(), flowId);
}
Aggregations