private MetricsChartDataVO getWriteCount()

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


  private MetricsChartDataVO getWriteCount(
      SessionPool sessionPool,
      SessionDataSetWrapper sessionDataSetWrapper,
      String url,
      Integer port) {
    // TODO:假数据
    List<String> timeList = new ArrayList<>();
    List<String> metricnameList = new ArrayList<>();
    metricnameList.add("success");
    metricnameList.add("fail");
    metricnameList.add("total");
    List<String> unitList = new ArrayList<>();
    unitList.add("ms");
    List<String> success = new ArrayList<>();
    List<String> fail = 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
            + "\".\"jvm.buffer.memory.used\".\"id=mapped\" "
            + "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));
    //            buffer.add(
    //                    getNetFileSizeDescription(
    //                            (getLongFromString(
    //                                    (Float.parseFloat(fields1.get(0).toString())
    //                                            + Float.parseFloat(fields1.get(1).toString()))
    //                                            + ""))));
    //          }
    //          Collections.reverse(buffer);
    //          Collections.reverse(max);
    //          dataList.put(metricnameList.get(0), buffer);
    //          dataList.put(metricnameList.get(1), max);
    //          Collections.reverse(timeList);
    //          metricsChartDataVO.setTimeList(timeList);
    //          metricsChartDataVO.setMetricnameList(metricnameList);
    //          metricsChartDataVO.setDataList(dataList);
    //        }
    //      } catch (IoTDBConnectionException e) {
    //        e.printStackTrace();
    //      } catch (StatementExecutionException e) {
    //        e.printStackTrace();
    //      }
    String pattern1 = "HH:mm";
    SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat(pattern1);
    long timestamp = System.currentTimeMillis();
    for (int i = 0; i < 16; i++) {
      timeList.add(simpleDateFormat1.format(timestamp));
      timestamp -= 60000;
      success.add("10");
      fail.add("20");
      total.add("30");
    }
    Collections.reverse(timeList);
    Collections.reverse(success);
    Collections.reverse(fail);
    Collections.reverse(total);
    dataList.put(metricnameList.get(0), success);
    dataList.put(metricnameList.get(1), fail);
    dataList.put(metricnameList.get(2), total);
    metricsChartDataVO.setTimeList(timeList);
    metricsChartDataVO.setMetricnameList(metricnameList);
    metricsChartDataVO.setDataList(dataList);
    metricsChartDataVO.setUnitList(unitList);
    return metricsChartDataVO;
  }