private boolean hasValidSession(BrokerHeartbeatState broker) {
        if (broker.fenced()) {
            return false;
        } else {
            return broker.lastContactNs + sessionTimeoutNs >= time.nanoseconds();
        }
    }
Check if the given broker has a valid session.

@param broker        The broker to check.

@return              True if the given broker has a valid session.
metadata/src/main/java/org/apache/kafka/controller/BrokerHeartbeatManager.java