public void analyzePaths(NiFiFlow nifiFlow) { final String rootProcessGroupId = nifiFlow.getRootProcessGroupId(); // Now let's break it into flow paths. final Map<String, ProcessorStatus> processors = nifiFlow.getProcessors(); final Set<String> headProcessComponents = processors.keySet().stream() .filter(pid -> { final List<ConnectionStatus> ins = nifiFlow.getIncomingConnections(pid); return isHeadProcessor(nifiFlow, ins); }) .collect(Collectors.toSet()); // Use RootInputPorts as headProcessors. headProcessComponents.addAll(nifiFlow.getRootInputPorts().keySet()); headProcessComponents.forEach(startPid -> { // By using the startPid as its qualifiedName, it's guaranteed that // the same path will end up being the same Atlas entity. // However, if the first processor is replaced by another, // the flow path will have a different id, and the old path is logically deleted. final NiFiFlowPath path = nifiFlow.getOrCreateFlowPath(startPid); traverse(nifiFlow, path, startPid); }); nifiFlow.getFlowPaths().values().forEach(path -> { if (processors.containsKey(path.getId())) { final ProcessorStatus processor = processors.get(path.getId()); path.setGroupId(processor.getGroupId()); } else { path.setGroupId(rootProcessGroupId); } }); }
public static ComponentDetails forProcessor(final ProcessorStatus status) { return forProcessor(status.getId(), status.getGroupId(), status.getName(), status.getType()); }
public ProcessorStatusDTO createProcessorStatusDto(final ProcessorStatus procStatus) { final ProcessorStatusDTO dto = new ProcessorStatusDTO(); dto.setId(procStatus.getId()); dto.setGroupId(procStatus.getGroupId()); dto.setName(procStatus.getName()); dto.setStatsLastRefreshed(new Date()); dto.setRunStatus(procStatus.getRunStatus().toString()); final ProcessorStatusSnapshotDTO snapshot = new ProcessorStatusSnapshotDTO(); dto.setAggregateSnapshot(snapshot); snapshot.setId(procStatus.getId()); snapshot.setGroupId(procStatus.getGroupId()); snapshot.setName(procStatus.getName()); snapshot.setFlowFilesOut(procStatus.getOutputCount()); snapshot.setBytesOut(procStatus.getOutputBytes()); snapshot.setFlowFilesIn(procStatus.getInputCount()); snapshot.setBytesIn(procStatus.getInputBytes()); snapshot.setBytesRead(procStatus.getBytesRead()); snapshot.setBytesWritten(procStatus.getBytesWritten()); snapshot.setTaskCount(procStatus.getInvocations()); snapshot.setTasksDurationNanos(procStatus.getProcessingNanos()); snapshot.setTasksDuration(FormatUtils.formatHoursMinutesSeconds(procStatus.getProcessingNanos(), TimeUnit.NANOSECONDS)); // determine the run status snapshot.setRunStatus(procStatus.getRunStatus().toString()); snapshot.setExecutionNode(procStatus.getExecutionNode().toString()); snapshot.setActiveThreadCount(procStatus.getActiveThreadCount()); snapshot.setTerminatedThreadCount(procStatus.getTerminatedThreadCount()); snapshot.setType(procStatus.getType()); StatusMerger.updatePrettyPrintedFields(snapshot); return dto; }
public void analyzePaths(NiFiFlow nifiFlow) { final String rootProcessGroupId = nifiFlow.getRootProcessGroupId(); // Now let's break it into flow paths. final Map<String, ProcessorStatus> processors = nifiFlow.getProcessors(); final Set<String> headProcessComponents = processors.keySet().stream() .filter(pid -> { final List<ConnectionStatus> ins = nifiFlow.getIncomingConnections(pid); return isHeadProcessor(nifiFlow, ins); }) .collect(Collectors.toSet()); // Use RootInputPorts as headProcessors. headProcessComponents.addAll(nifiFlow.getRootInputPorts().keySet()); headProcessComponents.forEach(startPid -> { // By using the startPid as its qualifiedName, it's guaranteed that // the same path will end up being the same Atlas entity. // However, if the first processor is replaced by another, // the flow path will have a different id, and the old path is logically deleted. final NiFiFlowPath path = nifiFlow.getOrCreateFlowPath(startPid); traverse(nifiFlow, path, startPid); }); nifiFlow.getFlowPaths().values().forEach(path -> { if (processors.containsKey(path.getId())) { final ProcessorStatus processor = processors.get(path.getId()); path.setGroupId(processor.getGroupId()); } else { path.setGroupId(rootProcessGroupId); } }); }