提交 c1fedb02 编写于 作者: P peng-yongsheng

1. Changed the attribute name from TPS to callsPerSec.

2. Calculate the callsPerSec.
上级 71eb594e
......@@ -30,9 +30,8 @@ import org.apache.skywalking.apm.collector.storage.utils.DurationPoint;
*/
public interface IInstanceMetricUIDAO extends DAO {
List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end, long secondBetween,
int topN,
MetricSource metricSource);
List<AppServerInfo> getServerThroughput(int applicationId, Step step, long startTimeBucket, long endTimeBucket,
int secondBetween, int topN, MetricSource metricSource);
List<Integer> getServerTPSTrend(int instanceId, Step step, List<DurationPoint> durationPoints);
......
......@@ -29,7 +29,7 @@ public class AppServerInfo {
private String applicationCode;
private String osInfo;
private String name;
private int tps;
private int callsPerSec;
private String host;
private int pid;
private List<String> ipv4;
......@@ -74,12 +74,12 @@ public class AppServerInfo {
this.name = name;
}
public int getTps() {
return tps;
public int getCallsPerSec() {
return callsPerSec;
}
public void setTps(int tps) {
this.tps = tps;
public void setCallsPerSec(int callsPerSec) {
this.callsPerSec = callsPerSec;
}
public String getHost() {
......
......@@ -58,8 +58,8 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
super(client);
}
@Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end,
long secondBetween, int topN, MetricSource metricSource) {
@Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long startTimeBucket, long endTimeBucket,
int secondBetween, int topN, MetricSource metricSource) {
String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE);
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName);
......@@ -67,7 +67,7 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must().add(QueryBuilders.rangeQuery(InstanceMetricTable.COLUMN_TIME_BUCKET).gte(start).lte(end));
boolQuery.must().add(QueryBuilders.rangeQuery(InstanceMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket));
if (applicationId != 0) {
boolQuery.must().add(QueryBuilders.termQuery(InstanceMetricTable.COLUMN_APPLICATION_ID, applicationId));
}
......@@ -102,7 +102,7 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
InternalSimpleValue simpleValue = serviceIdTerm.getAggregations().get(AVG_TPS);
appServerInfo.setId(instanceId);
appServerInfo.setTps((int)simpleValue.getValue());
appServerInfo.setCallsPerSec((int)simpleValue.getValue());
appServerInfos.add(appServerInfo);
});
return appServerInfos;
......
......@@ -49,8 +49,8 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO
super(client);
}
@Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end,
long secondBetween, int topN, MetricSource metricSource) {
@Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long startTimeBucket, long endTimeBucket,
int secondBetween, int topN, MetricSource metricSource) {
return null;
}
......
......@@ -98,9 +98,12 @@ public class ApplicationQuery implements Query {
public List<AppServerInfo> getServerThroughput(int applicationId, Duration duration,
Integer topN) throws ParseException {
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
return getServerService().getServerThroughput(applicationId, duration.getStep(), start, end, topN);
return getServerService().getServerThroughput(applicationId, duration.getStep(), startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket, topN);
}
}
......@@ -61,6 +61,7 @@ public class ServerService {
private final IMemoryMetricUIDAO memoryMetricUIDAO;
private final InstanceCacheService instanceCacheService;
private final ApplicationCacheService applicationCacheService;
private final SecondBetweenService secondBetweenService;
public ServerService(ModuleManager moduleManager) {
this.instanceUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class);
......@@ -70,6 +71,7 @@ public class ServerService {
this.memoryMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryMetricUIDAO.class);
this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class);
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
this.secondBetweenService = new SecondBetweenService(moduleManager);
}
public List<AppServerInfo> searchServer(String keyword, long start, long end) {
......@@ -99,10 +101,11 @@ public class ServerService {
return responseTimeTrend;
}
public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start,
long end, Integer topN) throws ParseException {
//TODO
List<AppServerInfo> serverThroughput = instanceMetricUIDAO.getServerThroughput(applicationId, step, start, end, 1000, topN, MetricSource.Callee);
public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long startTimeBucket,
long endTimeBucket, long startSecondTimeBucket, long endSecondTimeBucket, Integer topN) throws ParseException {
int secondBetween = secondBetweenService.calculate(applicationId, startSecondTimeBucket, endSecondTimeBucket);
List<AppServerInfo> serverThroughput = instanceMetricUIDAO.getServerThroughput(applicationId, step, startTimeBucket, endTimeBucket, secondBetween, topN, MetricSource.Callee);
serverThroughput.forEach(appServerInfo -> {
String applicationCode = applicationCacheService.getApplicationById(applicationId).getApplicationCode();
appServerInfo.setApplicationCode(applicationCode);
......
......@@ -8,7 +8,7 @@ type AppServerInfo {
name: String!
applicationId: Int!
applicationCode: String
tps: Int!
callsPerSec: Int!
host: String
pid: Int
ipv4: [String!]!
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册