public NodeState brokerState(int brokerId, long shutdownTimeoutNs) {
        BrokerHeartbeatState broker = brokers.get(brokerId);
        if (broker == null) {
            return NodeState.UNKNOWN;
        }
        if (broker.shuttingDown()) {
            return NodeState.CONTROLLED_SHUTDOWN;
        }
        if (broker.fenced()) {
            if (broker.lastControlledShutdownNs() + shutdownTimeoutNs > time.nanoseconds()) {
                // The broker is still in controlled shutdown.
                return NodeState.CONTROLLED_SHUTDOWN;
            }
            return NodeState.FENCED;
        }
        return NodeState.ACTIVE;
    }
Check if the oldest broker to have heartbeated has already violated the
sessionTimeoutNs timeout and needs to be fenced.

@return      An Optional broker node id.
metadata/src/main/java/org/apache/kafka/controller/BrokerHeartbeatManager.java