Search in sources :

Example 26 with ProcessGroup

use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.

the class ControllerFacade method getProcessGroupStatusHistory.

/**
 * Returns the status history for the specified process group.
 *
 * @param groupId group id
 * @return status history
 */
public StatusHistoryDTO getProcessGroupStatusHistory(final String groupId) {
    final String searchId = groupId.equals(ROOT_GROUP_ID_ALIAS) ? flowController.getRootGroupId() : groupId;
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
    final ProcessGroup group = root.findProcessGroup(searchId);
    // ensure the processor was found
    if (group == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate process group with id '%s'.", groupId));
    }
    final StatusHistoryDTO statusHistory = flowController.getProcessGroupStatusHistory(groupId);
    // if not authorized
    if (!group.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser())) {
        statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, groupId);
    }
    return statusHistory;
}
Also used : StatusHistoryDTO(org.apache.nifi.web.api.dto.status.StatusHistoryDTO) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 27 with ProcessGroup

use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.

the class ControllerFacade method getOutputPorts.

/**
 * Gets the output ports on the root group.
 *
 * @return output ports
 */
public Set<RootGroupPort> getOutputPorts() {
    final Set<RootGroupPort> outputPorts = new HashSet<>();
    ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    for (final Port port : rootGroup.getOutputPorts()) {
        if (port instanceof RootGroupPort) {
            outputPorts.add((RootGroupPort) port);
        }
    }
    return outputPorts;
}
Also used : RootGroupPort(org.apache.nifi.remote.RootGroupPort) 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) HashSet(java.util.HashSet)

Example 28 with ProcessGroup

use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.

the class ControllerFacade method getInputPorts.

/**
 * Gets the input ports on the root group.
 *
 * @return input ports
 */
public Set<RootGroupPort> getInputPorts() {
    final Set<RootGroupPort> inputPorts = new HashSet<>();
    ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    for (final Port port : rootGroup.getInputPorts()) {
        if (port instanceof RootGroupPort) {
            inputPorts.add((RootGroupPort) port);
        }
    }
    return inputPorts;
}
Also used : RootGroupPort(org.apache.nifi.remote.RootGroupPort) 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) HashSet(java.util.HashSet)

Example 29 with ProcessGroup

use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.

the class ControllerFacade method getInputPortStatus.

/**
 * Gets the status for the specified input port.
 *
 * @param portId input port id
 * @return the status for the specified input port
 */
public PortStatus getInputPortStatus(final String portId) {
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
    final Port port = root.findInputPort(portId);
    // ensure the input port was found
    if (port == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate input 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.getInputPortStatus().stream().filter(portStatus -> portId.equals(portStatus.getId())).findFirst().orElse(null);
    if (status == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate input 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 30 with ProcessGroup

use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.

the class ControllerFacade method getRemoteProcessGroupStatusHistory.

/**
 * Returns the status history for the specified remote process group.
 *
 * @param remoteProcessGroupId remote process group id
 * @return status history
 */
public StatusHistoryDTO getRemoteProcessGroupStatusHistory(final String remoteProcessGroupId) {
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
    final RemoteProcessGroup remoteProcessGroup = root.findRemoteProcessGroup(remoteProcessGroupId);
    // ensure the output port was found
    if (remoteProcessGroup == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId));
    }
    final StatusHistoryDTO statusHistory = flowController.getRemoteProcessGroupStatusHistory(remoteProcessGroupId);
    // if not authorized
    if (!remoteProcessGroup.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser())) {
        statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, remoteProcessGroupId);
        statusHistory.getComponentDetails().remove(ComponentStatusRepository.COMPONENT_DETAIL_URI);
    }
    return statusHistory;
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) StatusHistoryDTO(org.apache.nifi.web.api.dto.status.StatusHistoryDTO) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

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