yanghua commented on a change in pull request #6544: [FLINK-8532] [Streaming] modify RebalancePartitioner to use a random partition as its first partition URL: https://github.com/apache/flink/pull/6544#discussion_r209517591
########## File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/partitioner/RebalancePartitioner.java ########## @@ -36,9 +38,13 @@ @Override public int[] selectChannels(SerializationDelegate<StreamRecord<T>> record, int numberOfOutputChannels) { - int newChannel = ++this.returnArray[0]; - if (newChannel >= numberOfOutputChannels) { - this.returnArray[0] = 0; + if (this.returnArray[0] < 0) { + this.returnArray[0] = new Random().nextInt(numberOfOutputChannels); Review comment: May be use `ThreadLocalRandom.current().nextInt` would be better than `new Random().nextInt`. Even if you use `Random` class, there is no need to create it every time, when calling this method. ---------------------------------------------------------------- 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 With regards, Apache Git Services