Java Code Examples for org.apache.nifi.web.api.dto.PortDTO#setState()

The following examples show how to use org.apache.nifi.web.api.dto.PortDTO#setState() . 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: FlowFromDOMFactory.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public static PortDTO getPort(final Element element) {
    final PortDTO portDTO = new PortDTO();
    portDTO.setId(getString(element, "id"));
    portDTO.setPosition(getPosition(DomUtils.getChild(element, "position")));
    portDTO.setName(getString(element, "name"));
    portDTO.setComments(getString(element, "comments"));
    final ScheduledState scheduledState = getScheduledState(element);
    portDTO.setState(scheduledState.toString());

    final List<Element> maxTasksElements = getChildrenByTagName(element, "maxConcurrentTasks");
    if (!maxTasksElements.isEmpty()) {
        portDTO.setConcurrentlySchedulableTaskCount(Integer.parseInt(maxTasksElements.get(0).getTextContent()));
    }

    final List<Element> userAccessControls = getChildrenByTagName(element, "userAccessControl");
    if (userAccessControls != null && !userAccessControls.isEmpty()) {
        final Set<String> users = new HashSet<>();
        portDTO.setUserAccessControl(users);
        for (final Element userElement : userAccessControls) {
            users.add(userElement.getTextContent());
        }
    }

    final List<Element> groupAccessControls = getChildrenByTagName(element, "groupAccessControl");
    if (groupAccessControls != null && !groupAccessControls.isEmpty()) {
        final Set<String> groups = new HashSet<>();
        portDTO.setGroupAccessControl(groups);
        for (final Element groupElement : groupAccessControls) {
            groups.add(groupElement.getTextContent());
        }
    }

    return portDTO;
}
 
Example 2
Source File: JerseyOutputPortClient.java    From nifi with Apache License 2.0 5 votes vote down vote up
private PortEntity createStateEntity(final PortEntity entity, final String state) {
    final PortDTO component = new PortDTO();
    component.setId(entity.getComponent().getId());
    component.setParentGroupId(entity.getComponent().getParentGroupId());
    component.setState(state);

    final PortEntity stateEntity = new PortEntity();
    stateEntity.setId(entity.getId());
    stateEntity.setRevision(entity.getRevision());
    stateEntity.setComponent(component);

    return stateEntity;
}
 
Example 3
Source File: JerseyInputPortClient.java    From nifi with Apache License 2.0 5 votes vote down vote up
private PortEntity createStateEntity(final PortEntity entity, final String state) {
    final PortDTO component = new PortDTO();
    component.setId(entity.getComponent().getId());
    component.setParentGroupId(entity.getComponent().getParentGroupId());
    component.setState(state);

    final PortEntity stateEntity = new PortEntity();
    stateEntity.setId(entity.getId());
    stateEntity.setRevision(entity.getRevision());
    stateEntity.setComponent(component);

    return stateEntity;
}
 
Example 4
Source File: FlowFromDOMFactory.java    From nifi with Apache License 2.0 5 votes vote down vote up
public static PortDTO getPort(final Element element) {
    final PortDTO portDTO = new PortDTO();
    portDTO.setId(getString(element, "id"));
    portDTO.setVersionedComponentId(getString(element, "versionedComponentId"));
    portDTO.setPosition(getPosition(DomUtils.getChild(element, "position")));
    portDTO.setName(getString(element, "name"));
    portDTO.setComments(getString(element, "comments"));
    portDTO.setAllowRemoteAccess(getBoolean(element, "allowRemoteAccess"));
    final ScheduledState scheduledState = getScheduledState(element);
    portDTO.setState(scheduledState.toString());

    final List<Element> maxTasksElements = getChildrenByTagName(element, "maxConcurrentTasks");
    if (!maxTasksElements.isEmpty()) {
        portDTO.setConcurrentlySchedulableTaskCount(Integer.parseInt(maxTasksElements.get(0).getTextContent()));
    }

    final List<Element> userAccessControls = getChildrenByTagName(element, "userAccessControl");
    if (userAccessControls != null && !userAccessControls.isEmpty()) {
        final Set<String> users = new HashSet<>();
        portDTO.setUserAccessControl(users);
        for (final Element userElement : userAccessControls) {
            users.add(userElement.getTextContent());
        }
    }

    final List<Element> groupAccessControls = getChildrenByTagName(element, "groupAccessControl");
    if (groupAccessControls != null && !groupAccessControls.isEmpty()) {
        final Set<String> groups = new HashSet<>();
        portDTO.setGroupAccessControl(groups);
        for (final Element groupElement : groupAccessControls) {
            groups.add(groupElement.getTextContent());
        }
    }

    return portDTO;
}
 
