markobean commented on a change in pull request #5267:
URL: https://github.com/apache/nifi/pull/5267#discussion_r709399380



##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/DistributeLoad.java
##########
@@ -491,4 +508,35 @@ public boolean requiresAllDestinationsAvailable() {
             return false;
         }
     }
+
+    private class OverflowStrategy implements DistributionStrategy {
+
+        @Override
+        public Relationship mapToRelationship(final ProcessContext context, 
final FlowFile flowFile) {
+            final List<Relationship> relationshipList = 
DistributeLoad.this.weightedRelationshipListRef.get();
+            final int numRelationships = relationshipList.size();
+
+            boolean foundFreeRelationship = false;
+            Relationship relationship = null;
+            // Getting set of available relationships only once. This may miss 
a relationship that recently became available, but
+            // overall is more efficient than re-calling for every 
relationship evaluation
+            Set<Relationship> availableRelationships = 
context.getAvailableRelationships();
+
+            int weightedIndex = 0;
+            while (!foundFreeRelationship) {

Review comment:
       I don't think that's a valid concern - but I had to test it to be sure. 
The only time one of the defined relationships would not be available is if all 
relationships have reached their backpressure limit. And, when this is the 
case, the processor is not scheduled. Therefore, there will always be at least 
one available relationship in the set.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to