in backend/src/main/java/org/apache/iotdb/admin/service/impl/MetricsServiceImpl.java [730:784]
public JVMMetricsListDataVO getJVMCommittedMemorySize(Connection connection)
throws BaseException {
String name = "当前向JVM申请的内存大小";
String metricType = "内存";
String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
Integer detailAvailable = 0;
int port = connection.getPort();
// TODO bug 修复后删除
if (port == 6668) {
port = 8086;
}
String sql =
"select * from "
+ "root._metric.\"127.0.0.1:"
+ port
+ "\".\"jvm.memory.committed\".\"area=nonheap\".\"id=Compressed Class Space\", "
+ "root._metric.\"127.0.0.1:"
+ port
+ "\".\"jvm.memory.committed\".\"area=nonheap\".\"id=Code Cache\", "
+ "root._metric.\"127.0.0.1:"
+ port
+ "\".\"jvm.memory.committed\".\"area=nonheap\".\"id=Metaspace\", "
+ "root._metric.\"127.0.0.1:"
+ port
+ "\".\"jvm.memory.committed\".\"area=heap\".\"id=PS Old Gen\", "
+ "root._metric.\"127.0.0.1:"
+ port
+ "\".\"jvm.memory.committed\".\"area=heap\".\"id=PS Eden Space\", "
+ "root._metric.\"127.0.0.1:"
+ port
+ "\".\"jvm.memory.committed\".\"area=heap\".\"id=PS Survivor Space\" "
+ "order by time desc limit 1";
SessionPool sessionPool = getSessionPool(connection);
List<String> values = executeQueryOneLine(sessionPool, sql);
long lastestTimeStamp = Long.parseLong(values.get(0));
String count =
getNetFileSizeDescription(
(long)
(Double.parseDouble(values.get(1))
+ Double.parseDouble(values.get(2))
+ Double.parseDouble(values.get(3))
+ Double.parseDouble(values.get(4))
+ Double.parseDouble(values.get(5))
+ Double.parseDouble(values.get(6))));
String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
String latestResult = count;
JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
jvmMetricsListDataVO.setMetricType(metricType);
jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
jvmMetricsListDataVO.setLatestResult(latestResult);
jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
jvmMetricsListDataVO.setName(name);
return jvmMetricsListDataVO;
}