public StringBuilder adminGetOnlineGroupSetByTopic(HttpServletRequest req,
            StringBuilder strBuff,
            ProcessResult result) {
        // check and get topicName field
        if (!WebParameterUtils.getStringParamValue(req,
                WebFieldDef.COMPSTOPICNAME, false, null, strBuff, result)) {
            WebParameterUtils.buildFailResult(strBuff, result.getErrMsg());
            return strBuff;
        }
        Set<String> topicNameSet = (Set<String>) result.getRetData();
        Set<String> targetTopicSet;
        // query topic-group map info
        ConcurrentHashMap<String, ConcurrentHashSet<String>> topicGroupMap =
                master.getConsumerHolder().getRegTopicGroupMap();
        if (topicNameSet == null || topicNameSet.isEmpty()) {
            targetTopicSet = new HashSet<>(topicGroupMap.keySet());
        } else {
            targetTopicSet = new HashSet<>(topicNameSet);
        }
        // build query result
        int totalCnt = 0;
        int topicItemCnt;
        WebParameterUtils.buildSuccessWithDataRetBegin(strBuff);
        for (String topicName : targetTopicSet) {
            if (topicName == null) {
                continue;
            }
            if (totalCnt++ > 0) {
                strBuff.append(",");
            }
            topicItemCnt = 0;
            ConcurrentHashSet<String> groupSet = topicGroupMap.get(topicName);
            strBuff.append("{\"topicName\":\"").append(topicName)
                    .append("\",\"groupSet\":[");
            if (groupSet != null) {
                for (String groupName : groupSet) {
                    if (topicItemCnt++ > 0) {
                        strBuff.append(",");
                    }
                    strBuff.append("\"").append(groupName).append("\"");
                }
            }
            strBuff.append("],\"groupCnt\":").append(topicItemCnt).append("}");
        }
        WebParameterUtils.buildSuccessWithDataRetEnd(strBuff, totalCnt);
        return strBuff;
    }
Query group set by topic view

@param req       Http Servlet Request
@param strBuff   string buffer
@param result    process result
@return    process result
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/master/web/handler/WebMasterInfoHandler.java