public static PartitionInfo toPartitionInfo(PartitionMetadata metadata, Map<Integer, Node> nodesById) {
        return new PartitionInfo(metadata.topic(),
                metadata.partition(),
                metadata.leaderId.map(nodesById::get).orElse(null),
                (metadata.replicaIds == null) ? null : convertToNodeArray(metadata.replicaIds, nodesById),
                (metadata.inSyncReplicaIds == null) ? null : convertToNodeArray(metadata.inSyncReplicaIds, nodesById),
                (metadata.offlineReplicaIds == null) ? null : convertToNodeArray(metadata.offlineReplicaIds, nodesById));
    }
Get a snapshot of the cluster metadata from this response
@return the cluster snapshot
clients/src/main/java/org/apache/kafka/common/requests/MetadataResponse.java