[ 
https://issues.apache.org/jira/browse/NIFI-14959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18020013#comment-18020013
 ] 

Andreas Koch commented on NIFI-14959:
-------------------------------------

Yes, it seems the method will load balance to n-1 nodes instead of n nodes.
I repeated the test with 3 nodes:
{code:java}
HashSet<Integer> targets = new HashSet<Integer>();
for (int i = Integer.MIN_VALUE; i  < Integer.MAX_VALUE; i++) {
  int idx = findIndex(i, 3);
  targets.add(idx);
}
System.out.println(targets); 

=>[0, 1]{code}
so may be to fix this do
{code:java}
final int index = findIndex(hash, partitions.length +1);  {code}
in getPartition.

> CorrelationAttributePartitioner.findIndex always returns 0 if partitions == 2
> -----------------------------------------------------------------------------
>
>                 Key: NIFI-14959
>                 URL: https://issues.apache.org/jira/browse/NIFI-14959
>             Project: Apache NiFi
>          Issue Type: Bug
>            Reporter: Andreas Koch
>            Priority: Major
>
> Ways to reproduce. Added static to findIndex
>  
> {code:java}
> for (int i = Integer.MIN_VALUE; i  < Integer.MAX_VALUE; i++) {
>    int idx = findIndex(i, 2);   
>    if (idx != 0) {
>       System.out.println(i);
>    }            
> } {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to