You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by pe...@apache.org on 2018/04/24 02:11:59 UTC
[incubator-skywalking] branch ui-protocol/cpm updated: getGCTrend
query finished.
This is an automated email from the ASF dual-hosted git repository.
pengys pushed a commit to branch ui-protocol/cpm
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/ui-protocol/cpm by this push:
new 62c6e32 getGCTrend query finished.
62c6e32 is described below
commit 62c6e32eb1786896c92fb5a9abe7d452f1599b09
Author: peng-yongsheng <80...@qq.com>
AuthorDate: Tue Apr 24 10:11:53 2018 +0800
getGCTrend query finished.
---
.../collector/storage/dao/ui/IGCMetricUIDAO.java | 36 +++++++++++++++++-----
.../storage/es/dao/ui/GCMetricEsUIDAO.java | 28 ++++++++---------
.../storage/h2/dao/ui/GCMetricH2UIDAO.java | 29 ++++++++---------
.../apm/collector/ui/service/ServerService.java | 16 +++++++---
4 files changed, 65 insertions(+), 44 deletions(-)
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGCMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGCMetricUIDAO.java
index cfde09e..74552fc 100644
--- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGCMetricUIDAO.java
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGCMetricUIDAO.java
@@ -37,10 +37,11 @@ public interface IGCMetricUIDAO extends DAO {
/**
* Young GC Trend describes the trend of young generation garbage collection in the given
* duration, which represents by the DurationPoint list in the `step` Unit.
- * <p>SQL as: select COUNT, TIMES from GC_METRIC where ID in (durationPoints), rule of
+ * <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 count percent formula is "COUNT / TIMES".
+ * <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>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
@@ -51,19 +52,20 @@ public interface IGCMetricUIDAO extends DAO {
* @param instanceId the owner id of this GC metrics
* @param step the step which represent time formats
* @param durationPoints the time points in the time span
- * @return every duration points average young generation GC count percent metrics.
+ * @return every duration points average young generation GC count and duration metrics.
* @see org.apache.skywalking.apm.collector.storage.ui.common.Step
* @see org.apache.skywalking.apm.network.proto.GCPhrase
*/
- List<Integer> getYoungGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints);
+ List<Trend> getYoungGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints);
/**
* Old GC Trend describes the trend of old generation garbage collection in the given
* duration, which represents by the DurationPoint list in the `step` Unit.
- * <p>SQL as: select COUNT, TIMES from GC_METRIC where ID in (durationPoints), rule of
+ * <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 old generation GC count percent formula is "COUNT / TIMES".
+ * <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>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
@@ -74,9 +76,27 @@ public interface IGCMetricUIDAO extends DAO {
* @param instanceId the owner id of this GC metrics
* @param step the step which represent time formats
* @param durationPoints the time points in the time span
- * @return every duration points average old generation GC count percent metrics.
+ * @return every duration points average old generation GC count and duration metrics.
* @see org.apache.skywalking.apm.collector.storage.ui.common.Step
* @see org.apache.skywalking.apm.network.proto.GCPhrase
*/
- List<Integer> getOldGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints);
+ List<Trend> getOldGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints);
+
+ class Trend {
+ private int averageCount;
+ private int averageDuration;
+
+ public Trend(int averageCount, int averageDuration) {
+ this.averageCount = averageCount;
+ this.averageDuration = averageDuration;
+ }
+
+ public int getAverageCount() {
+ return averageCount;
+ }
+
+ public int getAverageDuration() {
+ return averageDuration;
+ }
+ }
}
diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GCMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GCMetricEsUIDAO.java
index 2a42db0..71c0880 100644
--- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GCMetricEsUIDAO.java
+++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GCMetricEsUIDAO.java
@@ -18,21 +18,16 @@
package org.apache.skywalking.apm.collector.storage.es.dao.ui;
-import java.util.LinkedList;
-import java.util.List;
-
+import java.util.*;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
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.elasticsearch.action.get.MultiGetItemResponse;
-import org.elasticsearch.action.get.MultiGetRequestBuilder;
-import org.elasticsearch.action.get.MultiGetResponse;
+import org.elasticsearch.action.get.*;
/**
* @author peng-yongsheng
@@ -44,16 +39,16 @@ public class GCMetricEsUIDAO extends EsDAO implements IGCMetricUIDAO {
}
@Override
- public List<Integer> getYoungGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
+ public List<Trend> getYoungGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
return getGCTrend(instanceId, step, durationPoints, GCPhrase.NEW_VALUE);
}
@Override
- public List<Integer> getOldGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
+ public List<Trend> getOldGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
return getGCTrend(instanceId, step, durationPoints, GCPhrase.OLD_VALUE);
}
- private List<Integer> getGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints, int gcPhrase) {
+ private List<Trend> getGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints, int gcPhrase) {
String tableName = TimePyramidTableNameBuilder.build(step, GCMetricTable.TABLE);
MultiGetRequestBuilder youngPrepareMultiGet = getClient().prepareMultiGet(durationPoints, new ElasticSearchClient.MultiGetRowHandler<DurationPoint>() {
@@ -64,15 +59,16 @@ public class GCMetricEsUIDAO extends EsDAO implements IGCMetricUIDAO {
}
});
- List<Integer> gcTrends = new LinkedList<>();
+ List<Trend> gcTrends = new LinkedList<>();
MultiGetResponse multiGetResponse = youngPrepareMultiGet.get();
for (MultiGetItemResponse itemResponse : multiGetResponse.getResponses()) {
if (itemResponse.getResponse().isExists()) {
- long count = ((Number) itemResponse.getResponse().getSource().get(GCMetricTable.COUNT.getName())).longValue();
- long times = ((Number) itemResponse.getResponse().getSource().get(GCMetricTable.TIMES.getName())).intValue();
- gcTrends.add((int) (count / times));
+ 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)));
} else {
- gcTrends.add(0);
+ gcTrends.add(new Trend(0, 0));
}
}
diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GCMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GCMetricH2UIDAO.java
index e3aa9df..6975adb 100644
--- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GCMetricH2UIDAO.java
+++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GCMetricH2UIDAO.java
@@ -18,23 +18,18 @@
package org.apache.skywalking.apm.collector.storage.h2.dao.ui;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.LinkedList;
-import java.util.List;
-import org.apache.skywalking.apm.collector.client.h2.H2Client;
-import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
+import java.sql.*;
+import java.util.*;
+import org.apache.skywalking.apm.collector.client.h2.*;
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.h2.base.dao.H2DAO;
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 peng-yongsheng, clevertension
@@ -48,33 +43,35 @@ public class GCMetricH2UIDAO extends H2DAO implements IGCMetricUIDAO {
super(client);
}
- @Override public List<Integer> getYoungGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
+ @Override public List<Trend> getYoungGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
return getGCTrend(instanceId, step, durationPoints, GCPhrase.NEW_VALUE);
}
- @Override public List<Integer> getOldGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
+ @Override public List<Trend> getOldGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints) {
return getGCTrend(instanceId, step, durationPoints, GCPhrase.OLD_VALUE);
}
- private List<Integer> getGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints, int gcPhrase) {
+ private List<Trend> getGCTrend(int instanceId, Step step, List<DurationPoint> durationPoints, int gcPhrase) {
String tableName = TimePyramidTableNameBuilder.build(step, GCMetricTable.TABLE);
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_GC_METRIC_SQL, tableName, GCMetricTable.ID.getName());
- List<Integer> gcTrends = new LinkedList<>();
+ List<Trend> gcTrends = new LinkedList<>();
durationPoints.forEach(durationPoint -> {
String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + gcPhrase;
try (ResultSet rs = client.executeQuery(sql, new String[] {id})) {
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((int)(count / times));
+ gcTrends.add(new Trend((int)(count / times), (int)(duration / times)));
} else {
- gcTrends.add(0);
+ gcTrends.add(new Trend(0, 0));
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
+ gcTrends.add(new Trend(0, 0));
}
});
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java
index 07f93e5..f09e5eb 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java
@@ -127,10 +127,18 @@ public class ServerService {
long endTimeBucket) throws ParseException {
GCTrend gcTrend = new GCTrend();
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket);
- List<Integer> youngGCTrend = gcMetricUIDAO.getYoungGCTrend(instanceId, step, durationPoints);
- gcTrend.setYoungGCCount(youngGCTrend);
- List<Integer> oldGCTrend = gcMetricUIDAO.getOldGCTrend(instanceId, step, durationPoints);
- gcTrend.setOldGCount(oldGCTrend);
+ List<IGCMetricUIDAO.Trend> youngGCTrend = gcMetricUIDAO.getYoungGCTrend(instanceId, step, durationPoints);
+ youngGCTrend.forEach(young -> {
+ gcTrend.getYoungGCCount().add(young.getAverageCount());
+ gcTrend.getYoungGCTime().add(young.getAverageDuration());
+ });
+
+ List<IGCMetricUIDAO.Trend> oldGCTrend = gcMetricUIDAO.getOldGCTrend(instanceId, step, durationPoints);
+ oldGCTrend.forEach(old -> {
+ gcTrend.getOldGCount().add(old.getAverageCount());
+ gcTrend.getOldGCTime().add(old.getAverageDuration());
+ });
+
return gcTrend;
}
--
To stop receiving notification emails like this one, please contact
pengys@apache.org.