Example 5
Source File: TestHttpClient.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Before
public void before() throws Exception {

    System.setProperty("org.slf4j.simpleLogger.log.org.apache.nifi.remote", "TRACE");
    System.setProperty("org.slf4j.simpleLogger.log.org.apache.nifi.remote.protocol.http.HttpClientTransaction", "DEBUG");

    testCaseFinished = new CountDownLatch(1);

    final PeerDTO peer = new PeerDTO();
    peer.setHostname("localhost");
    peer.setPort(httpConnector.getLocalPort());
    peer.setFlowFileCount(10);
    peer.setSecure(false);

    peers = new HashSet<>();
    peers.add(peer);

    final PeerDTO peerSecure = new PeerDTO();
    peerSecure.setHostname("localhost");
    peerSecure.setPort(sslConnector.getLocalPort());
    peerSecure.setFlowFileCount(10);
    peerSecure.setSecure(true);

    peersSecure = new HashSet<>();
    peersSecure.add(peerSecure);

    inputPorts = new HashSet<>();

    final PortDTO runningInputPort = new PortDTO();
    runningInputPort.setName("input-running");
    runningInputPort.setId("input-running-id");
    runningInputPort.setType("INPUT_PORT");
    runningInputPort.setState(ScheduledState.RUNNING.name());
    inputPorts.add(runningInputPort);

    final PortDTO timeoutInputPort = new PortDTO();
    timeoutInputPort.setName("input-timeout");
    timeoutInputPort.setId("input-timeout-id");
    timeoutInputPort.setType("INPUT_PORT");
    timeoutInputPort.setState(ScheduledState.RUNNING.name());
    inputPorts.add(timeoutInputPort);

    final PortDTO timeoutDataExInputPort = new PortDTO();
    timeoutDataExInputPort.setName("input-timeout-data-ex");
    timeoutDataExInputPort.setId("input-timeout-data-ex-id");
    timeoutDataExInputPort.setType("INPUT_PORT");
    timeoutDataExInputPort.setState(ScheduledState.RUNNING.name());
    inputPorts.add(timeoutDataExInputPort);

    final PortDTO accessDeniedInputPort = new PortDTO();
    accessDeniedInputPort.setName("input-access-denied");
    accessDeniedInputPort.setId("input-access-denied-id");
    accessDeniedInputPort.setType("INPUT_PORT");
    accessDeniedInputPort.setState(ScheduledState.RUNNING.name());
    inputPorts.add(accessDeniedInputPort);

    outputPorts = new HashSet<>();

    final PortDTO runningOutputPort = new PortDTO();
    runningOutputPort.setName("output-running");
    runningOutputPort.setId("output-running-id");
    runningOutputPort.setType("OUTPUT_PORT");
    runningOutputPort.setState(ScheduledState.RUNNING.name());
    outputPorts.add(runningOutputPort);

    final PortDTO timeoutOutputPort = new PortDTO();
    timeoutOutputPort.setName("output-timeout");
    timeoutOutputPort.setId("output-timeout-id");
    timeoutOutputPort.setType("OUTPUT_PORT");
    timeoutOutputPort.setState(ScheduledState.RUNNING.name());
    outputPorts.add(timeoutOutputPort);

    final PortDTO timeoutDataExOutputPort = new PortDTO();
    timeoutDataExOutputPort.setName("output-timeout-data-ex");
    timeoutDataExOutputPort.setId("output-timeout-data-ex-id");
    timeoutDataExOutputPort.setType("OUTPUT_PORT");
    timeoutDataExOutputPort.setState(ScheduledState.RUNNING.name());
    outputPorts.add(timeoutDataExOutputPort);


}
 
