soarez commented on code in PR #14838: URL: https://github.com/apache/kafka/pull/14838#discussion_r1415473599
########## 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: I don't think it's a bad name, we just need to make it clear the migration refers to the record version, and not to the cluster migration. You might not remember, but [the name was your suggestion](https://lists.apache.org/thread/38sbj42ssoksjq2p488vdk1992dw3j1t). 😄 ########## 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: I don't think it's a bad name, we just need to make it clear the migration refers to the record version, and not to the cluster migration. You might not remember, but [the name was your suggestion](https://lists.apache.org/thread/38sbj42ssoksjq2p488vdk1992dw3j1t). 😄 -- 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