未验证 提交 e233b7be 编写于 作者: 李运涛 liyuntao 提交者: GitHub

Merge branch 'master' into servicecomb

......@@ -104,6 +104,7 @@ import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMin
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO;
......@@ -248,6 +249,7 @@ public class StorageModule extends Module {
classes.add(IInstanceMetricUIDAO.class);
classes.add(IApplicationComponentUIDAO.class);
classes.add(IApplicationMappingUIDAO.class);
classes.add(IApplicationMetricUIDAO.class);
classes.add(IApplicationReferenceMetricUIDAO.class);
classes.add(ISegmentDurationUIDAO.class);
classes.add(ISegmentUIDAO.class);
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.collector.storage.dao.ui;
import java.util.List;
import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
import org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationTPS;
/**
* @author peng-yongsheng
*/
public interface IApplicationMetricUIDAO extends DAO {
List<ApplicationTPS> getTopNApplicationThroughput(Step step, long start, long end, long betweenSecond, int topN,
MetricSource metricSource);
}
......@@ -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);
......
......@@ -33,6 +33,8 @@ import org.apache.skywalking.apm.collector.storage.utils.DurationPoint;
public interface IServiceMetricUIDAO extends DAO {
List<Integer> getServiceResponseTimeTrend(int serviceId, Step step, List<DurationPoint> durationPoints);
List<Integer> getServiceTPSTrend(int serviceId, Step step, List<DurationPoint> durationPoints);
List<Integer> getServiceSLATrend(int serviceId, Step step, List<DurationPoint> durationPoints);
List<Node> getServicesMetric(Step step, long startTime, long endTime,
......
......@@ -18,6 +18,7 @@
package org.apache.skywalking.apm.collector.storage.ui.common;
import java.util.LinkedList;
import java.util.List;
/**
......@@ -26,6 +27,10 @@ import java.util.List;
public class ThroughputTrend {
private List<Integer> trendList;
public ThroughputTrend() {
this.trendList = new LinkedList<>();
}
public List<Integer> getTrendList() {
return trendList;
}
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.collector.storage.ui.overview;
/**
* @author peng-yongsheng
*/
public class ApplicationTPS {
private int applicationId;
private String applicationCode;
private int tps;
public int getApplicationId() {
return applicationId;
}
public void setApplicationId(int applicationId) {
this.applicationId = applicationId;
}
public String getApplicationCode() {
return applicationCode;
}
public void setApplicationCode(String applicationCode) {
this.applicationCode = applicationCode;
}
public int getTps() {
return tps;
}
public void setTps(int tps) {
this.tps = tps;
}
}
......@@ -113,6 +113,7 @@ import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMin
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO;
......@@ -211,6 +212,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceM
import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceMonthMetricEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationComponentEsUIDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationMappingEsUIDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationMetricEsUIDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationReferenceMetricEsUIDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ui.CpuMetricEsUIDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.ui.GCMetricEsUIDAO;
......@@ -407,6 +409,7 @@ public class StorageModuleEsProvider extends ModuleProvider {
this.registerServiceImplementation(IInstanceMetricUIDAO.class, new InstanceMetricEsUIDAO(elasticSearchClient));
this.registerServiceImplementation(IApplicationComponentUIDAO.class, new ApplicationComponentEsUIDAO(elasticSearchClient));
this.registerServiceImplementation(IApplicationMappingUIDAO.class, new ApplicationMappingEsUIDAO(elasticSearchClient));
this.registerServiceImplementation(IApplicationMetricUIDAO.class, new ApplicationMetricEsUIDAO(elasticSearchClient));
this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricEsUIDAO(elasticSearchClient));
this.registerServiceImplementation(ISegmentDurationUIDAO.class, new SegmentDurationEsUIDAO(elasticSearchClient));
this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentEsUIDAO(elasticSearchClient));
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.collector.storage.es.dao.ui;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
import org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationTPS;
import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders;
/**
* @author peng-yongsheng
*/
public class ApplicationMetricEsUIDAO extends EsDAO implements IApplicationMetricUIDAO {
public ApplicationMetricEsUIDAO(ElasticSearchClient client) {
super(client);
}
private static final String AVG_TPS = "avg_tps";
@Override
public List<ApplicationTPS> getTopNApplicationThroughput(Step step, long start, long end, long betweenSecond,
int topN,
MetricSource metricSource) {
String tableName = TimePyramidTableNameBuilder.build(step, ApplicationMetricTable.TABLE);
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName);
searchRequestBuilder.setTypes(ApplicationMetricTable.TABLE_TYPE);
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationMetricTable.COLUMN_TIME_BUCKET).gte(start).lte(end));
boolQuery.must().add(QueryBuilders.termQuery(ApplicationMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue()));
searchRequestBuilder.setQuery(boolQuery);
searchRequestBuilder.setSize(0);
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationMetricTable.COLUMN_APPLICATION_ID).field(ApplicationMetricTable.COLUMN_APPLICATION_ID).size(topN);
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS));
aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS).field(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS));
Map<String, String> bucketsPathsMap = new HashMap<>();
bucketsPathsMap.put(ApplicationMetricTable.COLUMN_TRANSACTION_CALLS, ApplicationMetricTable.COLUMN_TRANSACTION_CALLS);
bucketsPathsMap.put(ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS);
String idOrCode = "(params." + ApplicationMetricTable.COLUMN_TRANSACTION_CALLS + " - params." + ApplicationMetricTable.COLUMN_TRANSACTION_ERROR_CALLS + ")"
+ " / "
+ "(" + betweenSecond + ")";
Script script = new Script(idOrCode);
aggregationBuilder.subAggregation(PipelineAggregatorBuilders.bucketScript(AVG_TPS, bucketsPathsMap, script));
searchRequestBuilder.addAggregation(aggregationBuilder);
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
List<ApplicationTPS> applicationTPSs = new LinkedList<>();
Terms serviceIdTerms = searchResponse.getAggregations().get(ApplicationMetricTable.COLUMN_APPLICATION_ID);
serviceIdTerms.getBuckets().forEach(serviceIdTerm -> {
int applicationId = serviceIdTerm.getKeyAsNumber().intValue();
ApplicationTPS serviceMetric = new ApplicationTPS();
InternalSimpleValue simpleValue = serviceIdTerm.getAggregations().get(AVG_TPS);
serviceMetric.setApplicationId(applicationId);
serviceMetric.setTps((int)simpleValue.getValue());
applicationTPSs.add(serviceMetric);
});
return applicationTPSs;
}
}
......@@ -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);
......
......@@ -88,6 +88,29 @@ public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO {
return trends;
}
@Override public List<Integer> getServiceTPSTrend(int serviceId, Step step, List<DurationPoint> durationPoints) {
MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet();
String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE);
durationPoints.forEach(durationPoint -> {
String id = durationPoint.getPoint() + Const.ID_SPLIT + serviceId + Const.ID_SPLIT + MetricSource.Callee.getValue();
prepareMultiGet.add(tableName, ServiceMetricTable.TABLE_TYPE, id);
});
List<Integer> trends = new LinkedList<>();
MultiGetResponse multiGetResponse = prepareMultiGet.get();
for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
if (response.getResponse().isExists()) {
long calls = ((Number)response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue();
long errorCalls = ((Number)response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue();
trends.add((int)(calls - errorCalls));
} else {
trends.add(0);
}
}
return trends;
}
@Override public List<Integer> getServiceSLATrend(int serviceId, Step step, List<DurationPoint> durationPoints) {
MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet();
String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE);
......
......@@ -109,6 +109,7 @@ import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMin
import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO;
......@@ -207,6 +208,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.srmp.ServiceReferenceM
import org.apache.skywalking.apm.collector.storage.h2.dao.srmp.ServiceReferenceMonthMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationComponentH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationMappingH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationMetricH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationReferenceMetricH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.CpuMetricH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.GCMetricH2UIDAO;
......@@ -383,6 +385,7 @@ public class StorageModuleH2Provider extends ModuleProvider {
this.registerServiceImplementation(IInstanceMetricUIDAO.class, new InstanceMetricH2UIDAO(h2Client));
this.registerServiceImplementation(IApplicationComponentUIDAO.class, new ApplicationComponentH2UIDAO(h2Client));
this.registerServiceImplementation(IApplicationMappingUIDAO.class, new ApplicationMappingH2UIDAO(h2Client));
this.registerServiceImplementation(IApplicationMetricUIDAO.class, new ApplicationMetricH2UIDAO(h2Client));
this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricH2UIDAO(h2Client));
this.registerServiceImplementation(ISegmentDurationUIDAO.class, new SegmentDurationH2UIDAO(h2Client));
this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentH2UIDAO(h2Client));
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.collector.storage.h2.dao.ui;
import java.util.List;
import org.apache.skywalking.apm.collector.client.h2.H2Client;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
import org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationTPS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public class ApplicationMetricH2UIDAO extends H2DAO implements IApplicationMetricUIDAO {
private final Logger logger = LoggerFactory.getLogger(ApplicationMetricH2UIDAO.class);
public ApplicationMetricH2UIDAO(H2Client client) {
super(client);
}
@Override
public List<ApplicationTPS> getTopNApplicationThroughput(Step step, long start, long end, long betweenSecond,
int topN, MetricSource metricSource) {
return null;
}
}
......@@ -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;
}
......
......@@ -80,6 +80,10 @@ public class ServiceMetricH2UIDAO extends H2DAO implements IServiceMetricUIDAO {
return trends;
}
@Override public List<Integer> getServiceTPSTrend(int serviceId, Step step, List<DurationPoint> durationPoints) {
return null;
}
@Override public List<Integer> getServiceSLATrend(int serviceId, Step step, List<DurationPoint> durationPoints) {
String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE);
......
......@@ -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);
}
}
......@@ -25,16 +25,15 @@ import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend;
import org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationTPS;
import org.apache.skywalking.apm.collector.storage.ui.overview.ClusterBrief;
import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalAppBrief;
import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo;
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.AlarmService;
import org.apache.skywalking.apm.collector.ui.service.ApplicationService;
import org.apache.skywalking.apm.collector.ui.service.ClusterTopologyService;
import org.apache.skywalking.apm.collector.ui.service.NetworkAddressService;
import org.apache.skywalking.apm.collector.ui.service.ServerService;
import org.apache.skywalking.apm.collector.ui.service.ServiceNameService;
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
......@@ -48,7 +47,6 @@ public class OverViewLayerQuery implements Query {
private ApplicationService applicationService;
private NetworkAddressService networkAddressService;
private ServiceNameService serviceNameService;
private ServerService serverService;
private AlarmService alarmService;
public OverViewLayerQuery(ModuleManager moduleManager) {
......@@ -90,13 +88,6 @@ public class OverViewLayerQuery implements Query {
return alarmService;
}
private ServerService getServerService() {
if (ObjectUtils.isEmpty(serverService)) {
this.serverService = new ServerService(moduleManager);
}
return serverService;
}
public Topology getClusterTopology(Duration duration) throws ParseException {
long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
......@@ -135,11 +126,11 @@ public class OverViewLayerQuery implements Query {
return getServiceNameService().getSlowService(duration.getStep(), start, end, topN);
}
public List<AppServerInfo> getTopNServerThroughput(int applicationId, Duration duration,
public List<ApplicationTPS> getTopNApplicationThroughput(Duration duration,
int topN) throws ParseException {
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
return getServerService().getTopNServerThroughput(applicationId, duration.getStep(), start, end, topN);
return getApplicationService().getTopNApplicationThroughput(duration.getStep(), start, end, topN);
}
}
......@@ -70,8 +70,11 @@ public class ServiceQuery implements Query {
return getServiceNameService().getServiceResponseTimeTrend(serviceId, duration.getStep(), start, end);
}
public ThroughputTrend getServiceTPSTrend(int serviceId, Duration duration) {
return null;
public ThroughputTrend getServiceTPSTrend(int serviceId, Duration duration) throws ParseException {
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
return getServiceNameService().getServiceTPSTrend(serviceId, duration.getStep(), start, end);
}
public SLATrend getServiceSLATrend(int serviceId, Duration duration) throws ParseException {
......
......@@ -25,11 +25,13 @@ import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService
import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.ui.application.Application;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
import org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationTPS;
import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric;
/**
......@@ -39,12 +41,14 @@ public class ApplicationService {
private final IInstanceUIDAO instanceDAO;
private final IServiceMetricUIDAO serviceMetricUIDAO;
private final IApplicationMetricUIDAO applicationMetricUIDAO;
private final ApplicationCacheService applicationCacheService;
private final ServiceNameCacheService serviceNameCacheService;
public ApplicationService(ModuleManager moduleManager) {
this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class);
this.serviceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceMetricUIDAO.class);
this.applicationMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMetricUIDAO.class);
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
}
......@@ -69,4 +73,15 @@ public class ApplicationService {
});
return slowServices;
}
public List<ApplicationTPS> getTopNApplicationThroughput(Step step, long start, long end,
int topN) throws ParseException {
//TODO
List<ApplicationTPS> applicationThroughput = applicationMetricUIDAO.getTopNApplicationThroughput(step, start, end, 1000, topN, MetricSource.Callee);
applicationThroughput.forEach(applicationTPS -> {
String applicationCode = applicationCacheService.getApplicationById(applicationTPS.getApplicationId()).getApplicationCode();
applicationTPS.setApplicationCode(applicationCode);
});
return applicationThroughput;
}
}
......@@ -72,18 +72,6 @@ public class ServerService {
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
}
public List<AppServerInfo> getTopNServerThroughput(int applicationId, Step step, long start, long end, int topN) {
//TODO
List<AppServerInfo> appServerInfos = instanceMetricUIDAO.getTopNServerThroughput(applicationId, step, start, end, 1000, topN, MetricSource.Callee);
appServerInfos.forEach(appServerInfo -> {
Instance instance = instanceUIDAO.getInstance(appServerInfo.getId());
appServerInfo.setOsInfo(instance.getOsInfo());
});
buildAppServerInfo(appServerInfos);
return appServerInfos;
}
public List<AppServerInfo> searchServer(String keyword, long start, long end) {
List<AppServerInfo> serverInfos = instanceUIDAO.searchServer(keyword, start, end);
serverInfos.forEach(serverInfo -> {
......@@ -111,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);
......
......@@ -30,6 +30,7 @@ import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend;
import org.apache.skywalking.apm.collector.storage.ui.common.SLATrend;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend;
import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo;
import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric;
import org.apache.skywalking.apm.collector.storage.utils.DurationPoint;
......@@ -58,6 +59,17 @@ public class ServiceNameService {
return serviceNameServiceUIDAO.searchService(keyword, topN);
}
public ThroughputTrend getServiceTPSTrend(int serviceId, Step step, long start, long end) throws ParseException {
ThroughputTrend throughputTrend = new ThroughputTrend();
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end);
List<Integer> callsTrends = serviceMetricUIDAO.getServiceTPSTrend(serviceId, step, durationPoints);
//TODO
callsTrends.forEach(calls -> throughputTrend.getTrendList().add(calls / 1000));
return throughputTrend;
}
public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Step step, long start,
long end) throws ParseException {
ResponseTimeTrend responseTimeTrend = new ResponseTimeTrend();
......
......@@ -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!]!
}
......@@ -27,11 +27,17 @@ type ConjecturalApp {
num: Int!
}
type ApplicationTPS {
applicationId: Int!
applicationCode: String
tps: Int!
}
extend type Query {
getClusterTopology(duration: Duration!): Topology
getClusterBrief(duration: Duration!): ClusterBrief
getAlarmTrend(duration: Duration!): AlarmTrend
getConjecturalApps(duration: Duration!): ConjecturalAppBrief
getTopNSlowService(duration: Duration!, topN: Int!): [ServiceMetric!]!
getTopNServerThroughput(applicationId: Int, duration: Duration!, topN: Int!): [AppServerInfo!]!
getTopNApplicationThroughput(duration: Duration!, topN: Int!): [ApplicationTPS!]!
}
......@@ -7,7 +7,7 @@ type AppServerInfo {
id: ID!
name: String!
applicationId: Int!
applicationName: String
applicationCode: String
tps: Int!
host: String
pid: Int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册