Skip to content

Commit

Permalink
Fix limit doesn't work for findEndpoint API in ES storage
Browse files Browse the repository at this point in the history
  • Loading branch information
kezhenxu94 committed Nov 2, 2023
1 parent 92af797 commit 8a235c2
Showing 1 changed file with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.apache.skywalking.library.elasticsearch.response.search.SearchHit;
import org.apache.skywalking.library.elasticsearch.response.search.SearchResponse;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.Layer;
import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic;
import org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic;
Expand Down Expand Up @@ -71,7 +70,6 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
private final int scrollingBatchSize;
private String endpointTrafficNameAlias;
private boolean aliasNameInit = false;
private final int layerSize;

protected final Function<SearchHit, Service> searchHitServiceFunction = hit -> {
final var sourceAsMap = hit.getSource();
Expand Down Expand Up @@ -121,7 +119,6 @@ public MetadataQueryEsDAO(
super(client);
this.queryMaxSize = config.getMetadataQueryMaxSize();
this.scrollingBatchSize = config.getScrollingBatchSize();
this.layerSize = Layer.values().length;
}

@Override
Expand Down Expand Up @@ -231,14 +228,14 @@ public List<Endpoint> findEndpoint(String keyword, String serviceId, int limit)
query.must(Query.term(IndexController.LogicIndicesRegister.METRIC_TABLE_NAME, EndpointTraffic.INDEX_NAME));
}

final var search = Search.builder().query(query).size(limit);
final var search = Search.builder().query(query);

final var scroller = ElasticSearchScroller
.<Endpoint>builder()
.client(getClient())
.search(search.build())
.index(index)
.queryMaxSize(queryMaxSize)
.queryMaxSize(Math.min(limit, queryMaxSize))
.resultConverter(searchHit -> {
final var sourceAsMap = searchHit.getSource();

Expand Down Expand Up @@ -404,14 +401,6 @@ public Process getProcess(String processId) {
return null;
}

private List<Service> buildServices(SearchResponse response) {
List<Service> services = new ArrayList<>();
for (SearchHit hit : response.getHits()) {
services.add(searchHitServiceFunction.apply(hit));
}
return services;
}

private List<ServiceInstance> buildInstances(SearchResponse response) {
List<ServiceInstance> serviceInstances = new ArrayList<>();
for (SearchHit searchHit : response.getHits()) {
Expand Down

0 comments on commit 8a235c2

Please sign in to comment.