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


##########
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:
   > If you mean zk->kraft migration, then I don't think so. Metadata records 
may have been persisted in an older version, without directory assignment
   
   yes, agreed. @pprovenzano , `MIGRATING` state can happen outside ZK 
migration.
   
   Honestly, I think `MIGRATING` isn't a great name. Someone who sticks on 
metadata version 15 won't ever "migrate" to having directory IDs. Maybe calling 
this `UNKNOWN` would be more descriptive? But that's another discussion I guess 
:)



-- 
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