use of org.apache.nifi.processor.Relationship in project nifi by apache.
the class StandardProcessorNode method getRelationship.
/**
* @param relationshipName
* name
* @return the relationship for this nodes processor for the given name or
* creates a new relationship for the given name
*/
@Override
public Relationship getRelationship(final String relationshipName) {
final Relationship specRel = new Relationship.Builder().name(relationshipName).build();
Relationship returnRel = specRel;
final Set<Relationship> relationships;
final Processor processor = processorRef.get().getProcessor();
try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(processor.getClass(), processor.getIdentifier())) {
relationships = processor.getRelationships();
}
for (final Relationship rel : relationships) {
if (rel.equals(specRel)) {
returnRel = rel;
break;
}
}
return returnRel;
}
use of org.apache.nifi.processor.Relationship in project nifi by apache.
the class RepositoryContext method isAnyRelationshipAvailable.
public boolean isAnyRelationshipAvailable() {
for (final Relationship relationship : getConnectable().getRelationships()) {
final Collection<Connection> connections = getConnections(relationship);
boolean available = true;
for (final Connection connection : connections) {
if (connection.getFlowFileQueue().isFull()) {
available = false;
break;
}
}
if (available) {
return true;
}
}
return false;
}
use of org.apache.nifi.processor.Relationship in project nifi by apache.
the class AbstractBinlogEventWriter method writeEvent.
// Default implementation for binlog events
@Override
public long writeEvent(ProcessSession session, String transitUri, T eventInfo, long currentSequenceId, Relationship relationship) {
FlowFile flowFile = session.create();
flowFile = session.write(flowFile, (outputStream) -> {
super.startJson(outputStream, eventInfo);
writeJson(eventInfo);
// Nothing in the body
super.endJson();
});
flowFile = session.putAllAttributes(flowFile, getCommonAttributes(currentSequenceId, eventInfo));
session.transfer(flowFile, relationship);
session.getProvenanceReporter().receive(flowFile, transitUri);
return currentSequenceId + 1;
}
use of org.apache.nifi.processor.Relationship in project nifi by apache.
the class AbstractBinlogTableEventWriter method writeEvent.
// Default implementation for table-related binlog events
@Override
public long writeEvent(ProcessSession session, String transitUri, T eventInfo, long currentSequenceId, Relationship relationship) {
FlowFile flowFile = session.create();
flowFile = session.write(flowFile, (outputStream) -> {
super.startJson(outputStream, eventInfo);
writeJson(eventInfo);
// Nothing in the body
super.endJson();
});
flowFile = session.putAllAttributes(flowFile, getCommonAttributes(currentSequenceId, eventInfo));
session.transfer(flowFile, relationship);
session.getProvenanceReporter().receive(flowFile, transitUri);
return currentSequenceId + 1;
}
use of org.apache.nifi.processor.Relationship in project nifi by apache.
the class DeleteRowsWriter method writeEvent.
/**
* Creates and transfers a new flow file whose contents are the JSON-serialized value of the specified event, and the sequence ID attribute set
*
* @param session A reference to a ProcessSession from which the flow file(s) will be created and transferred
* @param eventInfo An event whose value will become the contents of the flow file
* @return The next available CDC sequence ID for use by the CDC processor
*/
@Override
public long writeEvent(final ProcessSession session, String transitUri, final DeleteRowsEventInfo eventInfo, final long currentSequenceId, Relationship relationship) {
final AtomicLong seqId = new AtomicLong(currentSequenceId);
for (Serializable[] row : eventInfo.getRows()) {
FlowFile flowFile = session.create();
flowFile = session.write(flowFile, outputStream -> {
super.startJson(outputStream, eventInfo);
super.writeJson(eventInfo);
final BitSet bitSet = eventInfo.getIncludedColumns();
writeRow(eventInfo, row, bitSet);
super.endJson();
});
flowFile = session.putAllAttributes(flowFile, getCommonAttributes(seqId.get(), eventInfo));
session.transfer(flowFile, relationship);
session.getProvenanceReporter().receive(flowFile, transitUri);
seqId.getAndIncrement();
}
return seqId.get();
}
Aggregations