Java Code Examples for org.apache.nifi.groups.ProcessGroup#findLocalConnectable()

The following examples show how to use org.apache.nifi.groups.ProcessGroup#findLocalConnectable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardProcessGroupDAO.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void verifyScheduleComponents(final String groupId, final ScheduledState state,final Set<String> componentIds) {
    final ProcessGroup group = locateProcessGroup(flowController, groupId);

    final Set<Connectable> connectables = new HashSet<>(componentIds.size());
    for (final String componentId : componentIds) {
        final Connectable connectable = group.findLocalConnectable(componentId);
        if (connectable == null) {
            throw new ResourceNotFoundException("Unable to find component with id " + componentId);
        }

        connectables.add(connectable);
    }

    // verify as appropriate
    connectables.forEach(connectable -> {
        if (ScheduledState.RUNNING.equals(state)) {
            group.verifyCanStart(connectable);
        } else {
            group.verifyCanStop(connectable);
        }
    });
}
 
Example 2
Source File: StandardProcessGroupDAO.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void scheduleComponents(final String groupId, final ScheduledState state, final Set<String> componentIds) {
    final ProcessGroup group = locateProcessGroup(flowController, groupId);

    for (final String componentId : componentIds) {
        final Connectable connectable = group.findLocalConnectable(componentId);
        if (ScheduledState.RUNNING.equals(state)) {
            if (ConnectableType.PROCESSOR.equals(connectable.getConnectableType())) {
                connectable.getProcessGroup().startProcessor((ProcessorNode) connectable);
            } else if (ConnectableType.INPUT_PORT.equals(connectable.getConnectableType())) {
                connectable.getProcessGroup().startInputPort((Port) connectable);
            } else if (ConnectableType.OUTPUT_PORT.equals(connectable.getConnectableType())) {
                connectable.getProcessGroup().startOutputPort((Port) connectable);
            }
        } else {
            if (ConnectableType.PROCESSOR.equals(connectable.getConnectableType())) {
                connectable.getProcessGroup().stopProcessor((ProcessorNode) connectable);
            } else if (ConnectableType.INPUT_PORT.equals(connectable.getConnectableType())) {
                connectable.getProcessGroup().stopInputPort((Port) connectable);
            } else if (ConnectableType.OUTPUT_PORT.equals(connectable.getConnectableType())) {
                connectable.getProcessGroup().stopOutputPort((Port) connectable);
            }
        }
    }
}
 
Example 3
Source File: ControllerFacade.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private void setComponentDetails(final ProvenanceEventDTO dto) {
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());

    final Connectable connectable = root.findLocalConnectable(dto.getComponentId());
    if (connectable != null) {
        dto.setGroupId(connectable.getProcessGroup().getIdentifier());
        dto.setComponentName(connectable.getName());
        return;
    }

    final RemoteGroupPort remoteGroupPort = root.findRemoteGroupPort(dto.getComponentId());
    if (remoteGroupPort != null) {
        dto.setGroupId(remoteGroupPort.getProcessGroupIdentifier());
        dto.setComponentName(remoteGroupPort.getName());
        return;
    }

    final Connection connection = root.findConnection(dto.getComponentId());
    if (connection != null) {
        dto.setGroupId(connection.getProcessGroup().getIdentifier());

        String name = connection.getName();
        final Collection<Relationship> relationships = connection.getRelationships();
        if (StringUtils.isBlank(name) && CollectionUtils.isNotEmpty(relationships)) {
            name = StringUtils.join(relationships.stream().map(relationship -> relationship.getName()).collect(Collectors.toSet()), ", ");
        }
        dto.setComponentName(name);

        return;
    }
}
 
Example 4
Source File: StandardAuthorizableLookup.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public Authorizable getLocalConnectable(String id) {
    final ProcessGroup group = processGroupDAO.getProcessGroup(controllerFacade.getRootGroupId());
    final Connectable connectable = group.findLocalConnectable(id);

    if (connectable == null) {
        throw new ResourceNotFoundException("Unable to find component with id " + id);
    }

    return connectable;
}
 
Example 5
Source File: StandardReportingContext.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public Bulletin createBulletin(final String componentId, final String category, final Severity severity, final String message) {
    final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    final Connectable connectable = rootGroup.findLocalConnectable(componentId);
    if (connectable == null) {
        throw new IllegalStateException("Cannot create Component-Level Bulletin because no component can be found with ID " + componentId);
    }
    return BulletinFactory.createBulletin(connectable, category, severity.name(), message);
}