public BaseVO getAllStorageGroupsInfo()

in backend/src/main/java/org/apache/iotdb/admin/controller/IotDBController.java [115:149]


  public BaseVO<GroupInfoVO> getAllStorageGroupsInfo(
      @PathVariable("serverId") Integer serverId,
      @RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
      @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
      HttpServletRequest request)
      throws BaseException {
    check(request, serverId);
    Connection connection = connectionService.getById(serverId);
    List<String> groupNames = iotDBService.getAllStorageGroups(connection);
    List<String> subGroupNames = new ArrayList<>();
    int size = groupNames.size();
    int pageStart = pageNum == 1 ? 0 : (pageNum - 1) * pageSize;
    int pageEnd = size < pageNum * pageSize ? size : pageNum * pageSize;
    if (size > pageStart) {
      subGroupNames = groupNames.subList(pageStart, pageEnd);
    }
    List<GroupInfo> groupInfoList = new ArrayList<>();
    GroupInfoVO groupInfoVO = new GroupInfoVO();
    if (subGroupNames == null || subGroupNames.size() == 0) {
      return BaseVO.success("Get successfully", groupInfoVO);
    }
    String host = connection.getHost();
    List<Integer> deviceCounts = iotDBService.getDevicesCount(connection, subGroupNames);
    List<String> descriptions = groupService.getGroupDescription(host, subGroupNames);
    for (int i = 0; i < subGroupNames.size(); i++) {
      GroupInfo groupInfo = new GroupInfo();
      groupInfo.setGroupName(subGroupNames.get(i));
      groupInfo.setDeviceCount(deviceCounts.get(i));
      groupInfo.setDescription(descriptions.get(i));
      groupInfoList.add(groupInfo);
    }
    groupInfoVO.setGroupInfoList(groupInfoList);
    groupInfoVO.setGroupCount(size);
    return BaseVO.success("Get successfully", groupInfoVO);
  }