@Override public Builder setRelationship(Relationship relationship) { this.relationship = relationship.getName(); return this; }
@Override public Set<Connection> getConnections(final Relationship relationship) { readLock.lock(); try { if (relationship.equals(PORT_RELATIONSHIP)) { return Collections.unmodifiableSet(outgoingConnections); } throw new IllegalArgumentException("No relationship with name " + relationship.getName() + " exists for Local Ports"); } finally { readLock.unlock(); } }
@Override public void update(Map<String, Integer> loadInfo) { for (Relationship rel : relationshipsRef.get()) { String hostname = rel.getDescription(); Integer weight = 1; if (loadInfo.containsKey(hostname)) { weight = loadInfo.get(hostname); } weightings.put(Integer.decode(rel.getName()), weight); } updateWeightedRelationships(weightings); } };
@Override protected void writeRelationships(final Set<Relationship> relationships) throws IOException { writeArray("relationships", relationships,rel -> { writeStartElement("relationship"); writeTextElement("name", rel.getName()); writeTextElement("description", rel.getDescription()); writeBooleanElement("autoTerminated", rel.isAutoTerminated()); writeEndElement(); } ); }
@Override protected Set<Relationship> filterRelationships(Set<Relationship> rels) { // If destination is attribute, then success == original. return rels.stream().filter(rel -> !REL_ORIGINAL.equals(rel) || !putToAttribute).collect(Collectors.toSet()); }
public Relationship build() { return new Relationship(this); } }
/** * Asserts that all FlowFiles that were transferred were transferred to the * given relationship * * @param relationship to validate */ public void assertAllFlowFilesTransferred(final Relationship relationship) { for (final Map.Entry<Relationship, List<MockFlowFile>> entry : transferMap.entrySet()) { final Relationship rel = entry.getKey(); final List<MockFlowFile> flowFiles = entry.getValue(); if (!rel.equals(relationship) && flowFiles != null && !flowFiles.isEmpty()) { Assert.fail("Expected all Transferred FlowFiles to go to " + relationship + " but " + flowFiles.size() + " were routed to " + rel); } } }
class Person { Relationship relationship; public void createRelationship(Person person) { relationship = new Relationship(this, person); } }
@Override public Relationship getRelationship(final String relationshipName) { if (PORT_RELATIONSHIP.getName().equals(relationshipName)) { return PORT_RELATIONSHIP; } return null; }
@Override public Set<Connection> getConnections(final Relationship relationship) { readLock.lock(); try { if (relationship.equals(Relationship.ANONYMOUS)) { return Collections.unmodifiableSet(outgoingConnections); } throw new IllegalArgumentException("No relationship with name " + relationship.getName() + " exists for Funnels"); } finally { readLock.unlock(); } }
/** * Writes a table describing the relations a processor has. * * @param processor the processor to describe * @param xmlStreamWriter the stream writer to use * @throws XMLStreamException thrown if there was a problem writing the xml */ private void writeRelationships(final Processor processor, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { writeSimpleElement(xmlStreamWriter, "h3", "Relationships: "); if (processor.getRelationships().size() > 0) { xmlStreamWriter.writeStartElement("table"); xmlStreamWriter.writeAttribute("id", "relationships"); xmlStreamWriter.writeStartElement("tr"); writeSimpleElement(xmlStreamWriter, "th", "Name"); writeSimpleElement(xmlStreamWriter, "th", "Description"); xmlStreamWriter.writeEndElement(); for (Relationship relationship : processor.getRelationships()) { xmlStreamWriter.writeStartElement("tr"); writeSimpleElement(xmlStreamWriter, "td", relationship.getName()); writeSimpleElement(xmlStreamWriter, "td", relationship.getDescription()); xmlStreamWriter.writeEndElement(); } xmlStreamWriter.writeEndElement(); } else { xmlStreamWriter.writeCharacters("This processor has no relationships."); } }
/** * Asserts that all FlowFiles that were transferred in the given relationship * are compliant with the given validator. * * @param validator validator to use */ public void assertAllFlowFiles(Relationship relationship, FlowFileValidator validator) { for (final Map.Entry<Relationship, List<MockFlowFile>> entry : transferMap.entrySet()) { final List<MockFlowFile> flowFiles = entry.getValue(); final Relationship rel = entry.getKey(); for (MockFlowFile mockFlowFile : flowFiles) { if(rel.equals(relationship)) { validator.assertFlowFile(mockFlowFile); } } } }
@Override public Relationship getRelationship(final String relationshipName) { return (Relationship.ANONYMOUS.getName().equals(relationshipName)) ? Relationship.ANONYMOUS : null; }
String hostname = rel.getDescription(); Integer weight = 1; if (loadInfo.containsKey(hostname)) { weight = loadInfo.get(hostname); weightings.put(Integer.decode(rel.getName()), weight);
@Override public void addConnection(final Connection connection) throws IllegalArgumentException { writeLock.lock(); try { if (!requireNonNull(connection).getSource().equals(this)) { if (connection.getDestination().equals(this)) { // don't add the connection twice. This may occur if we have a self-loop because we will be told // to add the connection once because we are the source and again because we are the destination. if (!incomingConnections.contains(connection)) { incomingConnections.add(connection); } return; } else { throw new IllegalArgumentException("Cannot add a connection to a LocalPort for which the LocalPort is neither the Source nor the Destination"); } } for (final Relationship relationship : connection.getRelationships()) { if (!relationship.equals(PORT_RELATIONSHIP)) { throw new IllegalArgumentException("No relationship with name " + relationship + " exists for Local Ports"); } } // don't add the connection twice. This may occur if we have a self-loop because we will be told // to add the connection once because we are the source and again because we are the destination. if (!outgoingConnections.contains(connection)) { outgoingConnections.add(connection); } } finally { writeLock.unlock(); } }
@Override public int compareTo(final Relationship o) { if (o == null) { return -1; } final String thisName = getName(); final String thatName = o.getName(); if (thisName == null && thatName == null) { return 0; } if (thisName == null) { return 1; } if (thatName == null) { return -1; } return thisName.compareTo(thatName); }
if (exitCode == 0) { logger.info("Transferring flow file {} to {}", new Object[]{outputFlowFile,outputFlowFileRelationship.getName()}); } else { logger.error("Transferring flow file {} to {}. Executable command {} ended in an error: {}", new Object[]{outputFlowFile,outputFlowFileRelationship.getName(), executeCommand, strBldr.toString()}); outputFlowFile = session.putAllAttributes(outputFlowFile, attributes); if (NONZERO_STATUS_RELATIONSHIP.equals(outputFlowFileRelationship)) { outputFlowFile = session.penalize(outputFlowFile);
for (final Relationship rel : node.getRelationships()) { final RelationshipDTO relationshipDTO = new RelationshipDTO(); relationshipDTO.setDescription(rel.getDescription()); relationshipDTO.setName(rel.getName()); relationshipDTO.setAutoTerminate(node.isAutoTerminated(rel)); relationships.add(relationshipDTO);
if (!relationship.equals(Relationship.ANONYMOUS)) { throw new IllegalArgumentException("No relationship with name " + relationship + " exists for Funnels");