Java Code Examples for org.apache.nifi.web.api.dto.ConnectionDTO#setSource()
The following examples show how to use
org.apache.nifi.web.api.dto.ConnectionDTO#setSource() .
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: NiFiClientUtil.java From nifi with Apache License 2.0 | 6 votes |
public ConnectionEntity createConnection(final ConnectableDTO source, final ConnectableDTO destination, final Set<String> relationships) throws NiFiClientException, IOException { final String groupId = "OUTPUT_PORT".equals(source.getType()) ? destination.getGroupId() : source.getGroupId(); final ConnectionDTO connectionDto = new ConnectionDTO(); connectionDto.setSelectedRelationships(relationships); connectionDto.setDestination(destination); connectionDto.setSource(source); connectionDto.setParentGroupId(groupId); final ConnectionEntity connectionEntity = new ConnectionEntity(); connectionEntity.setComponent(connectionDto); connectionEntity.setDestinationGroupId(destination.getGroupId()); connectionEntity.setDestinationId(destination.getId()); connectionEntity.setDestinationType(destination.getType()); connectionEntity.setSourceGroupId(source.getGroupId()); connectionEntity.setSourceId(source.getId()); connectionEntity.setSourceType(source.getType()); connectionEntity.setRevision(createNewRevision()); return nifiClient.getConnectionClient().createConnection(groupId, connectionEntity); }
Example 2
Source File: ConnectionSchemaTest.java From nifi-minifi with Apache License 2.0 | 5 votes |
@Before public void setup() { ConnectableDTO source = new ConnectableDTO(); source.setId(testSourceId); ConnectableDTO destination = new ConnectableDTO(); destination.setId(testDestinationId); dto = new ConnectionDTO(); dto.setId(testId); dto.setName(testName); dto.setSource(source); dto.setSelectedRelationships(Arrays.asList(testSelectedRelationship).stream().collect(Collectors.toSet())); dto.setDestination(destination); dto.setBackPressureObjectThreshold(testMaxWorkQueueSize); dto.setBackPressureDataSizeThreshold(testMaxWorkQueueDataSize); dto.setFlowFileExpiration(testFlowfileExpiration); dto.setPrioritizers(Arrays.asList(testQueuePrioritizerClass)); map = new HashMap<>(); map.put(CommonPropertyKeys.ID_KEY, testId); map.put(CommonPropertyKeys.NAME_KEY, testName); map.put(ConnectionSchema.SOURCE_ID_KEY, testSourceId); map.put(ConnectionSchema.SOURCE_RELATIONSHIP_NAMES_KEY, new ArrayList<>(Arrays.asList(testSelectedRelationship))); map.put(ConnectionSchema.DESTINATION_ID_KEY, testDestinationId); map.put(ConnectionSchema.MAX_WORK_QUEUE_SIZE_KEY, testMaxWorkQueueSize); map.put(ConnectionSchema.MAX_WORK_QUEUE_DATA_SIZE_KEY, testMaxWorkQueueDataSize); map.put(ConnectionSchema.FLOWFILE_EXPIRATION__KEY, testFlowfileExpiration); map.put(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, testQueuePrioritizerClass); }
Example 3
Source File: ITConnectionAccessControl.java From localization_nifi with Apache License 2.0 | 4 votes |
private ConnectionEntity createConnection(final String name) throws Exception { String url = helper.getBaseUrl() + "/process-groups/root/connections"; // get two processors final ProcessorEntity one = ITProcessorAccessControl.createProcessor(helper, "one"); final ProcessorEntity two = ITProcessorAccessControl.createProcessor(helper, "two"); // create the source connectable ConnectableDTO source = new ConnectableDTO(); source.setId(one.getId()); source.setType(ConnectableType.PROCESSOR.name()); // create the target connectable ConnectableDTO target = new ConnectableDTO(); target.setId(two.getId()); target.setType(ConnectableType.PROCESSOR.name()); // create the relationships Set<String> relationships = new HashSet<>(); relationships.add("success"); // create the connection ConnectionDTO connection = new ConnectionDTO(); connection.setName(name); connection.setSource(source); connection.setDestination(target); connection.setSelectedRelationships(relationships); // create the revision final RevisionDTO revision = new RevisionDTO(); revision.setClientId(READ_WRITE_CLIENT_ID); revision.setVersion(0L); // create the entity body ConnectionEntity entity = new ConnectionEntity(); entity.setRevision(revision); entity.setComponent(connection); // perform the request ClientResponse response = helper.getReadWriteUser().testPost(url, entity); // ensure the request is successful assertEquals(201, response.getStatus()); // get the entity body entity = response.getEntity(ConnectionEntity.class); // verify creation connection = entity.getComponent(); assertEquals(name, connection.getName()); // get the connection return entity; }
Example 4
Source File: FlowFromDOMFactory.java From localization_nifi with Apache License 2.0 | 4 votes |
public static ConnectionDTO getConnection(final Element element) { final ConnectionDTO dto = new ConnectionDTO(); dto.setId(getString(element, "id")); dto.setName(getString(element, "name")); dto.setLabelIndex(getOptionalInt(element, "labelIndex")); dto.setzIndex(getOptionalLong(element, "zIndex")); final List<PositionDTO> bends = new ArrayList<>(); final Element bendPointsElement = DomUtils.getChild(element, "bendPoints"); if (bendPointsElement != null) { for (final Element bendPointElement : getChildrenByTagName(bendPointsElement, "bendPoint")) { final PositionDTO bend = getPosition(bendPointElement); bends.add(bend); } } dto.setBends(bends); final ConnectableDTO sourceConnectable = new ConnectableDTO(); dto.setSource(sourceConnectable); sourceConnectable.setId(getString(element, "sourceId")); sourceConnectable.setGroupId(getString(element, "sourceGroupId")); sourceConnectable.setType(getString(element, "sourceType")); final ConnectableDTO destConnectable = new ConnectableDTO(); dto.setDestination(destConnectable); destConnectable.setId(getString(element, "destinationId")); destConnectable.setGroupId(getString(element, "destinationGroupId")); destConnectable.setType(getString(element, "destinationType")); final Set<String> relationships = new HashSet<>(); final List<Element> relationshipNodeList = getChildrenByTagName(element, "relationship"); for (final Element relationshipElem : relationshipNodeList) { relationships.add(relationshipElem.getTextContent()); } dto.setSelectedRelationships(relationships); dto.setBackPressureObjectThreshold(getLong(element, "maxWorkQueueSize")); final String maxDataSize = getString(element, "maxWorkQueueDataSize"); if (maxDataSize != null && !maxDataSize.trim().isEmpty()) { dto.setBackPressureDataSizeThreshold(maxDataSize); } String expiration = getString(element, "flowFileExpiration"); if (expiration == null) { expiration = "0 sec"; } dto.setFlowFileExpiration(expiration); final List<String> prioritizerClasses = new ArrayList<>(); final List<Element> prioritizerNodeList = getChildrenByTagName(element, "queuePrioritizerClass"); for (final Element prioritizerElement : prioritizerNodeList) { prioritizerClasses.add(prioritizerElement.getTextContent().trim()); } dto.setPrioritizers(prioritizerClasses); return dto; }
Example 5
Source File: ITConnectionAccessControl.java From nifi with Apache License 2.0 | 4 votes |
private ConnectionEntity createConnection(final String name) throws Exception { String url = helper.getBaseUrl() + "/process-groups/root/connections"; // get two processors final ProcessorEntity one = ITProcessorAccessControl.createProcessor(helper, "one"); final ProcessorEntity two = ITProcessorAccessControl.createProcessor(helper, "two"); // create the source connectable ConnectableDTO source = new ConnectableDTO(); source.setId(one.getId()); source.setGroupId(one.getComponent().getParentGroupId()); source.setType(ConnectableType.PROCESSOR.name()); // create the target connectable ConnectableDTO target = new ConnectableDTO(); target.setId(two.getId()); target.setGroupId(two.getComponent().getParentGroupId()); target.setType(ConnectableType.PROCESSOR.name()); // create the relationships Set<String> relationships = new HashSet<>(); relationships.add("success"); // create the connection ConnectionDTO connection = new ConnectionDTO(); connection.setName(name); connection.setSource(source); connection.setDestination(target); connection.setSelectedRelationships(relationships); // create the revision final RevisionDTO revision = new RevisionDTO(); revision.setClientId(READ_WRITE_CLIENT_ID); revision.setVersion(0L); // create the entity body ConnectionEntity entity = new ConnectionEntity(); entity.setRevision(revision); entity.setComponent(connection); // perform the request Response response = helper.getReadWriteUser().testPost(url, entity); // ensure the request is successful assertEquals(201, response.getStatus()); // get the entity body entity = response.readEntity(ConnectionEntity.class); // verify creation connection = entity.getComponent(); assertEquals(name, connection.getName()); // get the connection return entity; }
Example 6
Source File: FlowFromDOMFactory.java From nifi with Apache License 2.0 | 4 votes |
public static ConnectionDTO getConnection(final Element element) { final ConnectionDTO dto = new ConnectionDTO(); dto.setId(getString(element, "id")); dto.setName(getString(element, "name")); dto.setLabelIndex(getOptionalInt(element, "labelIndex")); dto.setzIndex(getOptionalLong(element, "zIndex")); dto.setVersionedComponentId(getString(element, "versionedComponentId")); final List<PositionDTO> bends = new ArrayList<>(); final Element bendPointsElement = DomUtils.getChild(element, "bendPoints"); if (bendPointsElement != null) { for (final Element bendPointElement : getChildrenByTagName(bendPointsElement, "bendPoint")) { final PositionDTO bend = getPosition(bendPointElement); bends.add(bend); } } dto.setBends(bends); final ConnectableDTO sourceConnectable = new ConnectableDTO(); dto.setSource(sourceConnectable); sourceConnectable.setId(getString(element, "sourceId")); sourceConnectable.setGroupId(getString(element, "sourceGroupId")); sourceConnectable.setType(getString(element, "sourceType")); final ConnectableDTO destConnectable = new ConnectableDTO(); dto.setDestination(destConnectable); destConnectable.setId(getString(element, "destinationId")); destConnectable.setGroupId(getString(element, "destinationGroupId")); destConnectable.setType(getString(element, "destinationType")); final Set<String> relationships = new HashSet<>(); final List<Element> relationshipNodeList = getChildrenByTagName(element, "relationship"); for (final Element relationshipElem : relationshipNodeList) { relationships.add(relationshipElem.getTextContent()); } dto.setSelectedRelationships(relationships); dto.setBackPressureObjectThreshold(getLong(element, "maxWorkQueueSize")); final String maxDataSize = getString(element, "maxWorkQueueDataSize"); if (maxDataSize != null && !maxDataSize.trim().isEmpty()) { dto.setBackPressureDataSizeThreshold(maxDataSize); } String expiration = getString(element, "flowFileExpiration"); if (expiration == null) { expiration = "0 sec"; } dto.setFlowFileExpiration(expiration); final List<String> prioritizerClasses = new ArrayList<>(); final List<Element> prioritizerNodeList = getChildrenByTagName(element, "queuePrioritizerClass"); for (final Element prioritizerElement : prioritizerNodeList) { prioritizerClasses.add(prioritizerElement.getTextContent().trim()); } dto.setPrioritizers(prioritizerClasses); dto.setLoadBalanceStrategy(getString(element, "loadBalanceStrategy")); dto.setLoadBalancePartitionAttribute(getString(element, "partitioningAttribute")); dto.setLoadBalanceCompression(getString(element, "loadBalanceCompression")); return dto; }