use of com.sequenceiq.flow.domain.FlowChainLog in project cloudbreak by hortonworks.
the class FlowService method getFlowChainState.
public FlowCheckResponse getFlowChainState(String chainId) {
FlowCheckResponse flowCheckResponse = new FlowCheckResponse();
flowCheckResponse.setFlowChainId(chainId);
List<FlowChainLog> flowChains = flowChainLogService.findByFlowChainIdOrderByCreatedDesc(chainId);
if (!flowChains.isEmpty()) {
LOGGER.info("Checking if there is an active flow based on flow chain id {}", chainId);
List<FlowChainLog> relatedChains = getRelatedFlowChainLogs(flowChains);
Set<String> relatedChainIds = relatedChains.stream().map(FlowChainLog::getFlowChainId).collect(toSet());
Set<String> relatedFlowIds = flowLogDBService.getFlowIdsByChainIds(relatedChainIds);
List<FlowLog> relatedFlowLogs = flowLogDBService.getFlowLogsByFlowIdsCreatedDesc(relatedFlowIds);
flowCheckResponse.setHasActiveFlow(!completed("Flow chain", chainId, relatedChains, relatedFlowLogs));
flowCheckResponse.setLatestFlowFinalizedAndFailed(isFlowInFailedState(relatedFlowLogs, failHandledEvents));
return flowCheckResponse;
} else {
flowCheckResponse.setHasActiveFlow(Boolean.FALSE);
return flowCheckResponse;
}
}
use of com.sequenceiq.flow.domain.FlowChainLog in project cloudbreak by hortonworks.
the class FlowChainLogService method collectRelatedFlowChains.
public List<FlowChainLog> collectRelatedFlowChains(FlowChainLog flowChain) {
LOGGER.info("Finding out master flow chain based on chain id {}", flowChain.getFlowChainId());
FlowChainLog rootFlowChain = collectRootFlowChain(flowChain);
LOGGER.info("Collecting child flow chains based on master chain id {}", rootFlowChain.getFlowChainId());
Map<String, FlowChainLog> flowChains = new HashMap<>();
flowChains.put(rootFlowChain.getFlowChainId(), rootFlowChain);
collectChildFlowChains(flowChains, rootFlowChain);
LOGGER.info("Collected flow chain ids for checking: {}", Joiner.on(",").join(flowChains.keySet()));
return flowChains.values().stream().sorted(comparing(FlowChainLog::getCreated)).collect(toList());
}
use of com.sequenceiq.flow.domain.FlowChainLog in project cloudbreak by hortonworks.
the class FlowChains method getRootTriggerEvent.
public Optional<Pair<String, Payload>> getRootTriggerEvent(String flowChainId) {
String rootFlowChainId = getRootFlowChainId(flowChainId);
FlowTriggerEventQueue flowTriggerEventQueue = flowChainMap.get(rootFlowChainId);
if (flowTriggerEventQueue != null) {
return Optional.of(Pair.of(rootFlowChainId, flowTriggerEventQueue.getTriggerEvent()));
}
Optional<FlowChainLog> initFlowChainLog = flowChainLogService.findRootInitFlowChainLog(flowChainId);
if (initFlowChainLog.isEmpty()) {
return Optional.empty();
}
LOGGER.info("Found root init flow chain log {} for flow chain {}", initFlowChainLog.get(), flowChainId);
Payload triggerEvent = FlowLogUtil.tryDeserializeTriggerEvent(initFlowChainLog.get());
if (triggerEvent == null) {
return Optional.empty();
} else {
return Optional.of(Pair.of(initFlowChainLog.get().getFlowChainId(), triggerEvent));
}
}
Aggregations