未验证 提交 5941e72f 编写于 作者: 彭勇升 pengys 提交者: GitHub

#1425 (#1426)

Fixed the bug of the result of GC count in query of GC trend service always 0.
上级 fc87747d
......@@ -40,7 +40,7 @@ public interface IGCMetricUIDAO extends DAO {
* <p>SQL as: select COUNT, TIMES, DURATION from GC_METRIC where ID in (durationPoints), rule of
* ID generation is "${durationPoint}_${instanceId}_${gcPhrase}",
* {@link org.apache.skywalking.apm.network.proto.GCPhrase#NEW_VALUE}
* <p>The average young generation GC average count formula is "COUNT / TIMES".
* <p>The young generation GC count
* <p>The average young generation GC average duration formula is "DURATION / TIMES".
* <p>Every element in return list must match DurationPoint list, which also means that,
* the two list must be in same size, and index match.
......@@ -64,8 +64,8 @@ public interface IGCMetricUIDAO extends DAO {
* <p>SQL as: select COUNT, TIMES, DURATION from GC_METRIC where ID in (durationPoints), rule of
* ID generation is "${durationPoint}_${instanceId}_${gcPhrase}",
* {@link org.apache.skywalking.apm.network.proto.GCPhrase#OLD_VALUE}
* <p>The average young generation GC average count formula is "COUNT / TIMES".
* <p>The average young generation GC average duration formula is "DURATION / TIMES".
* <p>The old generation GC count
* <p>The average old generation GC average duration formula is "DURATION / TIMES".
* <p>Every element in return list must match DurationPoint list, which also means that,
* the two list must be in same size, and index match.
* <p>If some element of the return list can't be found, the implementor must set 0 as
......
......@@ -66,7 +66,7 @@ public class GCMetricEsUIDAO extends EsDAO implements IGCMetricUIDAO {
long count = ((Number)itemResponse.getResponse().getSource().get(GCMetricTable.COUNT.getName())).longValue();
long duration = ((Number)itemResponse.getResponse().getSource().get(GCMetricTable.DURATION.getName())).longValue();
long times = ((Number)itemResponse.getResponse().getSource().get(GCMetricTable.TIMES.getName())).intValue();
gcTrends.add(new Trend((int)(count / times), (int)(duration / times)));
gcTrends.add(new Trend((int)count, (int)(duration / times)));
} else {
gcTrends.add(new Trend(0, 0));
}
......
......@@ -65,7 +65,7 @@ public class GCMetricH2UIDAO extends H2DAO implements IGCMetricUIDAO {
long count = rs.getLong(GCMetricTable.COUNT.getName());
long duration = rs.getLong(GCMetricTable.DURATION.getName());
long times = rs.getLong(GCMetricTable.TIMES.getName());
gcTrends.add(new Trend((int)(count / times), (int)(duration / times)));
gcTrends.add(new Trend((int)count, (int)(duration / times)));
} else {
gcTrends.add(new Trend(0, 0));
}
......
......@@ -18,26 +18,18 @@
package org.apache.skywalking.apm.collector.storage.shardingjdbc.dao.ui;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.LinkedList;
import java.util.List;
import org.apache.skywalking.apm.collector.client.shardingjdbc.ShardingjdbcClient;
import org.apache.skywalking.apm.collector.client.shardingjdbc.ShardingjdbcClientException;
import java.sql.*;
import java.util.*;
import org.apache.skywalking.apm.collector.client.shardingjdbc.*;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.shardingjdbc.base.dao.ShardingjdbcDAO;
import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
import org.apache.skywalking.apm.collector.storage.utils.DurationPoint;
import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder;
import org.apache.skywalking.apm.collector.storage.utils.*;
import org.apache.skywalking.apm.network.proto.GCPhrase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.*;
/**
* @author linjiaqi
......@@ -69,15 +61,15 @@ public class GCMetricShardingjdbcUIDAO extends ShardingjdbcDAO implements IGCMet
durationPoints.forEach(durationPoint -> {
String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + gcPhrase;
try (
ResultSet rs = client.executeQuery(sql, new String[] {id});
Statement statement = rs.getStatement();
Connection conn = statement.getConnection();
) {
ResultSet rs = client.executeQuery(sql, new String[] {id});
Statement statement = rs.getStatement();
Connection conn = statement.getConnection();
) {
if (rs.next()) {
long count = rs.getLong(GCMetricTable.COUNT.getName());
long duration = rs.getLong(GCMetricTable.DURATION.getName());
long times = rs.getLong(GCMetricTable.TIMES.getName());
gcTrends.add(new Trend((int)(count / times), (int)(duration / times)));
gcTrends.add(new Trend((int)count, (int)(duration / times)));
} else {
gcTrends.add(new Trend(0, 0));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册