You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2018/10/09 13:58:32 UTC
[incubator-skywalking] branch master updated: Get the value column
name from value column annotation manager. (#1737)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 1a49f70 Get the value column name from value column annotation manager. (#1737)
1a49f70 is described below
commit 1a49f7053c966aecd2271a40017e13f2ed54c6b9
Author: 彭勇升 pengys <80...@qq.com>
AuthorDate: Tue Oct 9 21:58:26 2018 +0800
Get the value column name from value column annotation manager. (#1737)
---
.../server/core/query/AggregationQueryService.java | 21 ++++++------
.../core/storage/query/IAggregationQueryDAO.java | 12 ++++---
.../elasticsearch/query/AggregationQueryEsDAO.java | 39 +++++++++++-----------
3 files changed, 38 insertions(+), 34 deletions(-)
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AggregationQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AggregationQueryService.java
index f487368..6e247c6 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AggregationQueryService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AggregationQueryService.java
@@ -25,6 +25,7 @@ import org.apache.skywalking.oap.server.core.cache.*;
import org.apache.skywalking.oap.server.core.query.entity.*;
import org.apache.skywalking.oap.server.core.register.*;
import org.apache.skywalking.oap.server.core.storage.StorageModule;
+import org.apache.skywalking.oap.server.core.storage.annotation.ValueColumnIds;
import org.apache.skywalking.oap.server.core.storage.query.IAggregationQueryDAO;
import org.apache.skywalking.oap.server.library.module.*;
import org.apache.skywalking.oap.server.library.module.Service;
@@ -48,9 +49,9 @@ public class AggregationQueryService implements Service {
return aggregationQueryDAO;
}
- public List<TopNEntity> getServiceTopN(final String name, final int topN, final Step step, final long startTB,
+ public List<TopNEntity> getServiceTopN(final String indName, final int topN, final Step step, final long startTB,
final long endTB, final Order order) throws IOException {
- List<TopNEntity> topNEntities = getAggregationQueryDAO().getServiceTopN(name, topN, step, startTB, endTB, order);
+ List<TopNEntity> topNEntities = getAggregationQueryDAO().getServiceTopN(indName, ValueColumnIds.INSTANCE.getValueCName(indName), topN, step, startTB, endTB, order);
for (TopNEntity entity : topNEntities) {
ServiceInventory inventory = moduleManager.find(CoreModule.NAME).getService(ServiceInventoryCache.class).get(Integer.valueOf(entity.getId()));
if (inventory != null) {
@@ -60,9 +61,9 @@ public class AggregationQueryService implements Service {
return topNEntities;
}
- public List<TopNEntity> getAllServiceInstanceTopN(final String name, final int topN, final Step step,
+ public List<TopNEntity> getAllServiceInstanceTopN(final String indName, final int topN, final Step step,
final long startTB, final long endTB, final Order order) throws IOException {
- List<TopNEntity> topNEntities = getAggregationQueryDAO().getAllServiceInstanceTopN(name, topN, step, startTB, endTB, order);
+ List<TopNEntity> topNEntities = getAggregationQueryDAO().getAllServiceInstanceTopN(indName, ValueColumnIds.INSTANCE.getValueCName(indName), topN, step, startTB, endTB, order);
for (TopNEntity entity : topNEntities) {
ServiceInstanceInventory inventory = moduleManager.find(CoreModule.NAME).getService(ServiceInstanceInventoryCache.class).get(Integer.valueOf(entity.getId()));
if (inventory != null) {
@@ -72,9 +73,9 @@ public class AggregationQueryService implements Service {
return topNEntities;
}
- public List<TopNEntity> getServiceInstanceTopN(final int serviceId, final String name, final int topN,
+ public List<TopNEntity> getServiceInstanceTopN(final int serviceId, final String indName, final int topN,
final Step step, final long startTB, final long endTB, final Order order) throws IOException {
- List<TopNEntity> topNEntities = getAggregationQueryDAO().getServiceInstanceTopN(serviceId, name, topN, step, startTB, endTB, order);
+ List<TopNEntity> topNEntities = getAggregationQueryDAO().getServiceInstanceTopN(serviceId, indName, ValueColumnIds.INSTANCE.getValueCName(indName), topN, step, startTB, endTB, order);
for (TopNEntity entity : topNEntities) {
ServiceInstanceInventory inventory = moduleManager.find(CoreModule.NAME).getService(ServiceInstanceInventoryCache.class).get(Integer.valueOf(entity.getId()));
if (inventory != null) {
@@ -84,9 +85,9 @@ public class AggregationQueryService implements Service {
return topNEntities;
}
- public List<TopNEntity> getAllEndpointTopN(final String name, final int topN, final Step step,
+ public List<TopNEntity> getAllEndpointTopN(final String indName, final int topN, final Step step,
final long startTB, final long endTB, final Order order) throws IOException {
- List<TopNEntity> topNEntities = getAggregationQueryDAO().getAllEndpointTopN(name, topN, step, startTB, endTB, order);
+ List<TopNEntity> topNEntities = getAggregationQueryDAO().getAllEndpointTopN(indName, ValueColumnIds.INSTANCE.getValueCName(indName), topN, step, startTB, endTB, order);
for (TopNEntity entity : topNEntities) {
EndpointInventory inventory = moduleManager.find(CoreModule.NAME).getService(EndpointInventoryCache.class).get(Integer.valueOf(entity.getId()));
if (inventory != null) {
@@ -96,9 +97,9 @@ public class AggregationQueryService implements Service {
return topNEntities;
}
- public List<TopNEntity> getEndpointTopN(final int serviceId, final String name, final int topN,
+ public List<TopNEntity> getEndpointTopN(final int serviceId, final String indName, final int topN,
final Step step, final long startTB, final long endTB, final Order order) throws IOException {
- List<TopNEntity> topNEntities = getAggregationQueryDAO().getEndpointTopN(serviceId, name, topN, step, startTB, endTB, order);
+ List<TopNEntity> topNEntities = getAggregationQueryDAO().getEndpointTopN(serviceId, indName, ValueColumnIds.INSTANCE.getValueCName(indName), topN, step, startTB, endTB, order);
for (TopNEntity entity : topNEntities) {
EndpointInventory inventory = moduleManager.find(CoreModule.NAME).getService(EndpointInventoryCache.class).get(Integer.valueOf(entity.getId()));
if (inventory != null) {
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IAggregationQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IAggregationQueryDAO.java
index 1310c4e..932aa3e 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IAggregationQueryDAO.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IAggregationQueryDAO.java
@@ -28,18 +28,20 @@ import org.apache.skywalking.oap.server.core.storage.DAO;
*/
public interface IAggregationQueryDAO extends DAO {
- List<TopNEntity> getServiceTopN(final String name, final int topN, final Step step, final long startTB,
+ List<TopNEntity> getServiceTopN(final String indName, String valueCName, final int topN, final Step step,
+ final long startTB,
final long endTB, final Order order) throws IOException;
- List<TopNEntity> getAllServiceInstanceTopN(final String name, final int topN, final Step step,
+ List<TopNEntity> getAllServiceInstanceTopN(final String indName, String valueCName, final int topN, final Step step,
final long startTB, final long endTB, final Order order) throws IOException;
- List<TopNEntity> getServiceInstanceTopN(final int serviceId, final String name, final int topN,
+ List<TopNEntity> getServiceInstanceTopN(final int serviceId, final String indName, String valueCName,
+ final int topN,
final Step step, final long startTB, final long endTB, final Order order) throws IOException;
- List<TopNEntity> getAllEndpointTopN(final String name, final int topN, final Step step,
+ List<TopNEntity> getAllEndpointTopN(final String indName, String valueCName, final int topN, final Step step,
final long startTB, final long endTB, final Order order) throws IOException;
- List<TopNEntity> getEndpointTopN(final int serviceId, final String name, final int topN,
+ List<TopNEntity> getEndpointTopN(final int serviceId, final String indName, String valueCName, final int topN,
final Step step, final long startTB, final long endTB, final Order order) throws IOException;
}
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java
index 2868da6..eecd4ce 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java
@@ -44,27 +44,27 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO
}
@Override
- public List<TopNEntity> getServiceTopN(String name, int topN, Step step, long startTB,
+ public List<TopNEntity> getServiceTopN(String indName, String valueCName, int topN, Step step, long startTB,
long endTB, Order order) throws IOException {
- String indexName = TimePyramidTableNameBuilder.build(step, name);
+ String indexName = TimePyramidTableNameBuilder.build(step, indName);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
sourceBuilder.query(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB));
- return aggregation(indexName, sourceBuilder, topN, order);
+ return aggregation(indexName, valueCName, sourceBuilder, topN, order);
}
- @Override public List<TopNEntity> getAllServiceInstanceTopN(String name, int topN, Step step,
+ @Override public List<TopNEntity> getAllServiceInstanceTopN(String indName, String valueCName, int topN, Step step,
long startTB, long endTB, Order order) throws IOException {
- String indexName = TimePyramidTableNameBuilder.build(step, name);
+ String indexName = TimePyramidTableNameBuilder.build(step, indName);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
sourceBuilder.query(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB));
- return aggregation(indexName, sourceBuilder, topN, order);
+ return aggregation(indexName, valueCName, sourceBuilder, topN, order);
}
- @Override public List<TopNEntity> getServiceInstanceTopN(int serviceId, String name, int topN,
+ @Override public List<TopNEntity> getServiceInstanceTopN(int serviceId, String indName, String valueCName, int topN,
Step step, long startTB, long endTB, Order order) throws IOException {
- String indexName = TimePyramidTableNameBuilder.build(step, name);
+ String indexName = TimePyramidTableNameBuilder.build(step, indName);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
@@ -74,23 +74,23 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO
boolQueryBuilder.must().add(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB));
boolQueryBuilder.must().add(QueryBuilders.termQuery(ServiceInstanceInventory.SERVICE_ID, serviceId));
- return aggregation(indexName, sourceBuilder, topN, order);
+ return aggregation(indexName, valueCName, sourceBuilder, topN, order);
}
@Override
- public List<TopNEntity> getAllEndpointTopN(String name, int topN, Step step, long startTB,
+ public List<TopNEntity> getAllEndpointTopN(String indName, String valueCName, int topN, Step step, long startTB,
long endTB, Order order) throws IOException {
- String indexName = TimePyramidTableNameBuilder.build(step, name);
+ String indexName = TimePyramidTableNameBuilder.build(step, indName);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
sourceBuilder.query(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB));
- return aggregation(indexName, sourceBuilder, topN, order);
+ return aggregation(indexName, valueCName, sourceBuilder, topN, order);
}
@Override
- public List<TopNEntity> getEndpointTopN(int serviceId, String name, int topN, Step step,
+ public List<TopNEntity> getEndpointTopN(int serviceId, String indName, String valueCName, int topN, Step step,
long startTB, long endTB, Order order) throws IOException {
- String indexName = TimePyramidTableNameBuilder.build(step, name);
+ String indexName = TimePyramidTableNameBuilder.build(step, indName);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
@@ -100,10 +100,11 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO
boolQueryBuilder.must().add(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB));
boolQueryBuilder.must().add(QueryBuilders.termQuery(EndpointInventory.SERVICE_ID, serviceId));
- return aggregation(indexName, sourceBuilder, topN, order);
+ return aggregation(indexName, valueCName, sourceBuilder, topN, order);
}
- private List<TopNEntity> aggregation(String indexName, SearchSourceBuilder sourceBuilder, int topN,
+ private List<TopNEntity> aggregation(String indexName, String valueCName, SearchSourceBuilder sourceBuilder,
+ int topN,
Order order) throws IOException {
boolean asc = false;
if (order.equals(Order.ASC)) {
@@ -113,10 +114,10 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO
TermsAggregationBuilder aggregationBuilder = AggregationBuilders
.terms(Indicator.ENTITY_ID)
.field(Indicator.ENTITY_ID)
- .order(BucketOrder.aggregation("value", asc))
+ .order(BucketOrder.aggregation(valueCName, asc))
.size(topN)
.subAggregation(
- AggregationBuilders.avg("value").field("value")
+ AggregationBuilders.avg(valueCName).field(valueCName)
);
sourceBuilder.aggregation(aggregationBuilder);
@@ -127,7 +128,7 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO
for (Terms.Bucket termsBucket : idTerms.getBuckets()) {
TopNEntity topNEntity = new TopNEntity();
topNEntity.setId(termsBucket.getKeyAsString());
- Avg value = termsBucket.getAggregations().get("value");
+ Avg value = termsBucket.getAggregations().get(valueCName);
topNEntity.setValue((int)value.getValue());
topNEntities.add(topNEntity);
}