void maybeUpdateControlledShutdownOffset(int brokerId, long controlledShutDownOffset) {
        BrokerHeartbeatState broker = heartbeatStateOrThrow(brokerId);
        if (broker.fenced()) {
            throw new RuntimeException("Fenced brokers cannot enter controlled shutdown.");
        }
        active.remove(broker);
        // AutoMQ inject start
        broker.lastControlledShutdownNs = time.nanoseconds();
        // AutoMQ inject end
        if (broker.controlledShutdownOffset < 0) {
            broker.controlledShutdownOffset = controlledShutDownOffset;
            log.debug("Updated the controlled shutdown offset for broker {} to {}.",
                brokerId, controlledShutDownOffset);
        }
    }
Mark a broker as being in the controlled shutdown state. We only update the
controlledShutdownOffset if the broker was previously not in controlled shutdown state.

@param brokerId                  The broker id.
@param controlledShutDownOffset  The offset at which controlled shutdown will be complete.
metadata/src/main/java/org/apache/kafka/controller/BrokerHeartbeatManager.java