diff --git a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/pom.xml b/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/pom.xml index 132b29e68..be146f19a 100644 --- a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/pom.xml +++ b/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/pom.xml @@ -46,6 +46,11 @@ collector-cache-define ${project.version} + + org.skywalking + collector-configuration-define + ${project.version} + org.skywalking apm-collector-stream diff --git a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/AgentStreamModuleProvider.java b/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/AgentStreamModuleProvider.java index c8c0d6e78..f1dd6d7cd 100644 --- a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/AgentStreamModuleProvider.java +++ b/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/AgentStreamModuleProvider.java @@ -40,6 +40,7 @@ import org.skywalking.apm.collector.agent.stream.worker.register.InstanceIDServi import org.skywalking.apm.collector.agent.stream.worker.register.ServiceNameService; import org.skywalking.apm.collector.agent.stream.worker.trace.TraceSegmentService; import org.skywalking.apm.collector.cache.CacheModule; +import org.skywalking.apm.collector.configuration.ConfigurationModule; import org.skywalking.apm.collector.core.module.Module; import org.skywalking.apm.collector.core.module.ModuleProvider; import org.skywalking.apm.collector.core.module.ServiceNotProvidedException; @@ -91,6 +92,6 @@ public class AgentStreamModuleProvider extends ModuleProvider { } @Override public String[] requiredModules() { - return new String[] {StorageModule.NAME, CacheModule.NAME}; + return new String[] {StorageModule.NAME, CacheModule.NAME, ConfigurationModule.NAME}; } } diff --git a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/worker/trace/application/ApplicationMetricAggregationWorker.java b/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/worker/trace/application/ApplicationMetricAggregationWorker.java index 208008917..88ac32548 100644 --- a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/worker/trace/application/ApplicationMetricAggregationWorker.java +++ b/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/worker/trace/application/ApplicationMetricAggregationWorker.java @@ -44,16 +44,22 @@ public class ApplicationMetricAggregationWorker extends AggregationWorker { - public Factory(ModuleManager moduleManager, QueueCreatorService queueCreatorService) { + public Factory(ModuleManager moduleManager, + QueueCreatorService queueCreatorService) { super(moduleManager, queueCreatorService); } diff --git a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/worker/trace/application/ApplicationReferenceMetricSpanListener.java b/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/worker/trace/application/ApplicationReferenceMetricSpanListener.java index b03ad83d7..e6944fc04 100644 --- a/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/worker/trace/application/ApplicationReferenceMetricSpanListener.java +++ b/apm-collector/apm-collector-agent-stream/collector-agent-stream-provider/src/main/java/org/skywalking/apm/collector/agent/stream/worker/trace/application/ApplicationReferenceMetricSpanListener.java @@ -28,9 +28,12 @@ import org.skywalking.apm.collector.agent.stream.parser.standardization.Referenc import org.skywalking.apm.collector.agent.stream.parser.standardization.SpanDecorator; import org.skywalking.apm.collector.cache.CacheModule; import org.skywalking.apm.collector.cache.service.InstanceCacheService; +import org.skywalking.apm.collector.configuration.ConfigurationModule; +import org.skywalking.apm.collector.configuration.service.IApdexThresholdService; import org.skywalking.apm.collector.core.graph.Graph; import org.skywalking.apm.collector.core.graph.GraphManager; import org.skywalking.apm.collector.core.module.ModuleManager; +import org.skywalking.apm.collector.core.util.ApdexThresholdUtils; import org.skywalking.apm.collector.core.util.CollectionUtils; import org.skywalking.apm.collector.core.util.Const; import org.skywalking.apm.collector.core.util.TimeBucketUtils; @@ -45,6 +48,7 @@ public class ApplicationReferenceMetricSpanListener implements EntrySpanListener private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMetricSpanListener.class); + private final IApdexThresholdService apdexThresholdService; private final InstanceCacheService instanceCacheService; private final List applicationReferenceMetrics; private final List references; @@ -53,6 +57,7 @@ public class ApplicationReferenceMetricSpanListener implements EntrySpanListener this.applicationReferenceMetrics = new LinkedList<>(); this.references = new LinkedList<>(); this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class); + this.apdexThresholdService = moduleManager.find(ConfigurationModule.NAME).getService(IApdexThresholdService.class); } @Override @@ -115,19 +120,23 @@ public class ApplicationReferenceMetricSpanListener implements EntrySpanListener private ApplicationReferenceMetric buildNodeRefSum(ApplicationReferenceMetric reference, long startTime, long endTime, boolean isError) { - long cost = endTime - startTime; - if (cost <= 1000 && !isError) { - reference.setS1Lte(1); - } else if (1000 < cost && cost <= 3000 && !isError) { - reference.setS3Lte(1); - } else if (3000 < cost && cost <= 5000 && !isError) { - reference.setS5Lte(1); - } else if (5000 < cost && !isError) { - reference.setS5Gt(1); - } else { - reference.setError(1); + long duration = endTime - startTime; + + reference.setCalls(1L); + reference.setDurationSum(duration); + if (isError) { + reference.setErrorCalls(1L); + reference.setErrorDurationSum(duration); + } + + ApdexThresholdUtils.Apdex apdex = ApdexThresholdUtils.compute(apdexThresholdService.getApplicationApdexThreshold(reference.getBehindApplicationId()), duration); + if (ApdexThresholdUtils.Apdex.Satisfied.equals(apdex)) { + reference.setSatisfiedCount(1L); + } else if (ApdexThresholdUtils.Apdex.Tolerating.equals(apdex)) { + reference.setToleratingCount(1L); + } else { + reference.setFrustratedCount(1L); } - reference.setSummary(1); return reference; } } diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/skywalking/apm/collector/configuration/service/ApdexThresholdService.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/skywalking/apm/collector/configuration/service/ApdexThresholdService.java index e7c8b5254..492e13f10 100644 --- a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/skywalking/apm/collector/configuration/service/ApdexThresholdService.java +++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/skywalking/apm/collector/configuration/service/ApdexThresholdService.java @@ -30,6 +30,6 @@ public class ApdexThresholdService implements IApdexThresholdService { * @return This value is in milli-seconds. */ @Override public Integer getApplicationApdexThreshold(int applicationId) { - return 500; + return 1000; } } \ No newline at end of file diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/util/ApdexThresholdUtils.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/util/ApdexThresholdUtils.java new file mode 100644 index 000000000..10cf6735b --- /dev/null +++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/util/ApdexThresholdUtils.java @@ -0,0 +1,39 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.core.util; + +/** + * @author peng-yongsheng + */ +public class ApdexThresholdUtils { + + public static Apdex compute(int threshold, long duration) { + if (duration <= threshold) { + return Apdex.Satisfied; + } else if (duration <= threshold * 4) { + return Apdex.Tolerating; + } else { + return Apdex.Frustrated; + } + } + + public enum Apdex { + Satisfied, Tolerating, Frustrated + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageModule.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageModule.java index ec9043b5c..1812a0b99 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageModule.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageModule.java @@ -23,6 +23,13 @@ import java.util.List; import org.skywalking.apm.collector.core.module.Module; import org.skywalking.apm.collector.storage.base.dao.IBatchDAO; import org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; import org.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; import org.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; @@ -30,22 +37,16 @@ import org.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; import org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; -import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO; import org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO; import org.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO; import org.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; import org.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; import org.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; import org.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; @@ -102,6 +103,7 @@ public class StorageModule extends Module { classes.add(IInstanceMetricPersistenceDAO.class); classes.add(IApplicationComponentPersistenceDAO.class); classes.add(IApplicationMappingPersistenceDAO.class); + classes.add(IApplicationMetricPersistenceDAO.class); classes.add(IApplicationReferenceMetricPersistenceDAO.class); classes.add(ISegmentCostPersistenceDAO.class); classes.add(ISegmentPersistenceDAO.class); diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationMetric.java index 18681b9ab..42ba15c9d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationMetric.java @@ -37,7 +37,10 @@ public class ApplicationMetric extends Data { new Column(ApplicationMetricTable.COLUMN_CALLS, new AddOperation()), new Column(ApplicationMetricTable.COLUMN_ERROR_CALLS, new AddOperation()), new Column(ApplicationMetricTable.COLUMN_DURATION_SUM, new AddOperation()), - new Column(ApplicationMetricTable.COLUMN_DURATION_AVG, new CoverOperation()), + new Column(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM, new AddOperation()), + new Column(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, new AddOperation()), + new Column(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, new AddOperation()), + new Column(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, new AddOperation()), new Column(ApplicationMetricTable.COLUMN_TIME_BUCKET, new CoverOperation()), }; private static final Column[] DOUBLE_COLUMNS = {}; @@ -84,19 +87,43 @@ public class ApplicationMetric extends Data { setDataLong(2, durationSum); } - public long getDurationAvg() { + public long getErrorDurationSum() { return getDataLong(3); } - public void setDurationAvg(long durationAvg) { - setDataLong(3, durationAvg); + public void setErrorDurationSum(long errorDurationSum) { + setDataLong(3, errorDurationSum); } - public long getTimeBucket() { + public long getSatisfiedCount() { return getDataLong(4); } + public void setSatisfiedCount(long satisfiedCount) { + setDataLong(4, satisfiedCount); + } + + public long getToleratingCount() { + return getDataLong(5); + } + + public void setToleratingCount(long toleratingCount) { + setDataLong(5, toleratingCount); + } + + public long getFrustratedCount() { + return getDataLong(6); + } + + public void setFrustratedCount(long frustratedCount) { + setDataLong(6, frustratedCount); + } + + public long getTimeBucket() { + return getDataLong(7); + } + public void setTimeBucket(long timeBucket) { - setDataLong(4, timeBucket); + setDataLong(7, timeBucket); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationMetricTable.java index 457a0412d..c27a33394 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationMetricTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationMetricTable.java @@ -29,5 +29,8 @@ public class ApplicationMetricTable extends CommonTable { public static final String COLUMN_CALLS = "calls"; public static final String COLUMN_ERROR_CALLS = "error_calls"; public static final String COLUMN_DURATION_SUM = "duration_sum"; - public static final String COLUMN_DURATION_AVG = "duration_avg"; + public static final String COLUMN_ERROR_DURATION_SUM = "error_duration_sum"; + public static final String COLUMN_SATISFIED_COUNT = "satisfied_count"; + public static final String COLUMN_TOLERATING_COUNT = "tolerating_count"; + public static final String COLUMN_FRUSTRATED_COUNT = "frustrated_count"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java index 0c3a8ab62..63db9fb14 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java @@ -33,18 +33,19 @@ public class ApplicationReferenceMetric extends Data { }; private static final Column[] LONG_COLUMNS = { + new Column(ApplicationReferenceMetricTable.COLUMN_CALLS, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, new AddOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, new AddOperation()), new Column(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, new NonOperation()), }; private static final Column[] DOUBLE_COLUMNS = {}; private static final Column[] INTEGER_COLUMNS = { new Column(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, new NonOperation()), new Column(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, new NonOperation()), - new Column(ApplicationReferenceMetricTable.COLUMN_S1_LTE, new AddOperation()), - new Column(ApplicationReferenceMetricTable.COLUMN_S3_LTE, new AddOperation()), - new Column(ApplicationReferenceMetricTable.COLUMN_S5_LTE, new AddOperation()), - new Column(ApplicationReferenceMetricTable.COLUMN_S5_GT, new AddOperation()), - new Column(ApplicationReferenceMetricTable.COLUMN_SUMMARY, new AddOperation()), - new Column(ApplicationReferenceMetricTable.COLUMN_ERROR, new AddOperation()), }; private static final Column[] BOOLEAN_COLUMNS = {}; @@ -52,20 +53,6 @@ public class ApplicationReferenceMetric extends Data { public ApplicationReferenceMetric(String id) { super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); - setS1Lte(0); - setS3Lte(0); - setS5Lte(0); - setS5Gt(0); - setError(0); - setSummary(0); - } - - public Long getTimeBucket() { - return getDataLong(0); - } - - public void setTimeBucket(Long timeBucket) { - setDataLong(0, timeBucket); } public Integer getFrontApplicationId() { @@ -84,51 +71,67 @@ public class ApplicationReferenceMetric extends Data { setDataInteger(1, behindApplicationId); } - public Integer getS1Lte() { - return getDataInteger(2); + public Long getCalls() { + return getDataLong(0); } - public void setS1Lte(Integer s1Lte) { - setDataInteger(2, s1Lte); + public void setCalls(Long calls) { + setDataLong(0, calls); } - public Integer getS3Lte() { - return getDataInteger(3); + public Long getErrorCalls() { + return getDataLong(1); } - public void setS3Lte(Integer s3Lte) { - setDataInteger(3, s3Lte); + public void setErrorCalls(Long errorCalls) { + setDataLong(1, errorCalls); } - public Integer getS5Lte() { - return getDataInteger(4); + public Long getDurationSum() { + return getDataLong(2); } - public void setS5Lte(Integer s5Lte) { - setDataInteger(4, s5Lte); + public void setDurationSum(Long durationSum) { + setDataLong(2, durationSum); } - public Integer getS5Gt() { - return getDataInteger(5); + public Long getErrorDurationSum() { + return getDataLong(3); } - public void setS5Gt(Integer s5Gt) { - setDataInteger(5, s5Gt); + public void setErrorDurationSum(Long errorDurationSum) { + setDataLong(3, errorDurationSum); } - public Integer getSummary() { - return getDataInteger(6); + public long getSatisfiedCount() { + return getDataLong(4); } - public void setSummary(Integer summary) { - setDataInteger(6, summary); + public void setSatisfiedCount(long satisfiedCount) { + setDataLong(4, satisfiedCount); } - public Integer getError() { - return getDataInteger(7); + public long getToleratingCount() { + return getDataLong(5); } - public void setError(Integer error) { - setDataInteger(7, error); + public void setToleratingCount(long toleratingCount) { + setDataLong(5, toleratingCount); + } + + public long getFrustratedCount() { + return getDataLong(6); + } + + public void setFrustratedCount(long frustratedCount) { + setDataLong(6, frustratedCount); + } + + public Long getTimeBucket() { + return getDataLong(7); + } + + public void setTimeBucket(Long timeBucket) { + setDataLong(7, timeBucket); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetricTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetricTable.java index a9a9ad1fe..5a6d029ac 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetricTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetricTable.java @@ -27,10 +27,11 @@ public class ApplicationReferenceMetricTable extends CommonTable { public static final String TABLE = "application_reference"; public static final String COLUMN_FRONT_APPLICATION_ID = "front_application_id"; public static final String COLUMN_BEHIND_APPLICATION_ID = "behind_application_id"; - public static final String COLUMN_S1_LTE = "s1_lte"; - public static final String COLUMN_S3_LTE = "s3_lte"; - public static final String COLUMN_S5_LTE = "s5_lte"; - public static final String COLUMN_S5_GT = "s5_gt"; - public static final String COLUMN_SUMMARY = "summary"; - public static final String COLUMN_ERROR = "error"; + public static final String COLUMN_CALLS = "calls"; + public static final String COLUMN_ERROR_CALLS = "error_calls"; + public static final String COLUMN_DURATION_SUM = "duration_sum"; + public static final String COLUMN_ERROR_DURATION_SUM = "error_duration_sum"; + public static final String COLUMN_SATISFIED_COUNT = "satisfied_count"; + public static final String COLUMN_TOLERATING_COUNT = "tolerating_count"; + public static final String COLUMN_FRUSTRATED_COUNT = "frustrated_count"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java index 15123d036..203e41dcd 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java @@ -32,6 +32,13 @@ import org.skywalking.apm.collector.storage.StorageException; import org.skywalking.apm.collector.storage.StorageModule; import org.skywalking.apm.collector.storage.base.dao.IBatchDAO; import org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; import org.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; import org.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; @@ -39,22 +46,16 @@ import org.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; import org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; -import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO; import org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO; import org.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO; import org.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; import org.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; import org.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; import org.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; @@ -67,30 +68,31 @@ import org.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersisten import org.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; import org.skywalking.apm.collector.storage.es.base.dao.BatchEsDAO; import org.skywalking.apm.collector.storage.es.base.define.ElasticSearchStorageInstaller; +import org.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsPersistenceDAO; +import org.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsUIDAO; import org.skywalking.apm.collector.storage.es.dao.ApplicationEsCacheDAO; import org.skywalking.apm.collector.storage.es.dao.ApplicationEsRegisterDAO; +import org.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsPersistenceDAO; +import org.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsUIDAO; +import org.skywalking.apm.collector.storage.es.dao.ApplicationMetricEsPersistenceDAO; +import org.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsPersistenceDAO; +import org.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsUIDAO; import org.skywalking.apm.collector.storage.es.dao.CpuMetricEsPersistenceDAO; import org.skywalking.apm.collector.storage.es.dao.CpuMetricEsUIDAO; import org.skywalking.apm.collector.storage.es.dao.GCMetricEsPersistenceDAO; import org.skywalking.apm.collector.storage.es.dao.GCMetricEsUIDAO; import org.skywalking.apm.collector.storage.es.dao.GlobalTraceEsPersistenceDAO; import org.skywalking.apm.collector.storage.es.dao.GlobalTraceEsUIDAO; -import org.skywalking.apm.collector.storage.es.dao.InstanceMetricEsPersistenceDAO; import org.skywalking.apm.collector.storage.es.dao.InstPerformanceEsUIDAO; import org.skywalking.apm.collector.storage.es.dao.InstanceEsCacheDAO; import org.skywalking.apm.collector.storage.es.dao.InstanceEsRegisterDAO; import org.skywalking.apm.collector.storage.es.dao.InstanceEsUIDAO; import org.skywalking.apm.collector.storage.es.dao.InstanceHeartBeatEsPersistenceDAO; +import org.skywalking.apm.collector.storage.es.dao.InstanceMetricEsPersistenceDAO; import org.skywalking.apm.collector.storage.es.dao.MemoryMetricEsPersistenceDAO; import org.skywalking.apm.collector.storage.es.dao.MemoryMetricEsUIDAO; import org.skywalking.apm.collector.storage.es.dao.MemoryPoolMetricEsPersistenceDAO; import org.skywalking.apm.collector.storage.es.dao.MemoryPoolMetricEsUIDAO; -import org.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsPersistenceDAO; -import org.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsUIDAO; -import org.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsPersistenceDAO; -import org.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsUIDAO; -import org.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsPersistenceDAO; -import org.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsUIDAO; import org.skywalking.apm.collector.storage.es.dao.SegmentCostEsPersistenceDAO; import org.skywalking.apm.collector.storage.es.dao.SegmentCostEsUIDAO; import org.skywalking.apm.collector.storage.es.dao.SegmentEsPersistenceDAO; @@ -197,6 +199,7 @@ public class StorageModuleEsProvider extends ModuleProvider { this.registerServiceImplementation(IInstanceMetricPersistenceDAO.class, new InstanceMetricEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IApplicationComponentPersistenceDAO.class, new ApplicationComponentEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IApplicationMappingPersistenceDAO.class, new ApplicationMappingEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationMetricPersistenceDAO.class, new ApplicationMetricEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IApplicationReferenceMetricPersistenceDAO.class, new ApplicationReferenceMetricEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentEsPersistenceDAO(elasticSearchClient)); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationMetricEsPersistenceDAO.java index dbc0c78d5..2552e112a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationMetricEsPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationMetricEsPersistenceDAO.java @@ -54,7 +54,10 @@ public class ApplicationMetricEsPersistenceDAO extends EsDAO implements IApplica applicationMetric.setCalls(((Number)source.get(ApplicationMetricTable.COLUMN_CALLS)).longValue()); applicationMetric.setErrorCalls(((Number)source.get(ApplicationMetricTable.COLUMN_ERROR_CALLS)).longValue()); applicationMetric.setDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_DURATION_SUM)).longValue()); - applicationMetric.setDurationAvg(((Number)source.get(ApplicationMetricTable.COLUMN_DURATION_AVG)).longValue()); + applicationMetric.setErrorDurationSum(((Number)source.get(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM)).longValue()); + applicationMetric.setSatisfiedCount(((Number)source.get(ApplicationMetricTable.COLUMN_SATISFIED_COUNT)).longValue()); + applicationMetric.setToleratingCount(((Number)source.get(ApplicationMetricTable.COLUMN_TOLERATING_COUNT)).longValue()); + applicationMetric.setFrustratedCount(((Number)source.get(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT)).longValue()); applicationMetric.setTimeBucket(((Number)source.get(ApplicationMetricTable.COLUMN_TIME_BUCKET)).longValue()); return applicationMetric; } else { @@ -68,7 +71,10 @@ public class ApplicationMetricEsPersistenceDAO extends EsDAO implements IApplica source.put(ApplicationMetricTable.COLUMN_CALLS, data.getCalls()); source.put(ApplicationMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls()); source.put(ApplicationMetricTable.COLUMN_DURATION_SUM, data.getDurationSum()); - source.put(ApplicationMetricTable.COLUMN_DURATION_AVG, data.getDurationAvg()); + source.put(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum()); + source.put(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); + source.put(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); + source.put(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); source.put(ApplicationMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); return getClient().prepareIndex(ApplicationMetricTable.TABLE, data.getId()).setSource(source); @@ -80,8 +86,10 @@ public class ApplicationMetricEsPersistenceDAO extends EsDAO implements IApplica source.put(ApplicationMetricTable.COLUMN_CALLS, data.getCalls()); source.put(ApplicationMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls()); source.put(ApplicationMetricTable.COLUMN_DURATION_SUM, data.getDurationSum()); - source.put(ApplicationMetricTable.COLUMN_DURATION_AVG, data.getDurationAvg()); - source.put(ApplicationMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + source.put(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum()); + source.put(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); + source.put(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); + source.put(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); return getClient().prepareUpdate(ApplicationMetricTable.TABLE, data.getId()).setDoc(source); } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsPersistenceDAO.java index e7c107f5c..5234eef10 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsPersistenceDAO.java @@ -52,12 +52,13 @@ public class ApplicationReferenceMetricEsPersistenceDAO extends EsDAO implements Map source = getResponse.getSource(); applicationReferenceMetric.setFrontApplicationId(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)).intValue()); applicationReferenceMetric.setBehindApplicationId(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)).intValue()); - applicationReferenceMetric.setS1Lte(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_S1_LTE)).intValue()); - applicationReferenceMetric.setS3Lte(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_S3_LTE)).intValue()); - applicationReferenceMetric.setS5Lte(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_S5_LTE)).intValue()); - applicationReferenceMetric.setS5Gt(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_S5_GT)).intValue()); - applicationReferenceMetric.setSummary(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_SUMMARY)).intValue()); - applicationReferenceMetric.setError(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_ERROR)).intValue()); + applicationReferenceMetric.setCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_CALLS)).longValue()); + applicationReferenceMetric.setErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS)).longValue()); + applicationReferenceMetric.setDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM)).longValue()); + applicationReferenceMetric.setErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM)).longValue()); + applicationReferenceMetric.setSatisfiedCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT)).longValue()); + applicationReferenceMetric.setToleratingCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT)).longValue()); + applicationReferenceMetric.setFrustratedCount(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT)).longValue()); applicationReferenceMetric.setTimeBucket(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET)).longValue()); return applicationReferenceMetric; } else { @@ -69,12 +70,13 @@ public class ApplicationReferenceMetricEsPersistenceDAO extends EsDAO implements Map source = new HashMap<>(); source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); - source.put(ApplicationReferenceMetricTable.COLUMN_S1_LTE, data.getS1Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S3_LTE, data.getS3Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S5_LTE, data.getS5Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S5_GT, data.getS5Gt()); - source.put(ApplicationReferenceMetricTable.COLUMN_SUMMARY, data.getSummary()); - source.put(ApplicationReferenceMetricTable.COLUMN_ERROR, data.getError()); + source.put(ApplicationReferenceMetricTable.COLUMN_CALLS, data.getCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); return getClient().prepareIndex(ApplicationReferenceMetricTable.TABLE, data.getId()).setSource(source); @@ -84,12 +86,13 @@ public class ApplicationReferenceMetricEsPersistenceDAO extends EsDAO implements Map source = new HashMap<>(); source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); - source.put(ApplicationReferenceMetricTable.COLUMN_S1_LTE, data.getS1Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S3_LTE, data.getS3Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S5_LTE, data.getS5Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S5_GT, data.getS5Gt()); - source.put(ApplicationReferenceMetricTable.COLUMN_SUMMARY, data.getSummary()); - source.put(ApplicationReferenceMetricTable.COLUMN_ERROR, data.getError()); + source.put(ApplicationReferenceMetricTable.COLUMN_CALLS, data.getCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); return getClient().prepareUpdate(ApplicationReferenceMetricTable.TABLE, data.getId()).setDoc(source); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java index d29f68ddd..f38945933 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java @@ -19,17 +19,13 @@ package org.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; -import org.elasticsearch.search.aggregations.metrics.sum.Sum; import org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.skywalking.apm.collector.core.util.ColumnNameUtils; import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; import org.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; @@ -55,48 +51,48 @@ public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplica searchRequestBuilder.setSize(0); TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).size(100); - aggregationBuilder.subAggregation(AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).size(100) - .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S1_LTE).field(ApplicationReferenceMetricTable.COLUMN_S1_LTE)) - .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S3_LTE).field(ApplicationReferenceMetricTable.COLUMN_S3_LTE)) - .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_LTE).field(ApplicationReferenceMetricTable.COLUMN_S5_LTE)) - .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_GT).field(ApplicationReferenceMetricTable.COLUMN_S5_GT)) - .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_SUMMARY).field(ApplicationReferenceMetricTable.COLUMN_SUMMARY)) - .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_ERROR).field(ApplicationReferenceMetricTable.COLUMN_ERROR))); +// aggregationBuilder.subAggregation(AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).size(100) +// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S1_LTE).field(ApplicationReferenceMetricTable.COLUMN_S1_LTE)) +// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S3_LTE).field(ApplicationReferenceMetricTable.COLUMN_S3_LTE)) +// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_LTE).field(ApplicationReferenceMetricTable.COLUMN_S5_LTE)) +// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_GT).field(ApplicationReferenceMetricTable.COLUMN_S5_GT)) +// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_SUMMARY).field(ApplicationReferenceMetricTable.COLUMN_SUMMARY)) +// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_ERROR).field(ApplicationReferenceMetricTable.COLUMN_ERROR))); searchRequestBuilder.addAggregation(aggregationBuilder); SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); JsonArray nodeRefResSumArray = new JsonArray(); - Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID); - for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) { - int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue(); - Terms behindApplicationIdTerms = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); - for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) { - int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue(); - - if (behindApplicationId != 0) { - Sum s1LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S1_LTE); - Sum s3LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S3_LTE); - Sum s5LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_LTE); - Sum s5GT = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_GT); - Sum summary = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_SUMMARY); - Sum error = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_ERROR); - logger.debug("frontApplicationId: {}, behindApplicationId: {}, s1LTE: {}, s3LTE: {}, s5LTE: {}, s5GT: {}, error: {}, summary: {}", frontApplicationId, - behindApplicationId, s1LTE.getValue(), s3LTE.getValue(), s5LTE.getValue(), s5GT.getValue(), error.getValue(), summary.getValue()); - - JsonObject nodeRefResSumObj = new JsonObject(); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), s1LTE.getValue()); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), s3LTE.getValue()); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), s5LTE.getValue()); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), s5GT.getValue()); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), error.getValue()); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), summary.getValue()); - nodeRefResSumArray.add(nodeRefResSumObj); - } - } - } +// Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID); +// for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) { +// int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue(); +// Terms behindApplicationIdTerms = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); +// for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) { +// int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue(); +// +// if (behindApplicationId != 0) { +// Sum s1LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S1_LTE); +// Sum s3LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S3_LTE); +// Sum s5LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_LTE); +// Sum s5GT = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_GT); +// Sum summary = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_SUMMARY); +// Sum error = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_ERROR); +// logger.debug("frontApplicationId: {}, behindApplicationId: {}, s1LTE: {}, s3LTE: {}, s5LTE: {}, s5GT: {}, error: {}, summary: {}", frontApplicationId, +// behindApplicationId, s1LTE.getValue(), s3LTE.getValue(), s5LTE.getValue(), s5GT.getValue(), error.getValue(), summary.getValue()); +// +// JsonObject nodeRefResSumObj = new JsonObject(); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), s1LTE.getValue()); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), s3LTE.getValue()); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), s5LTE.getValue()); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), s5GT.getValue()); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), error.getValue()); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), summary.getValue()); +// nodeRefResSumArray.add(nodeRefResSumObj); +// } +// } +// } return nodeRefResSumArray; } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/NodeReferenceEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ApplicationReferenceMetricEsTableDefine.java similarity index 72% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/NodeReferenceEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ApplicationReferenceMetricEsTableDefine.java index 019589a57..7b3ed1043 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/NodeReferenceEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ApplicationReferenceMetricEsTableDefine.java @@ -25,9 +25,9 @@ import org.skywalking.apm.collector.storage.table.application.ApplicationReferen /** * @author peng-yongsheng */ -public class NodeReferenceEsTableDefine extends ElasticSearchTableDefine { +public class ApplicationReferenceMetricEsTableDefine extends ElasticSearchTableDefine { - public NodeReferenceEsTableDefine() { + public ApplicationReferenceMetricEsTableDefine() { super(ApplicationReferenceMetricTable.TABLE); } @@ -38,12 +38,13 @@ public class NodeReferenceEsTableDefine extends ElasticSearchTableDefine { @Override public void initialize() { addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_S1_LTE, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_S3_LTE, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_S5_LTE, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_S5_GT, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_SUMMARY, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_CALLS, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, ElasticSearchColumnDefine.Type.Long.name())); addColumn(new ElasticSearchColumnDefine(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java index 036d71c4e..5aa96bf7e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java @@ -27,6 +27,13 @@ import org.skywalking.apm.collector.storage.StorageException; import org.skywalking.apm.collector.storage.StorageModule; import org.skywalking.apm.collector.storage.base.dao.IBatchDAO; import org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; import org.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; import org.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; @@ -34,22 +41,16 @@ import org.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; import org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; -import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO; import org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO; import org.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; +import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO; import org.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO; import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; -import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; import org.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; import org.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; import org.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; @@ -62,30 +63,31 @@ import org.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersisten import org.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; import org.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO; import org.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller; +import org.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2PersistenceDAO; +import org.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2UIDAO; import org.skywalking.apm.collector.storage.h2.dao.ApplicationH2CacheDAO; import org.skywalking.apm.collector.storage.h2.dao.ApplicationH2RegisterDAO; +import org.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2PersistenceDAO; +import org.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2UIDAO; +import org.skywalking.apm.collector.storage.h2.dao.ApplicationMetricH2PersistenceDAO; +import org.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2PersistenceDAO; +import org.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2UIDAO; import org.skywalking.apm.collector.storage.h2.dao.CpuMetricH2PersistenceDAO; import org.skywalking.apm.collector.storage.h2.dao.CpuMetricH2UIDAO; import org.skywalking.apm.collector.storage.h2.dao.GCMetricH2PersistenceDAO; import org.skywalking.apm.collector.storage.h2.dao.GCMetricH2UIDAO; import org.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2PersistenceDAO; import org.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2UIDAO; -import org.skywalking.apm.collector.storage.h2.dao.InstanceMetricH2PersistenceDAO; import org.skywalking.apm.collector.storage.h2.dao.InstPerformanceH2UIDAO; import org.skywalking.apm.collector.storage.h2.dao.InstanceH2CacheDAO; import org.skywalking.apm.collector.storage.h2.dao.InstanceH2RegisterDAO; import org.skywalking.apm.collector.storage.h2.dao.InstanceH2UIDAO; import org.skywalking.apm.collector.storage.h2.dao.InstanceHeartBeatH2PersistenceDAO; +import org.skywalking.apm.collector.storage.h2.dao.InstanceMetricH2PersistenceDAO; import org.skywalking.apm.collector.storage.h2.dao.MemoryMetricH2PersistenceDAO; import org.skywalking.apm.collector.storage.h2.dao.MemoryMetricH2UIDAO; import org.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2PersistenceDAO; import org.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2UIDAO; -import org.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2PersistenceDAO; -import org.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2UIDAO; -import org.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2PersistenceDAO; -import org.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2UIDAO; -import org.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2PersistenceDAO; -import org.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2UIDAO; import org.skywalking.apm.collector.storage.h2.dao.SegmentCostH2PersistenceDAO; import org.skywalking.apm.collector.storage.h2.dao.SegmentCostH2UIDAO; import org.skywalking.apm.collector.storage.h2.dao.SegmentH2PersistenceDAO; @@ -174,6 +176,7 @@ public class StorageModuleH2Provider extends ModuleProvider { this.registerServiceImplementation(IInstanceMetricPersistenceDAO.class, new InstanceMetricH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IApplicationComponentPersistenceDAO.class, new ApplicationComponentH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IApplicationMappingPersistenceDAO.class, new ApplicationMappingH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationMetricPersistenceDAO.class, new ApplicationMetricH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IApplicationReferenceMetricPersistenceDAO.class, new ApplicationReferenceMetricH2PersistenceDAO(h2Client)); this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostH2PersistenceDAO(h2Client)); this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentH2PersistenceDAO(h2Client)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationMetricH2PersistenceDAO.java new file mode 100644 index 000000000..95e1153fd --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationMetricH2PersistenceDAO.java @@ -0,0 +1,116 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.h2.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.skywalking.apm.collector.client.h2.H2Client; +import org.skywalking.apm.collector.client.h2.H2ClientException; +import org.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; +import org.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.skywalking.apm.collector.storage.table.application.ApplicationMetric; +import org.skywalking.apm.collector.storage.table.application.ApplicationMetricTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class ApplicationMetricH2PersistenceDAO extends H2DAO implements IApplicationMetricPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationMetricH2PersistenceDAO.class); + private static final String GET_SQL = "select * from {0} where {1} = ?"; + + public ApplicationMetricH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override public ApplicationMetric get(String id) { + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_SQL, ApplicationMetricTable.TABLE, ApplicationMetricTable.COLUMN_ID); + Object[] params = new Object[] {id}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + ApplicationMetric applicationMetric = new ApplicationMetric(id); + applicationMetric.setApplicationId(rs.getInt(ApplicationMetricTable.COLUMN_APPLICATION_ID)); + applicationMetric.setCalls(rs.getLong(ApplicationMetricTable.COLUMN_CALLS)); + applicationMetric.setErrorCalls(rs.getLong(ApplicationMetricTable.COLUMN_ERROR_CALLS)); + applicationMetric.setDurationSum(rs.getLong(ApplicationMetricTable.COLUMN_DURATION_SUM)); + applicationMetric.setErrorDurationSum(rs.getLong(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM)); + applicationMetric.setSatisfiedCount(rs.getLong(ApplicationMetricTable.COLUMN_SATISFIED_COUNT)); + applicationMetric.setToleratingCount(rs.getLong(ApplicationMetricTable.COLUMN_TOLERATING_COUNT)); + applicationMetric.setFrustratedCount(rs.getLong(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT)); + applicationMetric.setTimeBucket(rs.getLong(ApplicationMetricTable.COLUMN_TIME_BUCKET)); + return applicationMetric; + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(ApplicationMetric data) { + Map source = new HashMap<>(); + H2SqlEntity entity = new H2SqlEntity(); + source.put(ApplicationMetricTable.COLUMN_ID, data.getId()); + source.put(ApplicationMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(ApplicationMetricTable.COLUMN_CALLS, data.getCalls()); + source.put(ApplicationMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls()); + source.put(ApplicationMetricTable.COLUMN_DURATION_SUM, data.getDurationSum()); + source.put(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum()); + source.put(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); + source.put(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); + source.put(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); + source.put(ApplicationMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + String sql = SqlBuilder.buildBatchInsertSql(ApplicationMetricTable.TABLE, source.keySet()); + entity.setSql(sql); + + entity.setParams(source.values().toArray(new Object[0])); + return entity; + } + + @Override public H2SqlEntity prepareBatchUpdate(ApplicationMetric data) { + Map source = new HashMap<>(); + H2SqlEntity entity = new H2SqlEntity(); + source.put(ApplicationMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(ApplicationMetricTable.COLUMN_CALLS, data.getCalls()); + source.put(ApplicationMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls()); + source.put(ApplicationMetricTable.COLUMN_DURATION_SUM, data.getDurationSum()); + source.put(ApplicationMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum()); + source.put(ApplicationMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); + source.put(ApplicationMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); + source.put(ApplicationMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); + source.put(ApplicationMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + String sql = SqlBuilder.buildBatchUpdateSql(ApplicationMetricTable.TABLE, source.keySet(), ApplicationMetricTable.COLUMN_ID); + entity.setSql(sql); + List values = new ArrayList<>(source.values()); + values.add(data.getId()); + entity.setParams(values.toArray(new Object[0])); + return entity; + } + + @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2PersistenceDAO.java index 342c518f3..12c5fd738 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2PersistenceDAO.java @@ -56,12 +56,13 @@ public class ApplicationReferenceMetricH2PersistenceDAO extends H2DAO implements ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(id); applicationReferenceMetric.setFrontApplicationId(rs.getInt(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)); applicationReferenceMetric.setBehindApplicationId(rs.getInt(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)); - applicationReferenceMetric.setS1Lte(rs.getInt(ApplicationReferenceMetricTable.COLUMN_S1_LTE)); - applicationReferenceMetric.setS3Lte(rs.getInt(ApplicationReferenceMetricTable.COLUMN_S3_LTE)); - applicationReferenceMetric.setS5Lte(rs.getInt(ApplicationReferenceMetricTable.COLUMN_S5_LTE)); - applicationReferenceMetric.setS5Gt(rs.getInt(ApplicationReferenceMetricTable.COLUMN_S5_GT)); - applicationReferenceMetric.setSummary(rs.getInt(ApplicationReferenceMetricTable.COLUMN_SUMMARY)); - applicationReferenceMetric.setError(rs.getInt(ApplicationReferenceMetricTable.COLUMN_ERROR)); + applicationReferenceMetric.setCalls(rs.getLong(ApplicationReferenceMetricTable.COLUMN_CALLS)); + applicationReferenceMetric.setErrorCalls(rs.getLong(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS)); + applicationReferenceMetric.setDurationSum(rs.getLong(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM)); + applicationReferenceMetric.setErrorDurationSum(rs.getLong(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM)); + applicationReferenceMetric.setSatisfiedCount(rs.getLong(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT)); + applicationReferenceMetric.setToleratingCount(rs.getLong(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT)); + applicationReferenceMetric.setFrustratedCount(rs.getLong(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT)); applicationReferenceMetric.setTimeBucket(rs.getLong(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET)); return applicationReferenceMetric; } @@ -77,12 +78,13 @@ public class ApplicationReferenceMetricH2PersistenceDAO extends H2DAO implements source.put(ApplicationReferenceMetricTable.COLUMN_ID, data.getId()); source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); - source.put(ApplicationReferenceMetricTable.COLUMN_S1_LTE, data.getS1Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S3_LTE, data.getS3Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S5_LTE, data.getS5Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S5_GT, data.getS5Gt()); - source.put(ApplicationReferenceMetricTable.COLUMN_SUMMARY, data.getSummary()); - source.put(ApplicationReferenceMetricTable.COLUMN_ERROR, data.getError()); + source.put(ApplicationReferenceMetricTable.COLUMN_CALLS, data.getCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); String sql = SqlBuilder.buildBatchInsertSql(ApplicationReferenceMetricTable.TABLE, source.keySet()); entity.setSql(sql); @@ -96,12 +98,13 @@ public class ApplicationReferenceMetricH2PersistenceDAO extends H2DAO implements H2SqlEntity entity = new H2SqlEntity(); source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, data.getFrontApplicationId()); source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, data.getBehindApplicationId()); - source.put(ApplicationReferenceMetricTable.COLUMN_S1_LTE, data.getS1Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S3_LTE, data.getS3Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S5_LTE, data.getS5Lte()); - source.put(ApplicationReferenceMetricTable.COLUMN_S5_GT, data.getS5Gt()); - source.put(ApplicationReferenceMetricTable.COLUMN_SUMMARY, data.getSummary()); - source.put(ApplicationReferenceMetricTable.COLUMN_ERROR, data.getError()); + source.put(ApplicationReferenceMetricTable.COLUMN_CALLS, data.getCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, data.getSatisfiedCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, data.getToleratingCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, data.getFrustratedCount()); source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); String sql = SqlBuilder.buildBatchUpdateSql(ApplicationReferenceMetricTable.TABLE, source.keySet(), ApplicationReferenceMetricTable.COLUMN_ID); entity.setSql(sql); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java index dbe7f9427..de8f4aa1e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java @@ -48,31 +48,31 @@ public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplica @Override public JsonArray load(long startTime, long endTime) { H2Client client = getClient(); JsonArray nodeRefResSumArray = new JsonArray(); - String sql = SqlBuilder.buildSql(NODE_REFERENCE_SQL, ApplicationReferenceMetricTable.COLUMN_S1_LTE, - ApplicationReferenceMetricTable.COLUMN_S3_LTE, ApplicationReferenceMetricTable.COLUMN_S5_LTE, - ApplicationReferenceMetricTable.COLUMN_S5_GT, ApplicationReferenceMetricTable.COLUMN_SUMMARY, - ApplicationReferenceMetricTable.COLUMN_ERROR, ApplicationReferenceMetricTable.TABLE, ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, - ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); - - Object[] params = new Object[] {startTime, endTime}; - try (ResultSet rs = client.executeQuery(sql, params)) { - while (rs.next()) { - int frontApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID); - int behindApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); - JsonObject nodeRefResSumObj = new JsonObject(); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S1_LTE)); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S3_LTE)); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_LTE)); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_GT)); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_ERROR)); - nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_SUMMARY)); - nodeRefResSumArray.add(nodeRefResSumObj); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } +// String sql = SqlBuilder.buildSql(NODE_REFERENCE_SQL, ApplicationReferenceMetricTable.COLUMN_S1_LTE, +// ApplicationReferenceMetricTable.COLUMN_S3_LTE, ApplicationReferenceMetricTable.COLUMN_S5_LTE, +// ApplicationReferenceMetricTable.COLUMN_S5_GT, ApplicationReferenceMetricTable.COLUMN_SUMMARY, +// ApplicationReferenceMetricTable.COLUMN_ERROR, ApplicationReferenceMetricTable.TABLE, ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, +// ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); +// +// Object[] params = new Object[] {startTime, endTime}; +// try (ResultSet rs = client.executeQuery(sql, params)) { +// while (rs.next()) { +// int frontApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID); +// int behindApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); +// JsonObject nodeRefResSumObj = new JsonObject(); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S1_LTE)); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S3_LTE)); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_LTE)); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_GT)); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_ERROR)); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_SUMMARY)); +// nodeRefResSumArray.add(nodeRefResSumObj); +// } +// } catch (SQLException | H2ClientException e) { +// logger.error(e.getMessage(), e); +// } return nodeRefResSumArray; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/NodeReferenceH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/ApplicationReferenceMetricH2TableDefine.java similarity index 75% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/NodeReferenceH2TableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/ApplicationReferenceMetricH2TableDefine.java index 15f6b5204..5924e03e4 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/NodeReferenceH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/ApplicationReferenceMetricH2TableDefine.java @@ -25,9 +25,9 @@ import org.skywalking.apm.collector.storage.table.application.ApplicationReferen /** * @author peng-yongsheng */ -public class NodeReferenceH2TableDefine extends H2TableDefine { +public class ApplicationReferenceMetricH2TableDefine extends H2TableDefine { - public NodeReferenceH2TableDefine() { + public ApplicationReferenceMetricH2TableDefine() { super(ApplicationReferenceMetricTable.TABLE); } @@ -35,12 +35,13 @@ public class NodeReferenceH2TableDefine extends H2TableDefine { addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_S1_LTE, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_S3_LTE, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_S5_LTE, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_S5_GT, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_SUMMARY, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_CALLS, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR_CALLS, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_DURATION_SUM, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_ERROR_DURATION_SUM, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, H2ColumnDefine.Type.Bigint.name())); addColumn(new H2ColumnDefine(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); } } diff --git a/apm-collector/apm-collector-stream/src/main/java/org/skywalking/apm/collector/stream/worker/impl/PersistenceWorker.java b/apm-collector/apm-collector-stream/src/main/java/org/skywalking/apm/collector/stream/worker/impl/PersistenceWorker.java index 33248e73c..e6116c8aa 100644 --- a/apm-collector/apm-collector-stream/src/main/java/org/skywalking/apm/collector/stream/worker/impl/PersistenceWorker.java +++ b/apm-collector/apm-collector-stream/src/main/java/org/skywalking/apm/collector/stream/worker/impl/PersistenceWorker.java @@ -40,12 +40,12 @@ public abstract class PersistenceWorker private final Logger logger = LoggerFactory.getLogger(PersistenceWorker.class); - private final DataCache dataCache; + private final DataCache dataCache; private final IBatchDAO batchDAO; public PersistenceWorker(ModuleManager moduleManager) { super(moduleManager); - this.dataCache = new DataCache(); + this.dataCache = new DataCache<>(); this.batchDAO = moduleManager.find(StorageModule.NAME).getService(IBatchDAO.class); } @@ -95,7 +95,7 @@ public abstract class PersistenceWorker return batchCollection; } - protected final List prepareBatch(Map dataMap) { + protected final List prepareBatch(Map dataMap) { List insertBatchCollection = new LinkedList<>(); List updateBatchCollection = new LinkedList<>(); dataMap.forEach((id, data) -> { @@ -130,7 +130,7 @@ public abstract class PersistenceWorker private void aggregate(Object message) { dataCache.writing(); - Data newData = (Data)message; + OUTPUT newData = (OUTPUT)message; if (dataCache.containsKey(newData.getId())) { dataCache.get(newData.getId()).mergeData(newData); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java index c7e647729..c500b9adc 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java @@ -70,7 +70,7 @@ public class TraceDagDataBuilder { JsonObject lineJsonObj = new JsonObject(); lineJsonObj.addProperty("from", findOrCreateNode(front)); lineJsonObj.addProperty("to", findOrCreateNode(behind)); - lineJsonObj.addProperty("resSum", nodeRefJsonObj.get(ApplicationReferenceMetricTable.COLUMN_SUMMARY).getAsInt()); + lineJsonObj.addProperty("resSum", nodeRefJsonObj.get(ApplicationReferenceMetricTable.COLUMN_CALLS).getAsInt()); lineArray.add(lineJsonObj); logger.debug("line: {}", lineJsonObj);