Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed the bug of the result of GC count in query of GC trend service always 0.
  • Loading branch information
peng-yongsheng committed Jul 4, 2018
1 parent fc87747 commit 5941e72
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void accept(DurationPoint durationPoint) {
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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private List<Trend> getGCTrend(int instanceId, Step step, List<DurationPoint> du
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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -69,15 +61,15 @@ private List<Trend> getGCTrend(int instanceId, Step step, List<DurationPoint> du
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));
}
Expand Down

0 comments on commit 5941e72

Please sign in to comment.