Search in sources :

Example 21 with ProcessGroup

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;
}
Also used : VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) InstantiatedVersionedProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup)

Example 22 with ProcessGroup

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();
    }
}
Also used : ProcessorNode(org.apache.nifi.controller.ProcessorNode) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup)

Example 23 with ProcessGroup

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;
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) PortStatus(org.apache.nifi.controller.status.PortStatus) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 24 with ProcessGroup

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;
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) Connection(org.apache.nifi.connectable.Connection) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException) ConnectionStatus(org.apache.nifi.controller.status.ConnectionStatus)

Example 25 with ProcessGroup

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;
}
Also used : QueueSize(org.apache.nifi.controller.queue.QueueSize) ControllerStatusDTO(org.apache.nifi.web.api.dto.status.ControllerStatusDTO) ProcessGroupCounts(org.apache.nifi.groups.ProcessGroupCounts) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup)

Aggregations

ProcessGroup (org.apache.nifi.groups.ProcessGroup)185 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)97 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)68 ProcessorNode (org.apache.nifi.controller.ProcessorNode)50 Port (org.apache.nifi.connectable.Port)40 RootGroupPort (org.apache.nifi.remote.RootGroupPort)37 Connection (org.apache.nifi.connectable.Connection)36 ArrayList (java.util.ArrayList)35 InstantiatedVersionedProcessGroup (org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup)35 Test (org.junit.Test)35 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)34 HashSet (java.util.HashSet)32 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)32 ResourceNotFoundException (org.apache.nifi.web.ResourceNotFoundException)29 FlowController (org.apache.nifi.controller.FlowController)27 Connectable (org.apache.nifi.connectable.Connectable)26 VersionControlInformation (org.apache.nifi.registry.flow.VersionControlInformation)25 Funnel (org.apache.nifi.connectable.Funnel)24 List (java.util.List)22 Label (org.apache.nifi.controller.label.Label)22