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


##########
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:
   Can you clarify what you mean with "migration mode"?
   
   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. That may 
happen outside of a ZK->KRaft migration.
   When such records are found, the default directory for every replica is 
assumed to be `MIGRATING`.
   
   See in #14820 :
    * `new PartitionRegistration(PartitionRecord record)`
    * `partitionRegistration.merge(PartitionChangeRecord record)`
    * `partitionRegistration.toRecord(...)`
    * `partitionChangeBuilder.setAssignmentChanges()`
   
   



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