private MetricsChartDataVO getFileSize()

in backend/src/main/java/org/apache/iotdb/admin/service/impl/IotDBServiceImpl.java [3129:3208]


  private MetricsChartDataVO getFileSize(
      SessionPool sessionPool,
      SessionDataSetWrapper sessionDataSetWrapper,
      String url,
      Integer port) {
    List<String> timeList = new ArrayList<>();
    List<String> metricnameList = new ArrayList<>();
    metricnameList.add("wal");
    metricnameList.add("tsfile_seq");
    metricnameList.add("tsfile_unseq");
    metricnameList.add("total");
    List<String> unitList = new ArrayList<>();
    unitList.add("MB");
    List<String> wal = new ArrayList<>();
    List<String> tsfile_seq = new ArrayList<>();
    List<String> tsfile_unseq = new ArrayList<>();
    List<String> total = new ArrayList<>();
    HashMap<String, List<String>> dataList = new HashMap<>();
    if (port == 6668) {
      port = 8086;
    }
    String sql =
        "select * from "
            + "root._metric.\"127.0.0.1:"
            + port
            + "\".\"file_size\".\"name=wal\", "
            + "root._metric.\"127.0.0.1:"
            + port
            + "\".\"file_size\".\"name=seq\", "
            + "root._metric.\"127.0.0.1:"
            + port
            + "\".\"file_size\".\"name=unseq\" "
            + "order by time desc limit 16";
    MetricsChartDataVO metricsChartDataVO = new MetricsChartDataVO();
    try {
      sessionDataSetWrapper = sessionPool.executeQueryStatement(sql);
      int batchSize = sessionDataSetWrapper.getBatchSize();
      if (batchSize > 0) {
        int count = 0;
        while (sessionDataSetWrapper.hasNext()) {
          count++;
          RowRecord rowRecord = sessionDataSetWrapper.next();
          long timestamp = rowRecord.getTimestamp();
          List<org.apache.iotdb.tsfile.read.common.Field> fields1 = rowRecord.getFields();
          String pattern1 = "HH:mm";
          SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat(pattern1);
          timeList.add(simpleDateFormat1.format(timestamp));
          wal.add(getNetFileSizeDescription((long) Float.parseFloat(fields1.get(0).toString())));
          tsfile_seq.add(
              getNetFileSizeDescription((long) Float.parseFloat(fields1.get(1).toString())));
          tsfile_unseq.add(
              getNetFileSizeDescription((long) Float.parseFloat(fields1.get(2).toString())));
          total.add(
              getNetFileSizeDescription(
                  (long)
                      (Float.parseFloat(fields1.get(0).toString())
                          + Float.parseFloat(fields1.get(1).toString())
                          + Float.parseFloat(fields1.get(2).toString()))));
        }
        Collections.reverse(timeList);
        Collections.reverse(wal);
        Collections.reverse(tsfile_seq);
        Collections.reverse(tsfile_unseq);
        Collections.reverse(total);
        dataList.put(metricnameList.get(0), wal);
        dataList.put(metricnameList.get(1), tsfile_seq);
        dataList.put(metricnameList.get(2), tsfile_unseq);
        dataList.put(metricnameList.get(3), total);
        metricsChartDataVO.setTimeList(timeList);
        metricsChartDataVO.setMetricnameList(metricnameList);
        metricsChartDataVO.setDataList(dataList);
        metricsChartDataVO.setUnitList(unitList);
      }
    } catch (IoTDBConnectionException e) {
      e.printStackTrace();
    } catch (StatementExecutionException e) {
      e.printStackTrace();
    }
    return metricsChartDataVO;
  }