From da89ea4d7714c41195e7079291479f3bb6c5913d Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sun, 7 Jan 2018 19:18:22 +0800 Subject: [PATCH] Application reference metric pyramid aggregate. --- .../ApplicationReferenceMetricAlarmGraph.java | 2 +- .../define/graph/MetricWorkerIdDefine.java | 12 +- .../AnalysisMetricModuleProvider.java | 2 +- .../application/ApplicationMetricGraph.java | 2 +- ...nReferenceDayMetricPersistenceWorker.java} | 18 +-- ...cationReferenceDayMetricTransformNode.java | 45 ++++++ ...nReferenceHourMetricPersistenceWorker.java | 67 ++++++++ ...ationReferenceHourMetricTransformNode.java | 45 ++++++ ...ationReferenceMetricAggregationWorker.java | 14 +- .../ApplicationReferenceMetricGraph.java | 20 ++- ...pplicationReferenceMetricRemoteWorker.java | 4 +- ...eferenceMinuteMetricPersistenceWorker.java | 67 ++++++++ ...ReferenceMonthMetricPersistenceWorker.java | 67 ++++++++ ...tionReferenceMonthMetricTransformNode.java | 45 ++++++ .../apm/collector/storage/StorageModule.java | 4 +- ...tionReferenceDayMetricPersistenceDAO.java} | 4 +- ...tionReferenceHourMetricPersistenceDAO.java | 28 ++++ ...onReferenceMinuteMetricPersistenceDAO.java | 28 ++++ ...ionReferenceMonthMetricPersistenceDAO.java | 28 ++++ .../ApplicationReferenceMetric.java | 25 ++- .../storage/es/DataTTLKeeperTimer.java | 3 +- .../storage/es/StorageModuleEsProvider.java | 6 +- ...cationReferenceMetricEsPersistenceDAO.java | 151 ------------------ ...cationReferenceMetricEsPersistenceDAO.java | 105 ++++++++++++ ...ionReferenceDayMetricEsPersistenceDAO.java | 42 +++++ ...onReferenceHourMetricEsPersistenceDAO.java | 42 +++++ ...ReferenceMinuteMetricEsPersistenceDAO.java | 42 +++++ ...nReferenceMonthMetricEsPersistenceDAO.java | 42 +++++ .../storage/h2/StorageModuleH2Provider.java | 6 +- ...eferenceMinuteMetricH2PersistenceDAO.java} | 8 +- 30 files changed, 778 insertions(+), 196 deletions(-) rename apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/{ApplicationReferenceMetricPersistenceWorker.java => refmetric/ApplicationReferenceDayMetricPersistenceWorker.java} (73%) create mode 100644 apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricTransformNode.java create mode 100644 apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricPersistenceWorker.java create mode 100644 apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricTransformNode.java rename apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/{ => refmetric}/ApplicationReferenceMetricAggregationWorker.java (94%) rename apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/{ => refmetric}/ApplicationReferenceMetricGraph.java (75%) rename apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/{ => refmetric}/ApplicationReferenceMetricRemoteWorker.java (95%) create mode 100644 apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricPersistenceWorker.java create mode 100644 apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricPersistenceWorker.java create mode 100644 apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricTransformNode.java rename apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/{IApplicationReferenceMetricPersistenceDAO.java => armp/IApplicationReferenceDayMetricPersistenceDAO.java} (80%) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceHourMetricPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMinuteMetricPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMonthMetricPersistenceDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/AbstractApplicationReferenceMetricEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceDayMetricEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceHourMetricEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMinuteMetricEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMonthMetricEsPersistenceDAO.java rename apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/{ApplicationReferenceMetricH2PersistenceDAO.java => ApplicationReferenceMinuteMetricH2PersistenceDAO.java} (96%) diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmGraph.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmGraph.java index 374b10222..121aed10a 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationReferenceMetricAlarmGraph.java @@ -65,7 +65,7 @@ public class ApplicationReferenceMetricAlarmGraph { private void link(Graph graph) { GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.APPLICATION_REFERENCE_METRIC_GRAPH_ID, ApplicationReferenceMetric.class) - .toFinder().findNode(MetricWorkerIdDefine.APPLICATION_REFERENCE_METRIC_PERSISTENCE_WORKER_ID, ApplicationReferenceMetric.class) + .toFinder().findNode(MetricWorkerIdDefine.APPLICATION_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID, ApplicationReferenceMetric.class) .addNext(new NodeProcessor() { @Override public int id() { return AlarmWorkerIdDefine.APPLICATION_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID; diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java index b63eaa153..fe747eef6 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java @@ -42,9 +42,15 @@ public class MetricWorkerIdDefine { public static final int INSTANCE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4207; public static final int INSTANCE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4208; - public static final int APPLICATION_REFERENCE_METRIC_AGGREGATION_WORKER_ID = 406; - public static final int APPLICATION_REFERENCE_METRIC_REMOTE_WORKER_ID = 407; - public static final int APPLICATION_REFERENCE_METRIC_PERSISTENCE_WORKER_ID = 408; + public static final int APPLICATION_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4300; + public static final int APPLICATION_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID = 4301; + public static final int APPLICATION_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4302; + public static final int APPLICATION_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4303; + public static final int APPLICATION_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID = 4304; + public static final int APPLICATION_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4305; + public static final int APPLICATION_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID = 4306; + public static final int APPLICATION_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4307; + public static final int APPLICATION_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4308; public static final int SERVICE_METRIC_AGGREGATION_WORKER_ID = 409; public static final int SERVICE_METRIC_REMOTE_WORKER_ID = 410; diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java index fd457336e..d221afd32 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java @@ -25,7 +25,7 @@ import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.appli import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.ApplicationMappingGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.ApplicationMappingSpanListener; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.ApplicationMetricGraph; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.ApplicationReferenceMetricGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric.ApplicationReferenceMetricGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.GlobalTraceGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.GlobalTraceSpanListener; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.InstanceMappingGraph; diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricGraph.java index c6b91ed91..e0a8462bd 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationMetricGraph.java @@ -57,7 +57,7 @@ public class ApplicationMetricGraph { private void link(Graph graph) { GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.APPLICATION_REFERENCE_METRIC_GRAPH_ID, ApplicationReferenceMetric.class) - .toFinder().findNode(MetricWorkerIdDefine.APPLICATION_REFERENCE_METRIC_AGGREGATION_WORKER_ID, ApplicationReferenceMetric.class) + .toFinder().findNode(MetricWorkerIdDefine.APPLICATION_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID, ApplicationReferenceMetric.class) .addNext(new NodeProcessor() { @Override public int id() { diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricPersistenceWorker.java similarity index 73% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricPersistenceWorker.java index 7adf649ac..2741c3cb1 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricPersistenceWorker.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker; @@ -24,20 +24,20 @@ import org.apache.skywalking.apm.collector.analysis.worker.model.impl.Persistenc import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceDayMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; /** * @author peng-yongsheng */ -public class ApplicationReferenceMetricPersistenceWorker extends PersistenceWorker { +public class ApplicationReferenceDayMetricPersistenceWorker extends PersistenceWorker { - public ApplicationReferenceMetricPersistenceWorker(ModuleManager moduleManager) { + public ApplicationReferenceDayMetricPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return MetricWorkerIdDefine.APPLICATION_REFERENCE_METRIC_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID; } @Override protected boolean needMergeDBData() { @@ -46,17 +46,17 @@ public class ApplicationReferenceMetricPersistenceWorker extends PersistenceWork @SuppressWarnings("unchecked") @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceMetricPersistenceDAO.class); + return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceDayMetricPersistenceDAO.class); } - public static class Factory extends PersistenceWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ApplicationReferenceMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationReferenceMetricPersistenceWorker(moduleManager); + @Override public ApplicationReferenceDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceDayMetricPersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricTransformNode.java new file mode 100644 index 000000000..699cb27df --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceDayMetricTransformNode.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.core.graph.Next; +import org.apache.skywalking.apm.collector.core.graph.NodeProcessor; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceDayMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationReferenceMetric applicationReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(applicationReferenceMetric.getTimeBucket()); + applicationReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationReferenceMetric.getMetricId()); + applicationReferenceMetric.setTimeBucket(timeBucket); + + next.execute(applicationReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricPersistenceWorker.java new file mode 100644 index 000000000..7a74d2e25 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricPersistenceWorker.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceHourMetricPersistenceWorker extends PersistenceWorker { + + public ApplicationReferenceHourMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceHourMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationReferenceHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceHourMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricTransformNode.java new file mode 100644 index 000000000..a226e61d2 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceHourMetricTransformNode.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.core.graph.Next; +import org.apache.skywalking.apm.collector.core.graph.NodeProcessor; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceHourMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationReferenceMetric applicationReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(applicationReferenceMetric.getTimeBucket()); + applicationReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationReferenceMetric.getMetricId()); + applicationReferenceMetric.setTimeBucket(timeBucket); + + next.execute(applicationReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricAggregationWorker.java similarity index 94% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricAggregationWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricAggregationWorker.java index 75bc32225..dd6e6dcbc 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricAggregationWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricAggregationWorker.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; @@ -46,19 +46,23 @@ public class ApplicationReferenceMetricAggregationWorker extends AggregationWork } @Override public int id() { - return MetricWorkerIdDefine.APPLICATION_REFERENCE_METRIC_AGGREGATION_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID; } @Override protected ApplicationReferenceMetric transform(InstanceReferenceMetric instanceReferenceMetric) { Integer frontApplicationId = instanceCacheService.getApplicationId(instanceReferenceMetric.getFrontInstanceId()); Integer behindApplicationId = instanceCacheService.getApplicationId(instanceReferenceMetric.getBehindInstanceId()); - String id = instanceReferenceMetric.getTimeBucket() - + Const.ID_SPLIT + frontApplicationId + String metricId = frontApplicationId + Const.ID_SPLIT + behindApplicationId + Const.ID_SPLIT + instanceReferenceMetric.getSourceValue(); - ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(id); + String id = instanceReferenceMetric.getTimeBucket() + + Const.ID_SPLIT + metricId; + + ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(); + applicationReferenceMetric.setId(id); + applicationReferenceMetric.setMetricId(metricId); applicationReferenceMetric.setFrontApplicationId(frontApplicationId); applicationReferenceMetric.setBehindApplicationId(behindApplicationId); applicationReferenceMetric.setSourceValue(instanceReferenceMetric.getSourceValue()); diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricGraph.java similarity index 75% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricGraph.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricGraph.java index 92df5164d..65dd4035a 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricGraph.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; @@ -24,10 +24,12 @@ import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCrea import org.apache.skywalking.apm.collector.core.graph.Graph; import org.apache.skywalking.apm.collector.core.graph.GraphManager; import org.apache.skywalking.apm.collector.core.graph.Next; +import org.apache.skywalking.apm.collector.core.graph.Node; import org.apache.skywalking.apm.collector.core.graph.NodeProcessor; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.remote.RemoteModule; import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; /** @@ -48,9 +50,19 @@ public class ApplicationReferenceMetricGraph { Graph graph = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.APPLICATION_REFERENCE_METRIC_GRAPH_ID, InstanceReferenceMetric.class); - graph.addNode(new ApplicationReferenceMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) - .addNext(new ApplicationReferenceMetricRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.APPLICATION_REFERENCE_METRIC_GRAPH_ID).create(workerCreateListener)) - .addNext(new ApplicationReferenceMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node remoteNode = graph.addNode(new ApplicationReferenceMetricAggregationWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new ApplicationReferenceMetricRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.APPLICATION_REFERENCE_METRIC_GRAPH_ID).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationReferenceMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationReferenceHourMetricTransformNode()) + .addNext(new ApplicationReferenceHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationReferenceDayMetricTransformNode()) + .addNext(new ApplicationReferenceDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ApplicationReferenceMonthMetricTransformNode()) + .addNext(new ApplicationReferenceMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); link(graph); } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricRemoteWorker.java similarity index 95% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricRemoteWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricRemoteWorker.java index ed8f9c80b..33a79b3c6 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/ApplicationReferenceMetricRemoteWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMetricRemoteWorker.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application; +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker; @@ -37,7 +37,7 @@ public class ApplicationReferenceMetricRemoteWorker extends AbstractRemoteWorker } @Override public int id() { - return MetricWorkerIdDefine.APPLICATION_REFERENCE_METRIC_REMOTE_WORKER_ID; + return MetricWorkerIdDefine.APPLICATION_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID; } @Override protected void onWork(ApplicationReferenceMetric applicationReferenceMetric) throws WorkerException { diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..72b542911 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMinuteMetricPersistenceWorker.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMinuteMetricPersistenceWorker extends PersistenceWorker { + + public ApplicationReferenceMinuteMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceMinuteMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationReferenceMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricPersistenceWorker.java new file mode 100644 index 000000000..ac6f3b52a --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricPersistenceWorker.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMonthMetricPersistenceWorker extends PersistenceWorker { + + public ApplicationReferenceMonthMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationReferenceMonthMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationReferenceMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationReferenceMonthMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricTransformNode.java new file mode 100644 index 000000000..4a26159ad --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/refmetric/ApplicationReferenceMonthMetricTransformNode.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.core.graph.Next; +import org.apache.skywalking.apm.collector.core.graph.NodeProcessor; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMonthMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.APPLICATION_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationReferenceMetric applicationReferenceMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(applicationReferenceMetric.getTimeBucket()); + applicationReferenceMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationReferenceMetric.getMetricId()); + applicationReferenceMetric.setTimeBucket(timeBucket); + + next.execute(applicationReferenceMetric); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java index 1d5ed06f7..382f40c7b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java @@ -32,7 +32,7 @@ import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceAlarmListPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceAlarmPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; @@ -123,7 +123,7 @@ public class StorageModule extends Module { classes.add(IApplicationComponentPersistenceDAO.class); classes.add(IApplicationMappingPersistenceDAO.class); classes.add(IApplicationMetricPersistenceDAO.class); - classes.add(IApplicationReferenceMetricPersistenceDAO.class); + classes.add(IApplicationReferenceMinuteMetricPersistenceDAO.class); classes.add(ISegmentCostPersistenceDAO.class); classes.add(ISegmentPersistenceDAO.class); classes.add(IServiceEntryPersistenceDAO.class); diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceDayMetricPersistenceDAO.java similarity index 80% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricPersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceDayMetricPersistenceDAO.java index f5d2b9449..0f2cc394c 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceDayMetricPersistenceDAO.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.apm.collector.storage.dao; +package org.apache.skywalking.apm.collector.storage.dao.armp; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; @@ -24,5 +24,5 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application /** * @author peng-yongsheng */ -public interface IApplicationReferenceMetricPersistenceDAO extends IPersistenceDAO { +public interface IApplicationReferenceDayMetricPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceHourMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceHourMetricPersistenceDAO.java new file mode 100644 index 000000000..9f59debd0 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceHourMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.storage.dao.armp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IApplicationReferenceHourMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..3d140d65e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMinuteMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.storage.dao.armp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IApplicationReferenceMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMonthMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMonthMetricPersistenceDAO.java new file mode 100644 index 000000000..286a88624 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/armp/IApplicationReferenceMonthMetricPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.storage.dao.armp; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; + +/** + * @author peng-yongsheng + */ +public interface IApplicationReferenceMonthMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java index d092ca7a5..8c567886e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationReferenceMetric.java @@ -19,7 +19,7 @@ package org.apache.skywalking.apm.collector.storage.table.application; import org.apache.skywalking.apm.collector.core.data.Column; -import org.apache.skywalking.apm.collector.core.data.AbstractData; +import org.apache.skywalking.apm.collector.core.data.StreamData; import org.apache.skywalking.apm.collector.core.data.operator.AddOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; import org.apache.skywalking.apm.collector.storage.table.Metric; @@ -27,10 +27,11 @@ import org.apache.skywalking.apm.collector.storage.table.Metric; /** * @author peng-yongsheng */ -public class ApplicationReferenceMetric extends AbstractData implements Metric { +public class ApplicationReferenceMetric extends StreamData implements Metric { private static final Column[] STRING_COLUMNS = { new Column(ApplicationReferenceMetricTable.COLUMN_ID, new NonOperation()), + new Column(ApplicationReferenceMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { @@ -65,8 +66,24 @@ public class ApplicationReferenceMetric extends AbstractData implements Metric { private static final Column[] BYTE_COLUMNS = {}; - public ApplicationReferenceMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public ApplicationReferenceMetric() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); } @Override diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java index 36804e099..04266733a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java @@ -26,6 +26,7 @@ import org.apache.skywalking.apm.collector.storage.dao.*; import java.util.Calendar; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO; /** @@ -96,7 +97,7 @@ public class DataTTLKeeperTimer { IApplicationMappingPersistenceDAO applicationMappingPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingPersistenceDAO.class); applicationMappingPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); - IApplicationReferenceMetricPersistenceDAO applicationReferenceMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricPersistenceDAO.class); + IApplicationReferenceMinuteMetricPersistenceDAO applicationReferenceMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMinuteMetricPersistenceDAO.class); applicationReferenceMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); ISegmentCostPersistenceDAO segmentCostPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentCostPersistenceDAO.class); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java index 92004984f..c84399684 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java @@ -41,7 +41,7 @@ import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceAlarmListPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceAlarmPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; @@ -96,7 +96,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsUI import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationReferenceAlarmEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationReferenceAlarmListEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.armp.ApplicationReferenceMinuteMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.CpuMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.CpuMetricEsUIDAO; @@ -236,7 +236,7 @@ public class StorageModuleEsProvider extends ModuleProvider { 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(IApplicationReferenceMinuteMetricPersistenceDAO.class, new ApplicationReferenceMinuteMetricEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IServiceEntryPersistenceDAO.class, new ServiceEntryEsPersistenceDAO(elasticSearchClient)); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsPersistenceDAO.java deleted file mode 100644 index ffe56b7ac..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsPersistenceDAO.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - * - */ - -package org.apache.skywalking.apm.collector.storage.es.dao; - -import java.util.HashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.update.UpdateRequestBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ApplicationReferenceMetricEsPersistenceDAO extends EsDAO implements IApplicationReferenceMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMetricEsPersistenceDAO.class); - - public ApplicationReferenceMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public ApplicationReferenceMetric get(String id) { - GetResponse getResponse = getClient().prepareGet(ApplicationReferenceMetricTable.TABLE, id).get(); - if (getResponse.isExists()) { - ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(id); - 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.setSourceValue(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE)).intValue()); - - applicationReferenceMetric.setTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); - applicationReferenceMetric.setTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); - applicationReferenceMetric.setTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); - applicationReferenceMetric.setTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - applicationReferenceMetric.setBusinessTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); - applicationReferenceMetric.setBusinessTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); - applicationReferenceMetric.setBusinessTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); - applicationReferenceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); - - applicationReferenceMetric.setMqTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); - applicationReferenceMetric.setMqTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); - applicationReferenceMetric.setMqTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); - applicationReferenceMetric.setMqTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_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 { - return null; - } - } - - @Override public IndexRequestBuilder prepareBatchInsert(ApplicationReferenceMetric data) { - 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_SOURCE_VALUE, data.getSourceValue()); - - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - 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); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(ApplicationReferenceMetric data) { - 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_SOURCE_VALUE, data.getSourceValue()); - - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum()); - - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum()); - - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum()); - source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum()); - - 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); - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(ApplicationReferenceMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, ApplicationReferenceMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/AbstractApplicationReferenceMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/AbstractApplicationReferenceMetricEsPersistenceDAO.java new file mode 100644 index 000000000..dbb6bb747 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/AbstractApplicationReferenceMetricEsPersistenceDAO.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.storage.es.dao.armp; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractApplicationReferenceMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractApplicationReferenceMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final ApplicationReferenceMetric esDataToStreamData(Map source) { + ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(); + applicationReferenceMetric.setId((String)source.get(ApplicationReferenceMetricTable.COLUMN_ID)); + applicationReferenceMetric.setMetricId((String)source.get(ApplicationReferenceMetricTable.COLUMN_METRIC_ID)); + + applicationReferenceMetric.setFrontApplicationId(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)).intValue()); + applicationReferenceMetric.setBehindApplicationId(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)).intValue()); + applicationReferenceMetric.setSourceValue(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE)).intValue()); + + applicationReferenceMetric.setTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); + applicationReferenceMetric.setTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue()); + applicationReferenceMetric.setTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue()); + applicationReferenceMetric.setTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + applicationReferenceMetric.setBusinessTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue()); + applicationReferenceMetric.setBusinessTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue()); + applicationReferenceMetric.setBusinessTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue()); + applicationReferenceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue()); + + applicationReferenceMetric.setMqTransactionCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue()); + applicationReferenceMetric.setMqTransactionErrorCalls(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue()); + applicationReferenceMetric.setMqTransactionDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue()); + applicationReferenceMetric.setMqTransactionErrorDurationSum(((Number)source.get(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_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; + } + + @Override protected final Map esStreamDataToEsData(ApplicationReferenceMetric streamData) { + Map source = new HashMap<>(); + source.put(ApplicationReferenceMetricTable.COLUMN_ID, streamData.getId()); + source.put(ApplicationReferenceMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, streamData.getFrontApplicationId()); + source.put(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, streamData.getBehindApplicationId()); + source.put(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, streamData.getSourceValue()); + + source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS, streamData.getTransactionCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, streamData.getTransactionErrorCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, streamData.getTransactionDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, streamData.getTransactionErrorDurationSum()); + + source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, streamData.getBusinessTransactionCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, streamData.getBusinessTransactionErrorCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, streamData.getBusinessTransactionDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, streamData.getBusinessTransactionErrorDurationSum()); + + source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, streamData.getMqTransactionCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, streamData.getMqTransactionErrorCalls()); + source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, streamData.getMqTransactionDurationSum()); + source.put(ApplicationReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, streamData.getMqTransactionErrorDurationSum()); + + source.put(ApplicationReferenceMetricTable.COLUMN_SATISFIED_COUNT, streamData.getSatisfiedCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_TOLERATING_COUNT, streamData.getToleratingCount()); + source.put(ApplicationReferenceMetricTable.COLUMN_FRUSTRATED_COUNT, streamData.getFrustratedCount()); + + source.put(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); + + return source; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..457d53d57 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceDayMetricEsPersistenceDAO.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.storage.es.dao.armp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceDayMetricEsPersistenceDAO extends AbstractApplicationReferenceMetricEsPersistenceDAO implements IApplicationReferenceDayMetricPersistenceDAO { + + public ApplicationReferenceDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..ca99be26a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceHourMetricEsPersistenceDAO.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.storage.es.dao.armp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceHourMetricEsPersistenceDAO extends AbstractApplicationReferenceMetricEsPersistenceDAO implements IApplicationReferenceHourMetricPersistenceDAO { + + public ApplicationReferenceHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..39036c4aa --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMinuteMetricEsPersistenceDAO.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.storage.es.dao.armp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMinuteMetricEsPersistenceDAO extends AbstractApplicationReferenceMetricEsPersistenceDAO implements IApplicationReferenceMinuteMetricPersistenceDAO { + + public ApplicationReferenceMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..46c1d0598 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/armp/ApplicationReferenceMonthMetricEsPersistenceDAO.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.apm.collector.storage.es.dao.armp; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMonthMetricEsPersistenceDAO extends AbstractApplicationReferenceMetricEsPersistenceDAO implements IApplicationReferenceMonthMetricPersistenceDAO { + + public ApplicationReferenceMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationReferenceMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java index 459944e7c..4529ad5c4 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java @@ -37,7 +37,7 @@ import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceAlarmListPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceAlarmPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; @@ -92,7 +92,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2UI import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceAlarmH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceAlarmListH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMinuteMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.CpuMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.CpuMetricH2UIDAO; @@ -214,7 +214,7 @@ public class StorageModuleH2Provider extends ModuleProvider { 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(IApplicationReferenceMinuteMetricPersistenceDAO.class, new ApplicationReferenceMinuteMetricH2PersistenceDAO(h2Client)); this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostH2PersistenceDAO(h2Client)); this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IServiceEntryPersistenceDAO.class, new ServiceEntryH2PersistenceDAO(h2Client)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMinuteMetricH2PersistenceDAO.java similarity index 96% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMinuteMetricH2PersistenceDAO.java index 09c8d17ff..2fada9d91 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMinuteMetricH2PersistenceDAO.java @@ -26,7 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; import org.apache.skywalking.apm.collector.client.h2.H2Client; @@ -39,12 +39,12 @@ import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class ApplicationReferenceMetricH2PersistenceDAO extends H2DAO implements IApplicationReferenceMetricPersistenceDAO { +public class ApplicationReferenceMinuteMetricH2PersistenceDAO extends H2DAO implements IApplicationReferenceMinuteMetricPersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMetricH2PersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMinuteMetricH2PersistenceDAO.class); private static final String GET_SQL = "select * from {0} where {1} = ?"; - public ApplicationReferenceMetricH2PersistenceDAO(H2Client client) { + public ApplicationReferenceMinuteMetricH2PersistenceDAO(H2Client client) { super(client); }