@Override
    public Map<String, Set<String>> queryGroupTopicInfo(Set<String> groups) {
        StringBuilder strBuff = new StringBuilder(512);
        // build base path
        String groupNode = strBuff.append(this.consumerZkDir).toString();
        strBuff.delete(0, strBuff.length());
        Set<String> tmpGroups = new HashSet<>();
        Map<String, Set<String>> groupTopicMap = new HashMap<>();
        if (groups == null) {
            List<String> bookedGroups = ZKUtil.getChildren(this.zkw, groupNode);
            if (bookedGroups != null) {
                tmpGroups.addAll(bookedGroups);
            }
        } else {
            tmpGroups.addAll(groups);
        }
        if (tmpGroups.isEmpty()) {
            return groupTopicMap;
        }
        String qryBrokerId;
        // get the group managed by this broker
        for (String group : tmpGroups) {
            String topicNode = strBuff.append(groupNode)
                    .append("/").append(group).append("/offsets").toString();
            strBuff.delete(0, strBuff.length());
            List<String> consumeTopics = ZKUtil.getChildren(this.zkw, topicNode);
            Set<String> topicSet = new HashSet<>();
            if (consumeTopics != null) {
                for (String topic : consumeTopics) {
                    if (topic == null) {
                        continue;
                    }
                    String brokerNode = strBuff.append(topicNode)
                            .append("/").append(topic).toString();
                    strBuff.delete(0, strBuff.length());
                    List<String> brokerIds = ZKUtil.getChildren(this.zkw, brokerNode);
                    if (brokerIds != null) {
                        for (String idStr : brokerIds) {
                            if (idStr != null) {
                                String[] brokerPartIdStrs =
                                        idStr.split(TokenConstants.HYPHEN);
                                qryBrokerId = brokerPartIdStrs[0];
                                if (qryBrokerId != null
                                        && strBrokerId.equals(qryBrokerId.trim())) {
                                    topicSet.add(topic);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            if (!topicSet.isEmpty()) {
                groupTopicMap.put(group, topicSet);
            }
        }
        return groupTopicMap;
    }
Query booked topic info of groups stored in zookeeper.
@param groups query groups
@return group--topic map info
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/broker/offset/offsetstorage/ZkOffsetStorage.java