private StringBuilder buildNewQueryResult(boolean withAuthInfo,
            StringBuilder sBuffer,
            Map<String, List<TopicDeployEntity>> topicDeployMap) {
        // build query result
        int totalCnt = 0;
        int itemCount = 0;
        int totalCfgNumPartCount = 0;
        int totalRunNumPartCount = 0;
        boolean isSrvAcceptPublish = false;
        boolean isSrvAcceptSubscribe = false;
        String strManageStatus;
        TopicCtrlEntity ctrlEntity;
        BrokerConfEntity brokerConfEntity;
        List<GroupConsumeCtrlEntity> groupCtrlInfoLst;
        Tuple3<Boolean, Boolean, TopicInfo> topicInfoTuple = new Tuple3<>();
        BrokerRunManager brokerRunManager = master.getBrokerRunManager();
        WebParameterUtils.buildSuccessWithDataRetBegin(sBuffer);
        for (Map.Entry<String, List<TopicDeployEntity>> entry : topicDeployMap.entrySet()) {
            totalCfgNumPartCount = 0;
            totalRunNumPartCount = 0;
            isSrvAcceptPublish = false;
            isSrvAcceptSubscribe = false;
            ctrlEntity =
                    defMetaDataService.getTopicCtrlByTopicName(entry.getKey());
            if (ctrlEntity == null) {
                continue;
            }
            if (totalCnt++ > 0) {
                sBuffer.append(",");
            }
            ctrlEntity.toWebJsonStr(sBuffer, true, false);
            sBuffer.append(",\"deployInfo\":[");
            itemCount = 0;
            for (TopicDeployEntity entity : entry.getValue()) {
                if (itemCount++ > 0) {
                    sBuffer.append(",");
                }
                totalCfgNumPartCount += entity.getNumPartitions() * entity.getNumTopicStores();
                entity.toWebJsonStr(sBuffer, true, false);
                sBuffer.append(",\"runInfo\":{");
                brokerConfEntity =
                        defMetaDataService.getBrokerConfByBrokerId(entity.getBrokerId());
                strManageStatus = "-";
                if (brokerConfEntity != null) {
                    strManageStatus = brokerConfEntity.getManageStatus().getDescription();
                }
                brokerRunManager.getPubBrokerTopicInfo(
                        entity.getBrokerId(), entity.getTopicName(), topicInfoTuple);
                if (topicInfoTuple.getF2() == null) {
                    sBuffer.append("\"acceptPublish\":\"-\"").append(",\"acceptSubscribe\":\"-\"")
                            .append(",\"numPartitions\":\"-\"").append(",\"brokerManageStatus\":\"-\"");
                } else {
                    if (topicInfoTuple.getF0()) {
                        sBuffer.append("\"acceptPublish\":")
                                .append(topicInfoTuple.getF2().isAcceptPublish());
                        if (topicInfoTuple.getF2().isAcceptPublish()) {
                            isSrvAcceptPublish = true;
                        }
                    } else {
                        sBuffer.append("\"acceptPublish\":false");
                    }
                    if (topicInfoTuple.getF1()) {
                        sBuffer.append(",\"acceptSubscribe\":")
                                .append(topicInfoTuple.getF2().isAcceptSubscribe());
                        if (topicInfoTuple.getF2().isAcceptSubscribe()) {
                            isSrvAcceptSubscribe = true;
                        }
                    } else {
                        sBuffer.append(",\"acceptSubscribe\":false");
                    }
                    totalRunNumPartCount +=
                            topicInfoTuple.getF2().getPartitionNum() * topicInfoTuple.getF2().getTopicStoreNum();
                    sBuffer.append(",\"numPartitions\":")
                            .append(topicInfoTuple.getF2().getPartitionNum())
                            .append(",\"numTopicStores\":")
                            .append(topicInfoTuple.getF2().getTopicStoreNum())
                            .append(",\"brokerManageStatus\":\"").append(strManageStatus).append("\"");
                }
                sBuffer.append("}}");
            }
            sBuffer.append("],\"infoCount\":").append(itemCount)
                    .append(",\"totalCfgNumPart\":").append(totalCfgNumPartCount)
                    .append(",\"isSrvAcceptPublish\":").append(isSrvAcceptPublish)
                    .append(",\"isSrvAcceptSubscribe\":").append(isSrvAcceptSubscribe)
                    .append(",\"totalRunNumPartCount\":").append(totalRunNumPartCount);
            if (withAuthInfo) {
                sBuffer.append(",\"groupAuthInfo\":[");
                groupCtrlInfoLst =
                        defMetaDataService.getConsumeCtrlByTopic(entry.getKey());
                itemCount = 0;
                for (GroupConsumeCtrlEntity groupEntity : groupCtrlInfoLst) {
                    if (itemCount++ > 0) {
                        sBuffer.append(",");
                    }
                    groupEntity.toWebJsonStr(sBuffer, true, true);
                }
                sBuffer.append("],\"groupAuthCount\":").append(itemCount);
            }
            sBuffer.append("}");
        }
        WebParameterUtils.buildSuccessWithDataRetEnd(sBuffer, totalCnt);
        return sBuffer;
    }
Query topic info

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