public abstract class AbstractPort implements Port { public static final Relationship PORT_RELATIONSHIP = new Relationship.Builder() .description("The relationship through which all Flow Files are transferred") .name("") .build();
public abstract class AbstractPort implements Port { public static final Relationship PORT_RELATIONSHIP = new Relationship.Builder() .description("The relationship through which all Flow Files are transferred") .name("") .build();
final Relationship relationship = new Relationship.Builder().name(descriptor.getName()).build();
final Relationship relationship = new Relationship.Builder().name(descriptor.getName()).build(); destinations.add(relationship);
relsWithDesc.add(new Relationship.Builder().name(String.valueOf(i + 1)) .description(hostNames[i]).build());
if (ROUTE_TO_MATCHING_PROPERTY_NAME.equals(routeStrategy)) { for (final String propName : allDynamicProps) { newRelationships.add(new Relationship.Builder().name(propName).build());
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (descriptor.equals(ROUTE_STRATEGY)) { configuredRouteStrategy = newValue; } else { final Set<String> newDynamicPropertyNames = new HashSet<>(dynamicPropertyNames); if (newValue == null) { newDynamicPropertyNames.remove(descriptor.getName()); } else if (oldValue == null) { // new property newDynamicPropertyNames.add(descriptor.getName()); } this.dynamicPropertyNames = Collections.unmodifiableSet(newDynamicPropertyNames); } // formulate the new set of Relationships final Set<String> allDynamicProps = this.dynamicPropertyNames; final Set<Relationship> newRelationships = new HashSet<>(); final String routeStrategy = configuredRouteStrategy; if (ROUTE_PROPERTY_NAME.equals(routeStrategy)) { for (final String propName : allDynamicProps) { newRelationships.add(new Relationship.Builder().name(propName).build()); } } else { newRelationships.add(REL_MATCH); } newRelationships.add(REL_NO_MATCH); this.relationships.set(newRelationships); }
/** * When this processor is scheduled, update the dynamic properties into the map * for quick access during each onTrigger call * * @param context ProcessContext used to retrieve dynamic properties */ @OnScheduled public void onScheduled(final ProcessContext context) { final String regex = context.getProperty(GROUPING_REGEX).getValue(); if (regex != null) { groupingRegex = Pattern.compile(regex); } final Map<Relationship, PropertyValue> newPropertyMap = new HashMap<>(); for (final PropertyDescriptor descriptor : context.getProperties().keySet()) { if (!descriptor.isDynamic()) { continue; } getLogger().debug("Adding new dynamic property: {}", new Object[] {descriptor}); newPropertyMap.put(new Relationship.Builder().name(descriptor.getName()).build(), context.getProperty(descriptor)); } this.propertyMap = newPropertyMap; }
/** * When this processor is scheduled, update the dynamic properties into the map * for quick access during each onTrigger call * @param context ProcessContext used to retrieve dynamic properties */ @OnScheduled public void onScheduled(final ProcessContext context) { final Map<Relationship, PropertyValue> newPropertyMap = new HashMap<>(); for (final PropertyDescriptor descriptor : context.getProperties().keySet()) { if (!descriptor.isDynamic()) { continue; } getLogger().debug("Adding new dynamic property: {}", new Object[]{descriptor}); newPropertyMap.put(new Relationship.Builder().name(descriptor.getName()).build(), context.getProperty(descriptor)); } this.propertyMap = newPropertyMap; }
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (!descriptor.isDynamic()) { return; } final Relationship relationship = new Relationship.Builder() .name(descriptor.getName()) .description("User-defined relationship that specifies where data that matches the specified SQL query should be routed") .build(); if (newValue == null) { relationships.remove(relationship); } else { relationships.add(relationship); } }
private static Relationship createRelationship(final int num) { return new Relationship.Builder().name(String.valueOf(num)) .description("Where to route flowfiles for this relationship index").build(); }
@Override public void setRelationshipUnavailable(final String relationshipName) { setRelationshipUnavailable(new Relationship.Builder().name(relationshipName).build()); }
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (descriptor.isDynamic()) { final Set<Relationship> relationships = new HashSet<>(this.relationships.get()); final Relationship relationship = new Relationship.Builder().name(descriptor.getName()).build(); if (newValue == null) { relationships.remove(relationship); } else { relationships.add(relationship); } this.relationships.set(relationships); } }
@Override public void setRelationshipAvailable(final String relationshipName) { setRelationshipAvailable(new Relationship.Builder().name(relationshipName).build()); }
@Override public void addConnection(String relationshipName) { addConnection(new Relationship.Builder().name(relationshipName).build()); }
@Override public void removeConnection(String relationshipName) { removeConnection(new Relationship.Builder().name(relationshipName).build()); }
/** * Asserts that all FlowFiles meet all conditions. * * @param relationshipName relationship name * @param predicate conditions */ @Override public void assertAllConditionsMet(final String relationshipName, Predicate<MockFlowFile> predicate) { assertAllConditionsMet(new Relationship.Builder().name(relationshipName).build(), predicate); }
@Override public List<MockFlowFile> getFlowFilesForRelationship(final String relationship) { final Relationship rel = new Relationship.Builder().name(relationship).build(); return getFlowFilesForRelationship(rel); }
/** * Assert that the number of FlowFiles transferred to the given relationship * is equal to the given count * * @param relationship to validate transfer count of * @param count items transfer to given relationship */ public void assertTransferCount(final String relationship, final int count) { assertTransferCount(new Relationship.Builder().name(relationship).build(), count); }
private void updateWeightedRelationships(final Map<Integer, Integer> weightings) { final List<Relationship> relationshipList = new ArrayList<>(); for (final Map.Entry<Integer, Integer> entry : weightings.entrySet()) { final String relationshipName = String.valueOf(entry.getKey()); final Relationship relationship = new Relationship.Builder().name(relationshipName).build(); for (int i = 0; i < entry.getValue(); i++) { relationshipList.add(relationship); } } this.weightedRelationshipListRef.set(Collections.unmodifiableList(relationshipList)); }