use of org.apache.nifi.controller.status.ProcessGroupStatus in project nifi by apache.
the class TestNiFiFlowAnalyzer method testEmptyFlow.
@Test
public void testEmptyFlow() throws Exception {
ProcessGroupStatus rootPG = createEmptyProcessGroupStatus();
final NiFiFlowAnalyzer analyzer = new NiFiFlowAnalyzer();
final NiFiFlow nifiFlow = new NiFiFlow(rootPG.getId());
nifiFlow.setClusterName("cluster1");
analyzer.analyzeProcessGroup(nifiFlow, rootPG);
assertEquals("1234-5678-0000-0000@cluster1", nifiFlow.getQualifiedName());
}
use of org.apache.nifi.controller.status.ProcessGroupStatus in project nifi by apache.
the class TestNiFiFlowAnalyzer method createEmptyProcessGroupStatus.
private ProcessGroupStatus createEmptyProcessGroupStatus() {
final ProcessGroupStatus processGroupStatus = new ProcessGroupStatus();
processGroupStatus.setId(nextComponentId());
processGroupStatus.setName("Flow name");
return processGroupStatus;
}
use of org.apache.nifi.controller.status.ProcessGroupStatus in project nifi by apache.
the class TestNiFiFlowAnalyzer method connect.
private void connect(ProcessGroupStatus pg0, Object o0, Object o1) {
Function<Object, Tuple<String, String>> toTupple = o -> {
Tuple<String, String> comp;
if (o instanceof ProcessorStatus) {
ProcessorStatus p = (ProcessorStatus) o;
comp = new Tuple<>(p.getId(), p.getName());
} else if (o instanceof PortStatus) {
PortStatus p = (PortStatus) o;
comp = new Tuple<>(p.getId(), p.getName());
} else {
throw new IllegalArgumentException("Not supported");
}
return comp;
};
connect(pg0, toTupple.apply(o0), toTupple.apply(o1));
}
use of org.apache.nifi.controller.status.ProcessGroupStatus in project nifi by apache.
the class ControllerStatusReportingTask method onTrigger.
@Override
public void onTrigger(final ReportingContext context) {
final ProcessGroupStatus controllerStatus = context.getEventAccess().getControllerStatus();
final boolean showDeltas = context.getProperty(SHOW_DELTAS).asBoolean();
final StringBuilder builder = new StringBuilder();
builder.append("Processor Statuses:\n");
builder.append(processorBorderLine);
builder.append("\n");
builder.append(processorHeader);
builder.append(processorBorderLine);
builder.append("\n");
printProcessorStatus(controllerStatus, builder, showDeltas);
builder.append(processorBorderLine);
processorLogger.info(builder.toString());
builder.setLength(0);
builder.append("Connection Statuses:\n");
builder.append(connectionBorderLine);
builder.append("\n");
builder.append(connectionHeader);
builder.append(connectionBorderLine);
builder.append("\n");
printConnectionStatus(controllerStatus, builder, showDeltas);
builder.append(connectionBorderLine);
connectionLogger.info(builder.toString());
}
use of org.apache.nifi.controller.status.ProcessGroupStatus in project nifi by apache.
the class StandardNiFiServiceFacade method postProcessNewFlowSnippet.
/**
* Post processes a new flow snippet including validation, removing the snippet, and DTO conversion.
*
* @param groupId group id
* @param snippet snippet
* @return flow dto
*/
private FlowDTO postProcessNewFlowSnippet(final String groupId, final FlowSnippetDTO snippet) {
// validate the new snippet
validateSnippetContents(snippet);
// identify all components added
final Set<String> identifiers = new HashSet<>();
snippet.getProcessors().stream().map(proc -> proc.getId()).forEach(id -> identifiers.add(id));
snippet.getConnections().stream().map(conn -> conn.getId()).forEach(id -> identifiers.add(id));
snippet.getInputPorts().stream().map(port -> port.getId()).forEach(id -> identifiers.add(id));
snippet.getOutputPorts().stream().map(port -> port.getId()).forEach(id -> identifiers.add(id));
snippet.getProcessGroups().stream().map(group -> group.getId()).forEach(id -> identifiers.add(id));
snippet.getRemoteProcessGroups().stream().map(remoteGroup -> remoteGroup.getId()).forEach(id -> identifiers.add(id));
snippet.getRemoteProcessGroups().stream().filter(remoteGroup -> remoteGroup.getContents() != null && remoteGroup.getContents().getInputPorts() != null).flatMap(remoteGroup -> remoteGroup.getContents().getInputPorts().stream()).map(remoteInputPort -> remoteInputPort.getId()).forEach(id -> identifiers.add(id));
snippet.getRemoteProcessGroups().stream().filter(remoteGroup -> remoteGroup.getContents() != null && remoteGroup.getContents().getOutputPorts() != null).flatMap(remoteGroup -> remoteGroup.getContents().getOutputPorts().stream()).map(remoteOutputPort -> remoteOutputPort.getId()).forEach(id -> identifiers.add(id));
snippet.getLabels().stream().map(label -> label.getId()).forEach(id -> identifiers.add(id));
final ProcessGroup group = processGroupDAO.getProcessGroup(groupId);
final ProcessGroupStatus groupStatus = controllerFacade.getProcessGroupStatus(groupId);
return dtoFactory.createFlowDto(group, groupStatus, snippet, revisionManager, this::getProcessGroupBulletins);
}
Aggregations