public static boolean isOnline(Uuid dir, List<Uuid> sortedOnlineDirs) {
        if (UNASSIGNED.equals(dir) || MIGRATING.equals(dir)) {
            return true;
        }
        if (LOST.equals(dir)) {
            return false;
        }

        // The only time we should have a size be 0 is if we were at a MV prior to 3.7-IV2
        // and the system was upgraded. In this case the original list of directories was purged
        // during broker registration, so we don't know if the directory is online. We assume
        // that a broker will halt if all its log directories are down. Eventually the broker
        // will send another registration request with information about all log directories.
        // Refer KAFKA-16162 for more information
        if (sortedOnlineDirs.isEmpty()) {
            return true;
        }
        return Collections.binarySearch(sortedOnlineDirs, dir) >= 0;
    }
@Test
    void testIsOnline() {
        // Given
        List<Uuid> sortedDirs = Arrays.asList(
                Uuid.fromString("imQKg2cXTVe8OUFNa3R9bg"),
                Uuid.fromString("Mwy5wxTDQxmsZwGzjsaX7w"),
                Uuid.fromString("s8rHMluuSDCnxt3FmKwiyw")
        );
        sortedDirs.sort(Uuid::compareTo);
        List<Uuid> emptySortedDirs = Collections.emptyList();

        // When/Then
        assertTrue(DirectoryId.isOnline(Uuid.fromString("imQKg2cXTVe8OUFNa3R9bg"), sortedDirs));
        assertTrue(DirectoryId.isOnline(Uuid.fromString("Mwy5wxTDQxmsZwGzjsaX7w"), sortedDirs));
        assertTrue(DirectoryId.isOnline(Uuid.fromString("s8rHMluuSDCnxt3FmKwiyw"), sortedDirs));
        assertTrue(DirectoryId.isOnline(DirectoryId.MIGRATING, sortedDirs));
        assertTrue(DirectoryId.isOnline(DirectoryId.UNASSIGNED, sortedDirs));
        assertFalse(DirectoryId.isOnline(DirectoryId.LOST, sortedDirs));
        assertFalse(DirectoryId.isOnline(Uuid.fromString("AMYchbMtS6yhtsXbca7DQg"), sortedDirs));
        assertTrue(DirectoryId.isOnline(Uuid.randomUuid(), emptySortedDirs));
    }