healchow commented on a change in pull request #3273:
URL: https://github.com/apache/incubator-inlong/pull/3273#discussion_r832798896
##########
File path:
inlong-tubemq/tubemq-manager/src/main/java/org/apache/inlong/tubemq/manager/controller/cluster/ClusterController.java
##########
@@ -179,10 +189,130 @@ public TubeMQResult deleteCluster(DeleteClusterReq req) {
@RequestMapping(value = "/query", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
- String queryInfo(
+ String queryInfo(
@RequestParam Map<String, String> queryBody) throws Exception {
String url = masterService.getQueryUrl(queryBody);
return masterService.queryMaster(url);
}
+ /**
+ * get all count
+ *
+ * @param clusterId
+ */
+ public ClusterVo getAllCount(Integer clusterId) {
+ ClusterVo clusterVo = new ClusterVo();
+ int brokerSize = getBrokerSize(clusterId);
+ ClusterVo countVo = getTopicAndPartitionCount(clusterId);
+ int consumerGroupCount = getConsumerGroupCount(clusterId);
+ int consumerCount = getConsumerCount(clusterId);
+ int storeCount = getStoreCount(clusterId);
+ clusterVo.setBrokerCount(brokerSize);
+ clusterVo.setTopicCount(countVo.getTopicCount());
+ clusterVo.setPartitionCount(countVo.getPartitionCount());
+ clusterVo.setConsumerGroupCount(consumerGroupCount);
+ clusterVo.setConsumerCount(consumerCount);
+ clusterVo.setStoreCount(storeCount);
+ return clusterVo;
+ }
+
+ /**
+ * query borker size
+ *
+ * @param clusterId
+ */
+ public int getBrokerSize(Integer clusterId) {
+ String queryUrl = masterService.getQueryCountUrl(clusterId,
TubeConst.BROKER_RUN_STATUS);
+ String queryData = masterService.queryMaster(queryUrl);
+ JsonObject jsonObject = gson.fromJson(queryData, JsonObject.class);
+ JsonElement count = jsonObject.get("count");
+ return gson.fromJson(count, int.class);
+ }
+
+ /**
+ * query topic and partition count
+ *
+ * @param clusterId
+ */
+ public ClusterVo getTopicAndPartitionCount(Integer clusterId) {
+ ClusterVo clusterVo = new ClusterVo();
+ String url = masterService.getQueryCountUrl(clusterId,
TubeConst.TOPIC_CONFIG_INFO);
+ String queryMaster = masterService.queryMaster(url);
+ JsonObject jsonObject = gson.fromJson(queryMaster, JsonObject.class);
+ JsonElement data = jsonObject.get("data");
+ JsonElement dataCount = jsonObject.get("dataCount");
+ Integer topicSize = gson.fromJson(dataCount, Integer.class);
+ JsonArray jsonData = gson.fromJson(data, JsonArray.class);
+ int partitionCount = 0;
+ List<TopicQueryRes> topicQueryResList =
gson.fromJson(jsonData.toString(),
+ new TypeToken<List<TopicQueryRes>>() {
+ }.getType());
+ for (TopicQueryRes topicQueryRes : topicQueryResList) {
+ String totalCfgNumPart = topicQueryRes.getTotalCfgNumPart();
+ partitionCount = partitionCount + (int)
Math.ceil(Double.parseDouble(totalCfgNumPart));
+ }
+ clusterVo.setTopicCount(topicSize);
+ clusterVo.setPartitionCount(partitionCount);
+ return clusterVo;
+ }
+
+ /**
+ * query Consumer group count
+ *
+ * @param clusterId
+ * @return
+ */
+ public int getConsumerGroupCount(Integer clusterId) {
+ String queryUrl = masterService.getQueryCountUrl(clusterId,
TubeConst.QUERY_CONSUMER_GROUP_INFO);
+ int consumerGroupCount = 0;
+ String groupData = masterService.queryMaster(queryUrl);
+ JsonObject jsonObject1 = gson.fromJson(groupData, JsonObject.class);
Review comment:
Why add 1 for this variable?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]