Get the value column name from value column annotation manager. (#1737)
This commit is contained in:
parent
a062fdae71
commit
1a49f7053c
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue