use of com.sequenceiq.flow.domain.FlowChainLog in project cloudbreak by hortonworks.
the class FlowChainHandler method restoreFlowChain.
public void restoreFlowChain(String flowChainId) {
Optional<FlowChainLog> chainLog = flowLogService.findFirstByFlowChainIdOrderByCreatedDesc(flowChainId);
if (chainLog.isPresent()) {
String flowChainType = chainLog.get().getFlowChainType();
Queue<Selectable> queue = (Queue<Selectable>) JsonReader.jsonToJava(chainLog.get().getChain());
Payload triggerEvent = tryDeserializeTriggerEvent(chainLog.get());
FlowTriggerEventQueue chain = new FlowTriggerEventQueue(flowChainType, triggerEvent, queue);
if (chainLog.get().getParentFlowChainId() != null) {
chain.setParentFlowChainId(chainLog.get().getParentFlowChainId());
}
flowChains.putFlowChain(flowChainId, chainLog.get().getParentFlowChainId(), chain);
Selectable selectable = queue.peek();
if (selectable != null) {
OperationType operationType = flowChainOperationTypeConfig.getFlowTypeOperationTypeMap().getOrDefault(flowChainType, OperationType.UNKNOWN);
flowStatCache.putByFlowChainId(flowChainId, selectable.getResourceId(), operationType.name(), true);
}
if (chainLog.get().getParentFlowChainId() != null) {
restoreFlowChain(chainLog.get().getParentFlowChainId());
}
}
}
use of com.sequenceiq.flow.domain.FlowChainLog in project cloudbreak by hortonworks.
the class FlowLogDBService method saveChain.
@Override
public void saveChain(String flowChainId, String parentFlowChainId, FlowTriggerEventQueue chain, String flowTriggerUserCrn) {
String chainType = chain.getFlowChainName();
String chainJson = JsonWriter.objectToJson(chain.getQueue());
String triggerEventJson = null;
if (chain.getTriggerEvent() != null) {
triggerEventJson = JsonWriter.objectToJson(chain.getTriggerEvent(), writeOptions);
}
FlowChainLog chainLog = new FlowChainLog(chainType, flowChainId, parentFlowChainId, chainJson, flowTriggerUserCrn, triggerEventJson);
flowChainLogService.save(chainLog);
}
use of com.sequenceiq.flow.domain.FlowChainLog in project cloudbreak by hortonworks.
the class FlowService method getRelatedFlowChainLogs.
private List<FlowChainLog> getRelatedFlowChainLogs(List<FlowChainLog> sourceFlowChains) {
Optional<FlowChainLog> flowChainWithParent = sourceFlowChains.stream().filter(flowChainLog -> StringUtils.isNotBlank(flowChainLog.getParentFlowChainId())).findFirst();
FlowChainLog lastFlowChain = sourceFlowChains.stream().max(Comparator.comparing(FlowChainLog::getCreated)).get();
FlowChainLog inputFlowChain = flowChainWithParent.orElse(lastFlowChain);
return flowChainLogService.collectRelatedFlowChains(inputFlowChain);
}
use of com.sequenceiq.flow.domain.FlowChainLog in project cloudbreak by hortonworks.
the class FlowChainLogService method hasEventInFlowChainQueue.
public boolean hasEventInFlowChainQueue(List<FlowChainLog> flowChains) {
Map<String, List<FlowChainLog>> byFlowChainId = flowChains.stream().collect(Collectors.groupingBy(FlowChainLog::getFlowChainId, toList()));
return byFlowChainId.entrySet().stream().anyMatch(entry -> {
FlowChainLog latestFlowChain = entry.getValue().stream().sorted(comparing(FlowChainLog::getCreated).reversed()).findFirst().get();
LOGGER.debug("Checking if chain with id {} has any event in it's queue", latestFlowChain.getFlowChainId());
LOGGER.trace("Chain string in db: {}", latestFlowChain.getChain());
Queue<Selectable> chain = (Queue<Selectable>) JsonReader.jsonToJava(latestFlowChain.getChain());
return !chain.isEmpty();
});
}
use of com.sequenceiq.flow.domain.FlowChainLog in project cloudbreak by hortonworks.
the class FlowServiceTest method flowChainLog.
private FlowChainLog flowChainLog() {
FlowChainLog flowChainLog = new FlowChainLog();
flowChainLog.setFlowChainId(FLOW_CHAIN_ID);
return flowChainLog;
}
Aggregations