提交 fc5f67f0 编写于 作者: P peng-yongsheng

Setting the alarm attributes in topology.

上级 3863aa71
...@@ -60,7 +60,7 @@ public class ApplicationTopologyService { ...@@ -60,7 +60,7 @@ public class ApplicationTopologyService {
public Topology getApplicationTopology(Step step, int applicationId, long startTimeBucket, public Topology getApplicationTopology(Step step, int applicationId, long startTimeBucket,
long endTimeBucket, long startSecondTimeBucket, long endSecondTimeBucket) throws ParseException { long endTimeBucket, long startSecondTimeBucket, long endSecondTimeBucket) throws ParseException {
logger.debug("startTime: {}, endTime: {}", startTimeBucket, endTimeBucket); logger.debug("startTimeBucket: {}, endTimeBucket: {}", startTimeBucket, endTimeBucket);
List<IApplicationComponentUIDAO.ApplicationComponent> applicationComponents = applicationComponentUIDAO.load(step, startTimeBucket, endTimeBucket); List<IApplicationComponentUIDAO.ApplicationComponent> applicationComponents = applicationComponentUIDAO.load(step, startTimeBucket, endTimeBucket);
List<IApplicationMappingUIDAO.ApplicationMapping> applicationMappings = applicationMappingUIDAO.load(step, startTimeBucket, endTimeBucket); List<IApplicationMappingUIDAO.ApplicationMapping> applicationMappings = applicationMappingUIDAO.load(step, startTimeBucket, endTimeBucket);
...@@ -82,6 +82,6 @@ public class ApplicationTopologyService { ...@@ -82,6 +82,6 @@ public class ApplicationTopologyService {
TopologyBuilder builder = new TopologyBuilder(moduleManager); TopologyBuilder builder = new TopologyBuilder(moduleManager);
return builder.build(applicationComponents, applicationMappings, applicationMetrics, callerReferenceMetric, calleeReferenceMetric, startSecondTimeBucket, endSecondTimeBucket); return builder.build(applicationComponents, applicationMappings, applicationMetrics, callerReferenceMetric, calleeReferenceMetric, startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket);
} }
} }
...@@ -72,6 +72,6 @@ public class ClusterTopologyService { ...@@ -72,6 +72,6 @@ public class ClusterTopologyService {
TopologyBuilder builder = new TopologyBuilder(moduleManager); TopologyBuilder builder = new TopologyBuilder(moduleManager);
return builder.build(applicationComponents, applicationMappings, applicationMetrics, callerReferenceMetric, calleeReferenceMetric, startSecondTimeBucket, endSecondTimeBucket); return builder.build(applicationComponents, applicationMappings, applicationMetrics, callerReferenceMetric, calleeReferenceMetric, startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket);
} }
} }
...@@ -94,6 +94,7 @@ public class ServiceTopologyService { ...@@ -94,6 +94,7 @@ public class ServiceTopologyService {
} catch (ParseException e) { } catch (ParseException e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} }
call.setAlert(false);
calls.add(call); calls.add(call);
}); });
......
...@@ -33,6 +33,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUID ...@@ -33,6 +33,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUID
import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO; 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.IApplicationReferenceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.table.register.Application; import org.apache.skywalking.apm.collector.storage.table.register.Application;
import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
import org.apache.skywalking.apm.collector.storage.ui.application.ApplicationNode; import org.apache.skywalking.apm.collector.storage.ui.application.ApplicationNode;
import org.apache.skywalking.apm.collector.storage.ui.application.ConjecturalNode; import org.apache.skywalking.apm.collector.storage.ui.application.ConjecturalNode;
import org.apache.skywalking.apm.collector.storage.ui.common.Call; import org.apache.skywalking.apm.collector.storage.ui.common.Call;
...@@ -55,11 +56,13 @@ class TopologyBuilder { ...@@ -55,11 +56,13 @@ class TopologyBuilder {
private final ApplicationCacheService applicationCacheService; private final ApplicationCacheService applicationCacheService;
private final ServerService serverService; private final ServerService serverService;
private final SecondBetweenService secondBetweenService; private final SecondBetweenService secondBetweenService;
private final AlarmService alarmService;
TopologyBuilder(ModuleManager moduleManager) { TopologyBuilder(ModuleManager moduleManager) {
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
this.serverService = new ServerService(moduleManager); this.serverService = new ServerService(moduleManager);
this.secondBetweenService = new SecondBetweenService(moduleManager); this.secondBetweenService = new SecondBetweenService(moduleManager);
this.alarmService = new AlarmService(moduleManager);
} }
Topology build(List<IApplicationComponentUIDAO.ApplicationComponent> applicationComponents, Topology build(List<IApplicationComponentUIDAO.ApplicationComponent> applicationComponents,
...@@ -67,7 +70,7 @@ class TopologyBuilder { ...@@ -67,7 +70,7 @@ class TopologyBuilder {
List<IApplicationMetricUIDAO.ApplicationMetric> applicationMetrics, List<IApplicationMetricUIDAO.ApplicationMetric> applicationMetrics,
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> callerReferenceMetric, List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> callerReferenceMetric,
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> calleeReferenceMetric, List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> calleeReferenceMetric,
long startSecondTimeBucket, long endSecondTimeBucket) { long startTimeBucket, long endTimeBucket, long startSecondTimeBucket, long endSecondTimeBucket) {
Map<Integer, String> components = changeNodeComp2Map(applicationComponents); Map<Integer, String> components = changeNodeComp2Map(applicationComponents);
Map<Integer, Integer> mappings = changeMapping2Map(applicationMappings); Map<Integer, Integer> mappings = changeMapping2Map(applicationMappings);
...@@ -91,9 +94,29 @@ class TopologyBuilder { ...@@ -91,9 +94,29 @@ class TopologyBuilder {
applicationNode.setAvgResponseTime((applicationMetric.getDurations() - applicationMetric.getErrorDurations()) / (applicationMetric.getCalls() - applicationMetric.getErrorCalls())); applicationNode.setAvgResponseTime((applicationMetric.getDurations() - applicationMetric.getErrorDurations()) / (applicationMetric.getCalls() - applicationMetric.getErrorCalls()));
applicationNode.setApdex(ApdexCalculator.INSTANCE.calculate(applicationMetric.getSatisfiedCount(), applicationMetric.getToleratingCount(), applicationMetric.getFrustratedCount())); applicationNode.setApdex(ApdexCalculator.INSTANCE.calculate(applicationMetric.getSatisfiedCount(), applicationMetric.getToleratingCount(), applicationMetric.getFrustratedCount()));
applicationNode.setAlarm(false); applicationNode.setAlarm(false);
try {
Alarm alarm = alarmService.loadApplicationAlarmList(Const.EMPTY_STRING, startTimeBucket, endTimeBucket, 1, 0);
if (alarm.getItems().size() > 0) {
applicationNode.setAlarm(true);
}
} catch (ParseException e) {
logger.error(e.getMessage(), e);
}
applicationNode.setNumOfServer(serverService.getAllServer(applicationId, startSecondTimeBucket, endSecondTimeBucket).size()); applicationNode.setNumOfServer(serverService.getAllServer(applicationId, startSecondTimeBucket, endSecondTimeBucket).size());
applicationNode.setNumOfServerAlarm(1); try {
applicationNode.setNumOfServiceAlarm(1); Alarm alarm = alarmService.loadInstanceAlarmList(Const.EMPTY_STRING, startTimeBucket, endTimeBucket, 1000, 0);
applicationNode.setNumOfServerAlarm(alarm.getItems().size());
} catch (ParseException e) {
logger.error(e.getMessage(), e);
}
try {
Alarm alarm = alarmService.loadServiceAlarmList(Const.EMPTY_STRING, startTimeBucket, endTimeBucket, 1000, 0);
applicationNode.setNumOfServiceAlarm(alarm.getItems().size());
} catch (ParseException e) {
logger.error(e.getMessage(), e);
}
nodes.add(applicationNode); nodes.add(applicationNode);
}); });
...@@ -117,7 +140,7 @@ class TopologyBuilder { ...@@ -117,7 +140,7 @@ class TopologyBuilder {
int actualTargetId = mappings.getOrDefault(target.getApplicationId(), target.getApplicationId()); int actualTargetId = mappings.getOrDefault(target.getApplicationId(), target.getApplicationId());
call.setTarget(actualTargetId); call.setTarget(actualTargetId);
call.setTargetName(applicationCacheService.getApplicationById(actualTargetId).getApplicationCode()); call.setTargetName(applicationCacheService.getApplicationById(actualTargetId).getApplicationCode());
call.setAlert(true); call.setAlert(false);
call.setCallType(components.get(referenceMetric.getTarget())); call.setCallType(components.get(referenceMetric.getTarget()));
try { try {
call.setCallsPerSec(referenceMetric.getCalls() / secondBetweenService.calculate(source.getApplicationId(), startSecondTimeBucket, endSecondTimeBucket)); call.setCallsPerSec(referenceMetric.getCalls() / secondBetweenService.calculate(source.getApplicationId(), startSecondTimeBucket, endSecondTimeBucket));
...@@ -153,7 +176,7 @@ class TopologyBuilder { ...@@ -153,7 +176,7 @@ class TopologyBuilder {
call.setSourceName(source.getApplicationCode()); call.setSourceName(source.getApplicationCode());
call.setTarget(target.getApplicationId()); call.setTarget(target.getApplicationId());
call.setTargetName(target.getApplicationCode()); call.setTargetName(target.getApplicationCode());
call.setAlert(true); call.setAlert(false);
if (source.getApplicationId() == Const.NONE_APPLICATION_ID) { if (source.getApplicationId() == Const.NONE_APPLICATION_ID) {
call.setCallType(Const.EMPTY_STRING); call.setCallType(Const.EMPTY_STRING);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册