本文整理了Java中org.apache.nifi.processor.Relationship
类的一些代码示例,展示了Relationship
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Relationship
类的具体详情如下:
包路径:org.apache.nifi.processor.Relationship
类名称:Relationship
[英]An immutable object for holding information about a type of relationship.
[中]一种不可变的对象,用于保存关于一种关系类型的信息。
代码示例来源:origin: apache/nifi
@Override
public Builder setRelationship(Relationship relationship) {
this.relationship = relationship.getName();
return this;
}
代码示例来源:origin: apache/nifi
@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();
}
}
代码示例来源:origin: apache/nifi
@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);
}
};
代码示例来源:origin: apache/nifi
@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();
} );
}
代码示例来源:origin: apache/nifi
@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());
}
代码示例来源:origin: apache/nifi
public Relationship build() {
return new Relationship(this);
}
}
代码示例来源:origin: apache/nifi
/**
* 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);
}
}
}
代码示例来源:origin: stackoverflow.com
class Person {
Relationship relationship;
public void createRelationship(Person person) {
relationship = new Relationship(this, person);
}
}
代码示例来源:origin: apache/nifi
@Override
public Relationship getRelationship(final String relationshipName) {
if (PORT_RELATIONSHIP.getName().equals(relationshipName)) {
return PORT_RELATIONSHIP;
}
return null;
}
代码示例来源:origin: apache/nifi
@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();
}
}
代码示例来源:origin: apache/nifi
/**
* 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.");
}
}
代码示例来源:origin: apache/nifi
/**
* 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);
}
}
}
}
代码示例来源:origin: apache/nifi
@Override
public Relationship getRelationship(final String relationshipName) {
return (Relationship.ANONYMOUS.getName().equals(relationshipName)) ? Relationship.ANONYMOUS : null;
}
代码示例来源:origin: apache/nifi
if (Relationship.SELF.equals(relationship)) {
continue;
sb.append(" to '").append(relationship.getName()).append("', ");
sb.append(" to '").append(relationship.getName()).append("', ");
代码示例来源:origin: apache/nifi
String hostname = rel.getDescription();
Integer weight = 1;
if (loadInfo.containsKey(hostname)) {
weight = loadInfo.get(hostname);
weightings.put(Integer.decode(rel.getName()), weight);
代码示例来源:origin: apache/nifi
@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();
}
}
代码示例来源:origin: apache/nifi
@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);
}
代码示例来源:origin: apache/nifi
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);
代码示例来源:origin: apache/nifi
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);
代码示例来源:origin: apache/nifi
if (!relationship.equals(Relationship.ANONYMOUS)) {
throw new IllegalArgumentException("No relationship with name " + relationship + " exists for Funnels");
内容来源于网络,如有侵权,请联系作者删除!