use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardNiFiServiceFacade method getAncestorGroupServiceIds.
private Set<String> getAncestorGroupServiceIds(final ProcessGroup group) {
final Set<String> ancestorServiceIds;
ProcessGroup parentGroup = group.getParent();
if (parentGroup == null) {
ancestorServiceIds = Collections.emptySet();
} else {
ancestorServiceIds = parentGroup.getControllerServices(true).stream().map(cs -> {
// We want to map the Controller Service to its Versioned Component ID, if it has one.
// If it does not have one, we want to generate it in the same way that our Flow Mapper does
// because this allows us to find the Controller Service when doing a Flow Diff.
final Optional<String> versionedId = cs.getVersionedComponentId();
if (versionedId.isPresent()) {
return versionedId.get();
}
return UUID.nameUUIDFromBytes(cs.getIdentifier().getBytes(StandardCharsets.UTF_8)).toString();
}).collect(Collectors.toSet());
}
return ancestorServiceIds;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class ControllerFacade method findProcessGroupIdForProcessor.
/**
* Returns the group id that contains the specified processor.
*
* @param processorId processor id
* @return group id
*/
public String findProcessGroupIdForProcessor(String processorId) {
final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
final ProcessorNode processor = rootGroup.findProcessor(processorId);
if (processor == null) {
return null;
} else {
return processor.getProcessGroup().getIdentifier();
}
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class ControllerFacade method getOutputPortStatus.
/**
* Gets the status for the specified output port.
*
* @param portId output port id
* @return the status for the specified output port
*/
public PortStatus getOutputPortStatus(final String portId) {
final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
final Port port = root.findOutputPort(portId);
// ensure the output port was found
if (port == null) {
throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId));
}
final String groupId = port.getProcessGroup().getIdentifier();
final ProcessGroupStatus processGroupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser());
if (processGroupStatus == null) {
throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
}
final PortStatus status = processGroupStatus.getOutputPortStatus().stream().filter(portStatus -> portId.equals(portStatus.getId())).findFirst().orElse(null);
if (status == null) {
throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId));
}
return status;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class ControllerFacade method getConnectionStatus.
/**
* Gets the status for the specified connection.
*
* @param connectionId connection id
* @return the status for the specified connection
*/
public ConnectionStatus getConnectionStatus(final String connectionId) {
final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
final Connection connection = root.findConnection(connectionId);
// ensure the connection was found
if (connection == null) {
throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId));
}
// calculate the process group status
final String groupId = connection.getProcessGroup().getIdentifier();
final ProcessGroupStatus processGroupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser());
if (processGroupStatus == null) {
throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
}
final ConnectionStatus status = processGroupStatus.getConnectionStatus().stream().filter(connectionStatus -> connectionId.equals(connectionStatus.getId())).findFirst().orElse(null);
if (status == null) {
throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId));
}
return status;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class ControllerFacade method getControllerStatus.
/**
* Gets the status of this controller.
*
* @return the status of this controller
*/
public ControllerStatusDTO getControllerStatus() {
final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
final QueueSize controllerQueueSize = flowController.getTotalFlowFileCount(rootGroup);
final ControllerStatusDTO controllerStatus = new ControllerStatusDTO();
controllerStatus.setActiveThreadCount(flowController.getActiveThreadCount());
controllerStatus.setQueued(FormatUtils.formatCount(controllerQueueSize.getObjectCount()) + " / " + FormatUtils.formatDataSize(controllerQueueSize.getByteCount()));
controllerStatus.setBytesQueued(controllerQueueSize.getByteCount());
controllerStatus.setFlowFilesQueued(controllerQueueSize.getObjectCount());
final ProcessGroupCounts counts = rootGroup.getCounts();
controllerStatus.setRunningCount(counts.getRunningCount());
controllerStatus.setStoppedCount(counts.getStoppedCount());
controllerStatus.setInvalidCount(counts.getInvalidCount());
controllerStatus.setDisabledCount(counts.getDisabledCount());
controllerStatus.setActiveRemotePortCount(counts.getActiveRemotePortCount());
controllerStatus.setInactiveRemotePortCount(counts.getInactiveRemotePortCount());
controllerStatus.setUpToDateCount(counts.getUpToDateCount());
controllerStatus.setLocallyModifiedCount(counts.getLocallyModifiedCount());
controllerStatus.setStaleCount(counts.getStaleCount());
controllerStatus.setLocallyModifiedAndStaleCount(counts.getLocallyModifiedAndStaleCount());
controllerStatus.setSyncFailureCount(counts.getSyncFailureCount());
return controllerStatus;
}
Aggregations