Example 6
Source File: TestHttpClient.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Before
public void before() throws Exception {

    System.setProperty("org.slf4j.simpleLogger.log.org.apache.nifi.remote", "TRACE");
    System.setProperty("org.slf4j.simpleLogger.log.org.apache.nifi.remote.protocol.http.HttpClientTransaction", "DEBUG");

    testCaseFinished = new CountDownLatch(1);

    final PeerDTO peer = new PeerDTO();
    peer.setHostname("localhost");
    peer.setPort(httpConnector.getLocalPort());
    peer.setFlowFileCount(10);
    peer.setSecure(false);

    peers = new HashSet<>();
    peers.add(peer);

    final PeerDTO peerSecure = new PeerDTO();
    peerSecure.setHostname("localhost");
    peerSecure.setPort(sslConnector.getLocalPort());
    peerSecure.setFlowFileCount(10);
    peerSecure.setSecure(true);

    peersSecure = new HashSet<>();
    peersSecure.add(peerSecure);

    inputPorts = new HashSet<>();

    final PortDTO runningInputPort = new PortDTO();
    runningInputPort.setName("input-running");
    runningInputPort.setId("input-running-id");
    runningInputPort.setType("INPUT_PORT");
    runningInputPort.setState(ScheduledState.RUNNING.name());
    inputPorts.add(runningInputPort);

    final PortDTO timeoutInputPort = new PortDTO();
    timeoutInputPort.setName("input-timeout");
    timeoutInputPort.setId("input-timeout-id");
    timeoutInputPort.setType("INPUT_PORT");
    timeoutInputPort.setState(ScheduledState.RUNNING.name());
    inputPorts.add(timeoutInputPort);

    final PortDTO timeoutDataExInputPort = new PortDTO();
    timeoutDataExInputPort.setName("input-timeout-data-ex");
    timeoutDataExInputPort.setId("input-timeout-data-ex-id");
    timeoutDataExInputPort.setType("INPUT_PORT");
    timeoutDataExInputPort.setState(ScheduledState.RUNNING.name());
    inputPorts.add(timeoutDataExInputPort);

    final PortDTO accessDeniedInputPort = new PortDTO();
    accessDeniedInputPort.setName("input-access-denied");
    accessDeniedInputPort.setId("input-access-denied-id");
    accessDeniedInputPort.setType("INPUT_PORT");
    accessDeniedInputPort.setState(ScheduledState.RUNNING.name());
    inputPorts.add(accessDeniedInputPort);

    outputPorts = new HashSet<>();

    final PortDTO runningOutputPort = new PortDTO();
    runningOutputPort.setName("output-running");
    runningOutputPort.setId("output-running-id");
    runningOutputPort.setType("OUTPUT_PORT");
    runningOutputPort.setState(ScheduledState.RUNNING.name());
    outputPorts.add(runningOutputPort);

    final PortDTO timeoutOutputPort = new PortDTO();
    timeoutOutputPort.setName("output-timeout");
    timeoutOutputPort.setId("output-timeout-id");
    timeoutOutputPort.setType("OUTPUT_PORT");
    timeoutOutputPort.setState(ScheduledState.RUNNING.name());
    outputPorts.add(timeoutOutputPort);

    final PortDTO timeoutDataExOutputPort = new PortDTO();
    timeoutDataExOutputPort.setName("output-timeout-data-ex");
    timeoutDataExOutputPort.setId("output-timeout-data-ex-id");
    timeoutDataExOutputPort.setType("OUTPUT_PORT");
    timeoutDataExOutputPort.setState(ScheduledState.RUNNING.name());
    outputPorts.add(timeoutDataExOutputPort);


}
 
Example 7
Source File: InputPortResource.java    From nifi with Apache License 2.0 4 votes vote down vote up
private PortDTO createDTOWithDesiredRunStatus(final String id, final String runStatus) {
    final PortDTO dto = new PortDTO();
    dto.setId(id);
    dto.setState(runStatus);
    return dto;
}
 
Example 8
Source File: OutputPortResource.java    From nifi with Apache License 2.0 4 votes vote down vote up
private PortDTO createDTOWithDesiredRunStatus(final String id, final String runStatus) {
    final PortDTO dto = new PortDTO();
    dto.setId(id);
    dto.setState(runStatus);
    return dto;
}