azagrebin commented on a change in pull request #8646: [FLINK-12735][network] 
Make shuffle environment implementation independent with IOManager
URL: https://github.com/apache/flink/pull/8646#discussion_r294219127
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/disk/iomanager/IOManager.java
 ##########
 @@ -272,17 +231,91 @@ public abstract BulkBlockChannelReader 
createBulkBlockChannelReader(
         * @return The directories that the I/O manager spills to, as path 
strings.
         */
        public String[] getSpillingDirectoriesPaths() {
-               String[] strings = new String[this.paths.length];
+               File[] paths = fileChannelManager.getPaths();
+               String[] strings = new String[paths.length];
                for (int i = 0; i < strings.length; i++) {
                        strings[i] = paths[i].getAbsolutePath();
                }
                return strings;
        }
 
-       private int getNextPathNum() {
-               final int next = this.nextPath;
-               final int newNext = next + 1;
-               this.nextPath = newNext >= this.paths.length ? 0 : newNext;
-               return next;
+       /**
+        * The manager used for creating/deleting file channels based on config 
temp dirs.
+        */
+       private static class FileChannelManager {
+               /** The temporary directories for files. */
+               private final File[] paths;
+
+               /** A random number generator for the anonymous ChannelIDs. */
+               private final Random random = new Random();
+
+               /** The number of the next path to use. */
+               private volatile int nextPath = 0;
 
 Review comment:
   zero assignment is redundant we also try to keep all initialisation logic in 
constructors (same for `random`).

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to