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 2023/12/01 18:39:52 UTC

(skywalking) branch master updated: Add `layer` parameter to the global topology graphQL query. (#11620)

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/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new e9df2bd41e Add `layer` parameter to the global topology graphQL query. (#11620)
e9df2bd41e is described below

commit e9df2bd41ea3ad618417fd75d4b14d01deb57aaa
Author: mrproliu <74...@qq.com>
AuthorDate: Sat Dec 2 02:39:45 2023 +0800

    Add `layer` parameter to the global topology graphQL query. (#11620)
---
 docs/en/changes/changes.md                           |  2 +-
 .../oap/server/core/query/TopologyQueryService.java  | 20 +++++++++++++++++++-
 .../oap/query/graphql/resolver/TopologyQuery.java    |  4 ++--
 .../src/main/resources/query-protocol                |  2 +-
 test/e2e-v2/cases/simple/simple-cases.yaml           |  2 ++
 test/e2e-v2/script/env                               |  2 +-
 6 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 9d0433e046..85c2a66a65 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -4,7 +4,7 @@
 
 
 #### OAP Server
-
+* Add `layer` parameter to the global topology graphQL query.
 
 #### UI
 
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java
index 69ebfee476..449428f434 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java
@@ -39,12 +39,16 @@ import org.apache.skywalking.oap.server.core.storage.query.ITopologyQueryDAO;
 import org.apache.skywalking.oap.server.library.module.ModuleManager;
 import org.apache.skywalking.oap.server.library.module.Service;
 import org.apache.skywalking.oap.server.library.util.CollectionUtils;
+import org.apache.skywalking.oap.server.library.util.StringUtil;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 @Slf4j
 public class TopologyQueryService implements Service {
@@ -52,6 +56,7 @@ public class TopologyQueryService implements Service {
     private final StorageModels storageModels;
     private ITopologyQueryDAO topologyQueryDAO;
     private IComponentLibraryCatalogService componentLibraryCatalogService;
+    private MetadataQueryService metadataQueryService;
 
     public TopologyQueryService(ModuleManager moduleManager, StorageModels storageModels) {
         this.moduleManager = moduleManager;
@@ -65,6 +70,13 @@ public class TopologyQueryService implements Service {
         return topologyQueryDAO;
     }
 
+    private MetadataQueryService getMetadataQueryService() {
+        if (metadataQueryService == null) {
+            metadataQueryService = moduleManager.find(CoreModule.NAME).provider().getService(MetadataQueryService.class);
+        }
+        return metadataQueryService;
+    }
+
     private IComponentLibraryCatalogService getComponentLibraryCatalogService() {
         if (componentLibraryCatalogService == null) {
             componentLibraryCatalogService = moduleManager.find(CoreModule.NAME)
@@ -74,7 +86,13 @@ public class TopologyQueryService implements Service {
         return componentLibraryCatalogService;
     }
 
-    public Topology getGlobalTopology(final Duration duration) throws IOException {
+    public Topology getGlobalTopology(final Duration duration, final String layer) throws IOException {
+        if (StringUtil.isNotEmpty(layer)) {
+            final List<String> serviceIdList = Optional.ofNullable(getMetadataQueryService().listServices(layer, null))
+                .map(list -> list.stream().map(s -> s.getId()).collect(Collectors.toList()))
+                .orElse(Collections.emptyList());
+            return getServiceTopology(duration, serviceIdList);
+        }
         List<Call.CallDetail> serviceRelationServerCalls = getTopologyQueryDAO().loadServiceRelationsDetectedAtServerSide(
             duration);
         List<Call.CallDetail> serviceRelationClientCalls = getTopologyQueryDAO().loadServiceRelationDetectedAtClientSide(
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java
index 4c4b99aab5..7328a272af 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java
@@ -47,8 +47,8 @@ public class TopologyQuery implements GraphQLQueryResolver {
         return queryService;
     }
 
-    public Topology getGlobalTopology(final Duration duration) throws IOException {
-        return getQueryService().getGlobalTopology(duration);
+    public Topology getGlobalTopology(final Duration duration, final String layer) throws IOException {
+        return getQueryService().getGlobalTopology(duration, layer);
     }
 
     public Topology getServiceTopology(final String serviceId, final Duration duration) throws IOException {
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
index ee452f9285..e08b0a7825 160000
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
@@ -1 +1 @@
-Subproject commit ee452f9285cebb84bb348a03338adc45258eb27e
+Subproject commit e08b0a78258a4c56e67076424add6bc2d0a1dd08
diff --git a/test/e2e-v2/cases/simple/simple-cases.yaml b/test/e2e-v2/cases/simple/simple-cases.yaml
index a256a9b5e6..2c13590839 100644
--- a/test/e2e-v2/cases/simple/simple-cases.yaml
+++ b/test/e2e-v2/cases/simple/simple-cases.yaml
@@ -31,6 +31,8 @@ cases:
   - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql endpoint list --keyword=users --service-name=e2e-service-consumer
     expected: expected/service-endpoint-consumer.yml
   # dependency service
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql dependency global --layer=GENERAL
+    expected: expected/dependency-services-provider.yml
   - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql dependency service --service-name=e2e-service-provider
     expected: expected/dependency-services-provider.yml
   - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql dependency service --service-name=e2e-service-consumer
diff --git a/test/e2e-v2/script/env b/test/e2e-v2/script/env
index 3617515f88..f2bb2999b3 100644
--- a/test/e2e-v2/script/env
+++ b/test/e2e-v2/script/env
@@ -26,4 +26,4 @@ SW_ROVER_COMMIT=fc8d074c6d34ecfee585a7097cbd5aef1ca680a5
 SW_BANYANDB_COMMIT=84f32b3969cdcc676aaee428383b34b3b67dbdf5
 SW_AGENT_PHP_COMMIT=3192c553002707d344bd6774cfab5bc61f67a1d3
 
-SW_CTL_COMMIT=d4f774f36ffdf8aaab75e2bca1f4a9edcf022192
+SW_CTL_COMMIT=d5f3597733aa5217373986d776a3ee5ee8b3c468