pprovenzano commented on code in PR #14838:
URL: https://github.com/apache/kafka/pull/14838#discussion_r1405538961


##########
server-common/src/main/java/org/apache/kafka/common/DirectoryId.java:
##########
@@ -121,8 +122,38 @@ public static Map<Integer, Uuid> createAssignmentMap(int[] 
replicas, Uuid[] dire
      * Create an array with the specified number of entries set to {@link 
#UNASSIGNED}.
      */
     public static Uuid[] unassignedArray(int length) {
+        return array(length, UNASSIGNED);
+    }
+
+    /**
+     * Create an array with the specified number of entries set to {@link 
#MIGRATING}.
+     */
+    public static Uuid[] migratingArray(int length) {
+        return array(length, MIGRATING);
+    }
+
+    /**
+     * Create an array with the specified number of entries set to the 
specified value.
+     */
+    private static Uuid[] array(int length, Uuid value) {
         Uuid[] array = new Uuid[length];
-        Arrays.fill(array, UNASSIGNED);
+        Arrays.fill(array, value);
         return array;
     }
+
+    /**
+     * Check if a directory is online, given a sorted list of online 
directories.
+     * @param dir              The directory to check
+     * @param sortedOnlineDirs The sorted list of online directories
+     * @return                 true if the directory is considered online, 
false otherwise
+     */
+    public static boolean isOnline(Uuid dir, List<Uuid> sortedOnlineDirs) {
+        if (UNASSIGNED.equals(dir) || MIGRATING.equals(dir)) {

Review Comment:
   We should only allow for a directory ID to be MIGRATING if we are in 
migration mode.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to