wu-sheng commented on a change in pull request #4408: Support topology with multiple selected services URL: https://github.com/apache/skywalking/pull/4408#discussion_r383162223
########## File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java ########## @@ -90,30 +90,44 @@ private EndpointInventoryCache getEndpointInventoryCache() { } public Topology getGlobalTopology(final Downsampling downsampling, final long startTB, - final long endTB) throws IOException { + final long endTB) throws IOException { logger.debug("Downsampling: {}, startTimeBucket: {}, endTimeBucket: {}", downsampling, startTB, endTB); - List<Call.CallDetail> serviceRelationServerCalls = getTopologyQueryDAO().loadServerSideServiceRelations(downsampling, startTB, endTB); - List<Call.CallDetail> serviceRelationClientCalls = getTopologyQueryDAO().loadClientSideServiceRelations(downsampling, startTB, endTB); + List<Call.CallDetail> serviceRelationServerCalls = getTopologyQueryDAO().loadServerSideServiceRelations( + downsampling, startTB, endTB); + List<Call.CallDetail> serviceRelationClientCalls = getTopologyQueryDAO().loadClientSideServiceRelations( + downsampling, startTB, endTB); TopologyBuilder builder = new TopologyBuilder(moduleManager); return builder.build(serviceRelationClientCalls, serviceRelationServerCalls); } public Topology getServiceTopology(final Downsampling downsampling, final long startTB, final long endTB, - final int serviceId) throws IOException { - List<Integer> serviceIds = new ArrayList<>(); - serviceIds.add(serviceId); - - List<Call.CallDetail> serviceRelationClientCalls = getTopologyQueryDAO().loadSpecifiedClientSideServiceRelations(downsampling, startTB, endTB, serviceIds); - List<Call.CallDetail> serviceRelationServerCalls = getTopologyQueryDAO().loadSpecifiedServerSideServiceRelations(downsampling, startTB, endTB, serviceIds); + final List<Integer> serviceIds) throws IOException { + List<Call.CallDetail> serviceRelationClientCalls = getTopologyQueryDAO().loadSpecifiedClientSideServiceRelations( + downsampling, startTB, endTB, serviceIds); + List<Call.CallDetail> serviceRelationServerCalls = getTopologyQueryDAO().loadSpecifiedServerSideServiceRelations( + downsampling, startTB, endTB, serviceIds); TopologyBuilder builder = new TopologyBuilder(moduleManager); Topology topology = builder.build(serviceRelationClientCalls, serviceRelationServerCalls); - List<Integer> sourceServiceIds = new ArrayList<>(); - serviceRelationClientCalls.forEach(call -> sourceServiceIds.add(call.getSource())); - if (CollectionUtils.isNotEmpty(sourceServiceIds)) { - List<Call.CallDetail> sourceCalls = getTopologyQueryDAO().loadSpecifiedServerSideServiceRelations(downsampling, startTB, endTB, sourceServiceIds); + /** + * The topology built above is complete. + * There is a special case, there may be a node of the `serviceIds` call these services as and only as a client, so it is included in the topology, + * its component name could be missed as not being queried before. We add another query about this. + */ + List<Integer> outScopeSourceServiceIds = new ArrayList<>(); + serviceRelationClientCalls.forEach(call -> { + // Client side relationships exclude the given services(#serviceIds) + // The given services(#serviceIds)'s component names have been included inside `serviceRelationServerCalls` + if (!serviceIds.contains(call.getSource())) { + outScopeSourceServiceIds.add(call.getSource()); + } Review comment: All query in the condition service list scope, have been done before, this is just for filling the ones out of scope as the direct linked nodes. What is your question? I am confused. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services