public void write(ImageWriter writer, ImageWriterOptions options) {
        for (BrokerRegistration broker : brokers.values()) {
            writer.write(broker.toRecord(options));
        }
        if (!controllers.isEmpty()) {
            if (!options.metadataVersion().isControllerRegistrationSupported()) {
                options.handleLoss("controller registration data");
            } else {
                for (ControllerRegistration controller : controllers.values()) {
                    writer.write(controller.toRecord(options));
                }
            }
        }
        writer.write(new ApiMessageAndVersion(new UpdateNextNodeIdRecord().setNodeId(nextNodeId), (short) 0));
    }
Represents the cluster in the metadata image.

This class is thread-safe.
metadata/src/main/java/org/apache/kafka/image/ClusterImage.java