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

ASF GitHub Bot commented on FLINK-10820:
----------------------------------------

zhijiangW commented on a change in pull request #7051: [FLINK-10820][network] 
Simplify the RebalancePartitioner implementation
URL: https://github.com/apache/flink/pull/7051#discussion_r233348674
 
 

 ##########
 File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/partitioner/RebalancePartitioner.java
 ##########
 @@ -33,29 +33,18 @@
 public class RebalancePartitioner<T> extends StreamPartitioner<T> {
        private static final long serialVersionUID = 1L;
 
-       private final int[] returnArray = {Integer.MAX_VALUE - 1};
+       private final int[] returnArray = { -1 };
 
 Review comment:
   I want to add `setup(int numChannels)` method in `ChannelSelector` 
interface, and I think we can remove `numChannels` parameter from 
`selectChannels` method, because this information has already been given in 
`setup` logic and seems redundant in `selectChannels` logic.
   
   To do so, we should confirm the `setup` must be called firstly before 
`selectChannels`, do you think it is necessary to add another boolean 
`isInitialized` to check this condition in `selectChannels` every time, or the 
`numChannels` parameter still retain in `selectChannels` method?
   
   I try to fix this in this PR and it seems to cover many changes.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Simplify the RebalancePartitioner implementation
> ------------------------------------------------
>
>                 Key: FLINK-10820
>                 URL: https://issues.apache.org/jira/browse/FLINK-10820
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Network
>    Affects Versions: 1.8.0
>            Reporter: zhijiang
>            Assignee: zhijiang
>            Priority: Minor
>              Labels: pull-request-available
>
> _The current {{RebalancePartitioner}} implementation seems a little hacky for 
> selecting a random number as the first channel index, and the following 
> selections based on this random index in round-robin fashion._
> _Especially for the corner case of {{numChannels = Integer.MAX_VALUE}}, it 
> would trigger next random index once reaching the last channel index. 
> Actually the random index should be selected only once at the first time._



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to