boolean brokerRegistrationNeedsRefresh(
        MetadataVersion metadataVersion,
        BrokerRegistration registration
    ) {
        // If there is no existing registration, the BrokerLifecycleManager must still be sending it.
        // So we don't need to do anything yet.
        if (registration == null) {
            log.debug("No current broker registration to check.");
            return false;
        }
        // Check to see if the directory list has changed.  Note that this check could certainly be
        // triggered spuriously. For example, if the broker's directory list has been changed in the
        // past, and we are in the process of replaying that change log, we will end up here.
        // That's fine because resending the broker registration does not cause any problems. And,
        // of course, as soon as a snapshot is made, we will no longer need to worry about those
        // old metadata log entries being replayed on startup.
        if (metadataVersion.isAtLeast(MetadataVersion.IBP_3_7_IV2) &&
                registration.directories().isEmpty()) {
            log.info("Current directory set is empty, but MV supports JBOD. Resending " +
                    "broker registration.");
            return true;
        }
        log.debug("Broker registration does not need to be resent.");
        return false;
    }
Check if the current broker registration needs to be refreshed.

@param metadataVersion   The current metadata version.
@param registration      The current broker registration, or null if there is none.
@return                  True only if we should refresh.
metadata/src/main/java/org/apache/kafka/image/publisher/BrokerRegistrationTracker.java