Provide the getServerThroughput query.

This commit is contained in:
peng-yongsheng 2018-02-10 10:46:15 +08:00
parent 71275468c5
commit da0a8b8546
6 changed files with 40 additions and 9 deletions

View File

@ -30,7 +30,7 @@ import org.apache.skywalking.apm.collector.storage.utils.DurationPoint;
*/
public interface IInstanceMetricUIDAO extends DAO {
List<AppServerInfo> getTopNServerThroughput(int applicationId, Step step, long start, long end, long secondBetween,
List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end, long secondBetween,
int topN,
MetricSource metricSource);

View File

@ -58,7 +58,7 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
super(client);
}
@Override public List<AppServerInfo> getTopNServerThroughput(int applicationId, Step step, long start, long end,
@Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end,
long secondBetween, int topN, MetricSource metricSource) {
String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE);

View File

@ -49,7 +49,7 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO
super(client);
}
@Override public List<AppServerInfo> getTopNServerThroughput(int applicationId, Step step, long start, long end,
@Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end,
long secondBetween, int topN, MetricSource metricSource) {
return null;
}

View File

@ -30,6 +30,7 @@ import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric;
import org.apache.skywalking.apm.collector.ui.graphql.Query;
import org.apache.skywalking.apm.collector.ui.service.ApplicationService;
import org.apache.skywalking.apm.collector.ui.service.ApplicationTopologyService;
import org.apache.skywalking.apm.collector.ui.service.ServerService;
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
/**
@ -40,6 +41,7 @@ public class ApplicationQuery implements Query {
private final ModuleManager moduleManager;
private ApplicationService applicationService;
private ApplicationTopologyService applicationTopologyService;
private ServerService serverService;
public ApplicationQuery(ModuleManager moduleManager) {
this.moduleManager = moduleManager;
@ -59,6 +61,13 @@ public class ApplicationQuery implements Query {
return applicationTopologyService;
}
private ServerService getServerService() {
if (ObjectUtils.isEmpty(serverService)) {
this.serverService = new ServerService(moduleManager);
}
return serverService;
}
public List<Application> getAllApplication(Duration duration) throws ParseException {
long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
@ -73,14 +82,19 @@ public class ApplicationQuery implements Query {
return getApplicationTopologyService().getApplicationTopology(duration.getStep(), applicationId, start, end);
}
public List<ServiceMetric> getSlowService(int applicationId, Duration duration, Integer top) throws ParseException {
public List<ServiceMetric> getSlowService(int applicationId, Duration duration,
Integer topN) throws ParseException {
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
return getApplicationService().getSlowService(applicationId, duration.getStep(), start, end, top);
return getApplicationService().getSlowService(applicationId, duration.getStep(), start, end, topN);
}
public List<AppServerInfo> getServerThroughput(int applicationId, Duration duration, Integer top) {
return null;
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());
return getServerService().getServerThroughput(applicationId, duration.getStep(), start, end, topN);
}
}

View File

@ -36,6 +36,8 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.table.register.Instance;
import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend;
@ -97,6 +99,21 @@ 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);
serverThroughput.forEach(appServerInfo -> {
String applicationCode = applicationCacheService.getApplicationById(applicationId).getApplicationCode();
appServerInfo.setApplicationCode(applicationCode);
Instance instance = instanceUIDAO.getInstance(appServerInfo.getId());
appServerInfo.setOsInfo(instance.getOsInfo());
});
buildAppServerInfo(serverThroughput);
return serverThroughput;
}
public ThroughputTrend getServerTPSTrend(int instanceId, Step step, long start, long end) throws ParseException {
ThroughputTrend throughputTrend = new ThroughputTrend();
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end);

View File

@ -43,6 +43,6 @@ type Application {
extend type Query {
getAllApplication(duration: Duration!): [Application!]!
getApplicationTopology(applicationId: ID!, duration: Duration!): Topology
getSlowService(applicationId: ID!, duration: Duration!, top: Int!): [ServiceMetric!]!
getServerThroughput(applicationId: ID!, duration: Duration!, top: Int!): [AppServerInfo!]!
getSlowService(applicationId: ID!, duration: Duration!, topN: Int!): [ServiceMetric!]!
getServerThroughput(applicationId: ID!, duration: Duration!, topN: Int!): [AppServerInfo!]!
}