wu-sheng closed pull request #1165: Get conjectural node component name from 
component server name.
URL: https://github.com/apache/incubator-skywalking/pull/1165
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
index a91f187d5..359f5b5c2 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
@@ -18,21 +18,17 @@
 
 package org.apache.skywalking.apm.collector.ui.query;
 
+import java.text.ParseException;
+import java.util.List;
 import org.apache.skywalking.apm.collector.core.module.ModuleManager;
 import org.apache.skywalking.apm.collector.storage.ui.application.Application;
-import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
-import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
+import org.apache.skywalking.apm.collector.storage.ui.common.*;
 import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo;
 import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric;
 import org.apache.skywalking.apm.collector.ui.graphql.Query;
-import org.apache.skywalking.apm.collector.ui.service.ApplicationService;
-import 
org.apache.skywalking.apm.collector.ui.service.ApplicationTopologyService;
-import org.apache.skywalking.apm.collector.ui.service.ServerService;
+import org.apache.skywalking.apm.collector.ui.service.*;
 import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
 
-import java.text.ParseException;
-import java.util.List;
-
 import static java.util.Objects.isNull;
 
 /**
@@ -70,7 +66,7 @@ private ServerService getServerService() {
         return serverService;
     }
 
-    public List<Application> getAllApplication(Duration duration) throws 
ParseException {
+    public List<Application> getAllApplication(Duration duration) {
         long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
         long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
@@ -88,7 +84,7 @@ public Topology getApplicationTopology(int applicationId, 
Duration duration) thr
     }
 
     public List<ServiceMetric> getSlowService(int applicationId, Duration 
duration,
-        Integer topN) throws ParseException {
+        Integer topN) {
         long startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
         long endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
 
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java
index dcfd4d1f0..b2ad2354b 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java
@@ -21,22 +21,11 @@
 import java.text.ParseException;
 import java.util.List;
 import org.apache.skywalking.apm.collector.core.module.ModuleManager;
-import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
-import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
-import org.apache.skywalking.apm.collector.storage.ui.common.ValueType;
-import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend;
-import 
org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationThroughput;
-import org.apache.skywalking.apm.collector.storage.ui.overview.ClusterBrief;
-import 
org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalAppBrief;
-import org.apache.skywalking.apm.collector.storage.ui.overview.Thermodynamic;
+import org.apache.skywalking.apm.collector.storage.ui.common.*;
+import org.apache.skywalking.apm.collector.storage.ui.overview.*;
 import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric;
 import org.apache.skywalking.apm.collector.ui.graphql.Query;
-import org.apache.skywalking.apm.collector.ui.service.AlarmService;
-import org.apache.skywalking.apm.collector.ui.service.ApplicationService;
-import org.apache.skywalking.apm.collector.ui.service.ClusterTopologyService;
-import org.apache.skywalking.apm.collector.ui.service.NetworkAddressService;
-import 
org.apache.skywalking.apm.collector.ui.service.ResponseTimeDistributionService;
-import org.apache.skywalking.apm.collector.ui.service.ServiceNameService;
+import org.apache.skywalking.apm.collector.ui.service.*;
 import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
 
 import static java.util.Objects.isNull;
@@ -100,7 +89,7 @@ private ResponseTimeDistributionService 
getTimeDistributionService() {
         return timeDistributionService;
     }
 
-    public Topology getClusterTopology(Duration duration) throws 
ParseException {
+    public Topology getClusterTopology(Duration duration) {
         long startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
         long endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
 
@@ -110,7 +99,7 @@ public Topology getClusterTopology(Duration duration) throws 
ParseException {
         return 
getClusterTopologyService().getClusterTopology(duration.getStep(), 
startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket);
     }
 
-    public ClusterBrief getClusterBrief(Duration duration) throws 
ParseException {
+    public ClusterBrief getClusterBrief(Duration duration) {
         long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
         long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
@@ -133,14 +122,14 @@ public AlarmTrend getAlarmTrend(Duration duration) throws 
ParseException {
         return getAlarmService().getApplicationAlarmTrend(duration.getStep(), 
startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket);
     }
 
-    public ConjecturalAppBrief getConjecturalApps(Duration duration) throws 
ParseException {
+    public ConjecturalAppBrief getConjecturalApps(Duration duration) {
         long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
         long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         return getApplicationService().getConjecturalApps(duration.getStep(), 
startSecondTimeBucket, endSecondTimeBucket);
     }
 
-    public List<ServiceMetric> getTopNSlowService(Duration duration, int topN) 
throws ParseException {
+    public List<ServiceMetric> getTopNSlowService(Duration duration, int topN) 
{
         long startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
         long endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
 
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java
index b24fef855..61159c358 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java
@@ -18,25 +18,15 @@
 
 package org.apache.skywalking.apm.collector.ui.service;
 
-import java.text.ParseException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
 import 
org.apache.skywalking.apm.collector.configuration.service.IComponentLibraryCatalogService;
 import org.apache.skywalking.apm.collector.core.module.ModuleManager;
 import org.apache.skywalking.apm.collector.storage.StorageModule;
-import 
org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO;
-import 
org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO;
-import 
org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
-import 
org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO;
+import org.apache.skywalking.apm.collector.storage.dao.ui.*;
 import org.apache.skywalking.apm.collector.storage.table.MetricSource;
-import org.apache.skywalking.apm.collector.storage.ui.common.Step;
-import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.skywalking.apm.collector.storage.ui.common.*;
+import org.slf4j.*;
 
 /**
  * @author peng-yongsheng
@@ -62,7 +52,7 @@ public ApplicationTopologyService(ModuleManager 
moduleManager) {
     }
 
     public Topology getApplicationTopology(Step step, int applicationId, long 
startTimeBucket,
-        long endTimeBucket, long startSecondTimeBucket, long 
endSecondTimeBucket) throws ParseException {
+        long endTimeBucket, long startSecondTimeBucket, long 
endSecondTimeBucket) {
         logger.debug("startTimeBucket: {}, endTimeBucket: {}", 
startTimeBucket, endTimeBucket);
         List<IApplicationComponentUIDAO.ApplicationComponent> 
applicationComponents = applicationComponentUIDAO.load(step, startTimeBucket, 
endTimeBucket);
         List<IApplicationMappingUIDAO.ApplicationMapping> applicationMappings 
= applicationMappingUIDAO.load(step, startTimeBucket, endTimeBucket);
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
index 55d13711e..81389f028 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
@@ -61,7 +61,8 @@ Topology 
build(List<IApplicationComponentUIDAO.ApplicationComponent> application
         List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> 
callerReferenceMetric,
         List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> 
calleeReferenceMetric,
         Step step, long startTimeBucket, long endTimeBucket, long 
startSecondTimeBucket, long endSecondTimeBucket) {
-        Map<Integer, String> components = 
changeNodeComp2Map(applicationComponents);
+        Map<Integer, String> nodeCompMap = 
buildNodeCompMap(applicationComponents);
+        Map<Integer, String> conjecturalNodeCompMap = 
buildConjecturalNodeCompMap(applicationComponents);
         Map<Integer, Integer> mappings = 
changeMapping2Map(applicationMappings);
 
         filterZeroSourceOrTargetReference(callerReferenceMetric);
@@ -76,7 +77,7 @@ Topology 
build(List<IApplicationComponentUIDAO.ApplicationComponent> application
             ApplicationNode applicationNode = new ApplicationNode();
             applicationNode.setId(applicationId);
             applicationNode.setName(application.getApplicationCode());
-            
applicationNode.setType(components.getOrDefault(application.getApplicationId(), 
Const.UNKNOWN));
+            
applicationNode.setType(nodeCompMap.getOrDefault(application.getApplicationId(),
 Const.UNKNOWN));
 
             
applicationNode.setSla(SLACalculator.INSTANCE.calculate(applicationMetric.getErrorCalls(),
 applicationMetric.getCalls()));
             try {
@@ -124,7 +125,7 @@ Topology 
build(List<IApplicationComponentUIDAO.ApplicationComponent> application
                     ConjecturalNode conjecturalNode = new ConjecturalNode();
                     conjecturalNode.setId(target.getApplicationId());
                     conjecturalNode.setName(target.getApplicationCode());
-                    
conjecturalNode.setType(components.getOrDefault(target.getApplicationId(), 
Const.UNKNOWN));
+                    
conjecturalNode.setType(conjecturalNodeCompMap.getOrDefault(target.getApplicationId(),
 Const.UNKNOWN));
                     nodes.add(conjecturalNode);
                     nodeIds.add(target.getApplicationId());
                 }
@@ -135,7 +136,7 @@ Topology 
build(List<IApplicationComponentUIDAO.ApplicationComponent> application
                 ApplicationNode applicationNode = new ApplicationNode();
                 applicationNode.setId(source.getApplicationId());
                 applicationNode.setName(source.getApplicationCode());
-                
applicationNode.setType(components.getOrDefault(source.getApplicationId(), 
Const.UNKNOWN));
+                
applicationNode.setType(nodeCompMap.getOrDefault(source.getApplicationId(), 
Const.UNKNOWN));
                 applicationNode.setApdex(100);
                 applicationNode.setSla(100);
                 nodes.add(applicationNode);
@@ -149,7 +150,7 @@ Topology 
build(List<IApplicationComponentUIDAO.ApplicationComponent> application
             call.setTarget(actualTargetId);
             
call.setTargetName(applicationCacheService.getApplicationById(actualTargetId).getApplicationCode());
             call.setAlert(false);
-            call.setCallType(components.get(referenceMetric.getTarget()));
+            call.setCallType(nodeCompMap.get(referenceMetric.getTarget()));
             try {
                 call.setCpm(referenceMetric.getCalls() / 
dateBetweenService.minutesBetween(source.getApplicationId(), 
startSecondTimeBucket, endSecondTimeBucket));
             } catch (ParseException e) {
@@ -179,7 +180,7 @@ Topology 
build(List<IApplicationComponentUIDAO.ApplicationComponent> application
                     ConjecturalNode conjecturalNode = new ConjecturalNode();
                     conjecturalNode.setId(source.getApplicationId());
                     conjecturalNode.setName(source.getApplicationCode());
-                    
conjecturalNode.setType(components.getOrDefault(source.getApplicationId(), 
Const.UNKNOWN));
+                    
conjecturalNode.setType(conjecturalNodeCompMap.getOrDefault(target.getApplicationId(),
 Const.UNKNOWN));
                     nodeIds.add(source.getApplicationId());
                     nodes.add(conjecturalNode);
                 }
@@ -195,7 +196,7 @@ Topology 
build(List<IApplicationComponentUIDAO.ApplicationComponent> application
             if (source.getApplicationId() == Const.NONE_APPLICATION_ID) {
                 call.setCallType(Const.EMPTY_STRING);
             } else {
-                call.setCallType(components.get(referenceMetric.getTarget()));
+                call.setCallType(nodeCompMap.get(referenceMetric.getTarget()));
             }
             try {
                 call.setCpm(referenceMetric.getCalls() / 
dateBetweenService.minutesBetween(target.getApplicationId(), 
startSecondTimeBucket, endSecondTimeBucket));
@@ -239,7 +240,18 @@ Topology 
build(List<IApplicationComponentUIDAO.ApplicationComponent> application
         return mappings;
     }
 
-    private Map<Integer, String> changeNodeComp2Map(
+    private Map<Integer, String> buildConjecturalNodeCompMap(
+        List<IApplicationComponentUIDAO.ApplicationComponent> 
applicationComponents) {
+        Map<Integer, String> components = new HashMap<>();
+        applicationComponents.forEach(applicationComponent -> {
+            int componentServerId = 
this.componentLibraryCatalogService.getServerIdBasedOnComponent(applicationComponent.getComponentId());
+            String componentName = 
this.componentLibraryCatalogService.getServerName(componentServerId);
+            components.put(applicationComponent.getApplicationId(), 
componentName);
+        });
+        return components;
+    }
+
+    private Map<Integer, String> buildNodeCompMap(
         List<IApplicationComponentUIDAO.ApplicationComponent> 
applicationComponents) {
         Map<Integer, String> components = new HashMap<>();
         applicationComponents.forEach(applicationComponent -> {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to