From f77c10d59d068b73a2deaedb9019dc5ed8210d5e Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sun, 7 Jan 2018 23:31:19 +0800 Subject: [PATCH] Cpu metric pyramid aggregate. --- .../jvm/define/graph/WorkerIdDefine.java | 12 ++- .../provider/AnalysisJVMModuleProvider.java | 2 +- .../cpu/CpuDayMetricPersistenceWorker.java | 67 ++++++++++++++++ .../worker/cpu/CpuDayMetricTransformNode.java | 44 +++++++++++ .../cpu/CpuHourMetricPersistenceWorker.java | 67 ++++++++++++++++ .../cpu/CpuHourMetricTransformNode.java | 44 +++++++++++ .../worker/cpu/CpuMetricBridgeNode.java | 38 ++++++++++ .../{ => cpu}/CpuMetricPersistenceGraph.java | 21 ++++- .../cpu/CpuMinuteMetricPersistenceWorker.java | 67 ++++++++++++++++ .../cpu/CpuMinuteMetricTransformNode.java | 44 +++++++++++ .../cpu/CpuMonthMetricPersistenceWorker.java | 67 ++++++++++++++++ .../cpu/CpuMonthMetricTransformNode.java | 44 +++++++++++ .../CpuSecondMetricPersistenceWorker.java} | 18 ++--- .../collector/core/storage/TimePyramid.java | 2 +- .../collector/core/util/TimeBucketUtils.java | 16 ++++ .../apm/collector/storage/StorageModule.java | 4 +- .../ICpuDayMetricPersistenceDAO.java} | 4 +- .../cpump/ICpuHourMetricPersistenceDAO.java | 28 +++++++ .../cpump/ICpuMinuteMetricPersistenceDAO.java | 28 +++++++ .../cpump/ICpuMonthMetricPersistenceDAO.java | 28 +++++++ .../cpump/ICpuSecondMetricPersistenceDAO.java | 28 +++++++ .../storage/table/jvm/CpuMetric.java | 27 +++++-- .../storage/es/DataTTLKeeperTimer.java | 3 +- .../storage/es/StorageModuleEsProvider.java | 6 +- .../es/dao/CpuMetricEsPersistenceDAO.java | 76 ------------------- .../AbstractCpuMetricEsPersistenceDAO.java | 56 ++++++++++++++ .../cpump/CpuDayMetricEsPersistenceDAO.java | 42 ++++++++++ .../cpump/CpuHourMetricEsPersistenceDAO.java | 42 ++++++++++ .../CpuMinuteMetricEsPersistenceDAO.java | 42 ++++++++++ .../cpump/CpuMonthMetricEsPersistenceDAO.java | 42 ++++++++++ .../CpuSecondMetricEsPersistenceDAO.java | 42 ++++++++++ .../storage/h2/StorageModuleH2Provider.java | 6 +- ...a => CpuSecondMetricH2PersistenceDAO.java} | 8 +- 33 files changed, 954 insertions(+), 111 deletions(-) create mode 100644 apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricPersistenceWorker.java create mode 100644 apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricTransformNode.java create mode 100644 apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricPersistenceWorker.java create mode 100644 apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricTransformNode.java create mode 100644 apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricBridgeNode.java rename apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/{ => cpu}/CpuMetricPersistenceGraph.java (61%) create mode 100644 apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricPersistenceWorker.java create mode 100644 apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricTransformNode.java create mode 100644 apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricPersistenceWorker.java create mode 100644 apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricTransformNode.java rename apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/{CpuMetricPersistenceWorker.java => cpu/CpuSecondMetricPersistenceWorker.java} (77%) rename apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/{ICpuMetricPersistenceDAO.java => cpump/ICpuDayMetricPersistenceDAO.java} (82%) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuHourMetricPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMinuteMetricPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMonthMetricPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuSecondMetricPersistenceDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/AbstractCpuMetricEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuDayMetricEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuHourMetricEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMinuteMetricEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMonthMetricEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuSecondMetricEsPersistenceDAO.java rename apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/{CpuMetricH2PersistenceDAO.java => CpuSecondMetricH2PersistenceDAO.java} (86%) diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/WorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/WorkerIdDefine.java index 1606225cb..59fc6691b 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/WorkerIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/define/graph/WorkerIdDefine.java @@ -22,7 +22,17 @@ package org.apache.skywalking.apm.collector.analysis.jvm.define.graph; * @author peng-yongsheng */ public class WorkerIdDefine { - public static final int CPU_METRIC_PERSISTENCE_WORKER_ID = 300; + public static final int CPU_METRIC_BRIDGE_NODE_ID = 3000; + public static final int CPU_SECOND_METRIC_PERSISTENCE_WORKER_ID = 3001; + public static final int CPU_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 3002; + public static final int CPU_MINUTE_METRIC_TRANSFORM_NODE_ID = 3003; + public static final int CPU_HOUR_METRIC_PERSISTENCE_WORKER_ID = 3004; + public static final int CPU_HOUR_METRIC_TRANSFORM_NODE_ID = 3005; + public static final int CPU_DAY_METRIC_PERSISTENCE_WORKER_ID = 3006; + public static final int CPU_DAY_METRIC_TRANSFORM_NODE_ID = 3007; + public static final int CPU_MONTH_METRIC_PERSISTENCE_WORKER_ID = 3008; + public static final int CPU_MONTH_METRIC_TRANSFORM_NODE_ID = 3009; + public static final int GC_METRIC_PERSISTENCE_WORKER_ID = 301; public static final int INST_HEART_BEAT_PERSISTENCE_WORKER_ID = 302; public static final int MEMORY_METRIC_PERSISTENCE_WORKER_ID = 303; diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/AnalysisJVMModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/AnalysisJVMModuleProvider.java index 2b5904e56..f23351e56 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/AnalysisJVMModuleProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/AnalysisJVMModuleProvider.java @@ -30,7 +30,7 @@ import org.apache.skywalking.apm.collector.analysis.jvm.provider.service.GCMetri import org.apache.skywalking.apm.collector.analysis.jvm.provider.service.InstanceHeartBeatService; import org.apache.skywalking.apm.collector.analysis.jvm.provider.service.MemoryMetricService; import org.apache.skywalking.apm.collector.analysis.jvm.provider.service.MemoryPoolMetricService; -import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.CpuMetricPersistenceGraph; +import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.cpu.CpuMetricPersistenceGraph; import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.GCMetricPersistenceGraph; import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.InstanceHeartBeatPersistenceGraph; import org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.MemoryMetricPersistenceGraph; diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricPersistenceWorker.java new file mode 100644 index 000000000..7b42a800e --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricPersistenceWorker.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.jvm.provider.worker.cpu; + +import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine; +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.cpump.ICpuDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public class CpuDayMetricPersistenceWorker extends PersistenceWorker { + + public CpuDayMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return WorkerIdDefine.CPU_DAY_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(ICpuDayMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public CpuDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new CpuDayMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricTransformNode.java new file mode 100644 index 000000000..3128fc917 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuDayMetricTransformNode.java @@ -0,0 +1,44 @@ +/* + * 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.jvm.provider.worker.cpu; + +import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine; +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.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public class CpuDayMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.CPU_DAY_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(CpuMetric cpuMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.secondToDay(cpuMetric.getTimeBucket()); + cpuMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + cpuMetric.getMetricId()); + cpuMetric.setTimeBucket(timeBucket); + + next.execute(cpuMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricPersistenceWorker.java new file mode 100644 index 000000000..be163fa89 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricPersistenceWorker.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.jvm.provider.worker.cpu; + +import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine; +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.cpump.ICpuHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public class CpuHourMetricPersistenceWorker extends PersistenceWorker { + + public CpuHourMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return WorkerIdDefine.CPU_HOUR_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(ICpuHourMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public CpuHourMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new CpuHourMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricTransformNode.java new file mode 100644 index 000000000..48699714c --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuHourMetricTransformNode.java @@ -0,0 +1,44 @@ +/* + * 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.jvm.provider.worker.cpu; + +import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine; +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.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public class CpuHourMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.CPU_HOUR_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(CpuMetric cpuMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.secondToHour(cpuMetric.getTimeBucket()); + cpuMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + cpuMetric.getMetricId()); + cpuMetric.setTimeBucket(timeBucket); + + next.execute(cpuMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricBridgeNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricBridgeNode.java new file mode 100644 index 000000000..745b73b6f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricBridgeNode.java @@ -0,0 +1,38 @@ +/* + * 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.jvm.provider.worker.cpu; + +import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine; +import org.apache.skywalking.apm.collector.core.graph.Next; +import org.apache.skywalking.apm.collector.core.graph.NodeProcessor; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public class CpuMetricBridgeNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.CPU_METRIC_BRIDGE_NODE_ID; + } + + @Override public void process(CpuMetric metric, Next next) { + next.execute(metric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceGraph.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricPersistenceGraph.java similarity index 61% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceGraph.java rename to apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricPersistenceGraph.java index 9384c85c7..0196ea3b3 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMetricPersistenceGraph.java @@ -16,11 +16,12 @@ * */ -package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker; +package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.cpu; import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.GraphIdDefine; import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener; import org.apache.skywalking.apm.collector.core.graph.GraphManager; +import org.apache.skywalking.apm.collector.core.graph.Node; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; @@ -38,7 +39,21 @@ public class CpuMetricPersistenceGraph { } public void create() { - GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.CPU_METRIC_PERSISTENCE_GRAPH_ID, CpuMetric.class) - .addNode(new CpuMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + Node bridgeNode = GraphManager.INSTANCE.createIfAbsent(GraphIdDefine.CPU_METRIC_PERSISTENCE_GRAPH_ID, CpuMetric.class) + .addNode(new CpuMetricBridgeNode()); + + bridgeNode.addNext(new CpuSecondMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new CpuMinuteMetricTransformNode()) + .addNext(new CpuMinuteMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new CpuHourMetricTransformNode()) + .addNext(new CpuHourMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new CpuDayMetricTransformNode()) + .addNext(new CpuDayMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + bridgeNode.addNext(new CpuMonthMetricTransformNode()) + .addNext(new CpuMonthMetricPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricPersistenceWorker.java new file mode 100644 index 000000000..30b6685c2 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricPersistenceWorker.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.jvm.provider.worker.cpu; + +import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine; +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.cpump.ICpuMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public class CpuMinuteMetricPersistenceWorker extends PersistenceWorker { + + public CpuMinuteMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return WorkerIdDefine.CPU_MINUTE_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(ICpuMinuteMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public CpuMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new CpuMinuteMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricTransformNode.java new file mode 100644 index 000000000..6e276a9ee --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMinuteMetricTransformNode.java @@ -0,0 +1,44 @@ +/* + * 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.jvm.provider.worker.cpu; + +import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine; +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.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public class CpuMinuteMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.CPU_MINUTE_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(CpuMetric cpuMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.secondToMinute(cpuMetric.getTimeBucket()); + cpuMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + cpuMetric.getMetricId()); + cpuMetric.setTimeBucket(timeBucket); + + next.execute(cpuMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricPersistenceWorker.java new file mode 100644 index 000000000..8bf3cfe69 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricPersistenceWorker.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.jvm.provider.worker.cpu; + +import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine; +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.cpump.ICpuMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public class CpuMonthMetricPersistenceWorker extends PersistenceWorker { + + public CpuMonthMetricPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return WorkerIdDefine.CPU_MONTH_METRIC_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(ICpuMonthMetricPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public CpuMonthMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new CpuMonthMetricPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricTransformNode.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricTransformNode.java new file mode 100644 index 000000000..87ff41276 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuMonthMetricTransformNode.java @@ -0,0 +1,44 @@ +/* + * 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.jvm.provider.worker.cpu; + +import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine; +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.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public class CpuMonthMetricTransformNode implements NodeProcessor { + + @Override public int id() { + return WorkerIdDefine.CPU_MONTH_METRIC_TRANSFORM_NODE_ID; + } + + @Override public void process(CpuMetric cpuMetric, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.secondToMonth(cpuMetric.getTimeBucket()); + cpuMetric.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + cpuMetric.getMetricId()); + cpuMetric.setTimeBucket(timeBucket); + + next.execute(cpuMetric); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuSecondMetricPersistenceWorker.java similarity index 77% rename from apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuSecondMetricPersistenceWorker.java index 402d222ee..ea2dfeba4 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/CpuMetricPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/worker/cpu/CpuSecondMetricPersistenceWorker.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker; +package org.apache.skywalking.apm.collector.analysis.jvm.provider.worker.cpu; import org.apache.skywalking.apm.collector.analysis.jvm.define.graph.WorkerIdDefine; 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.ICpuMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; /** * @author peng-yongsheng */ -public class CpuMetricPersistenceWorker extends PersistenceWorker { +public class CpuSecondMetricPersistenceWorker extends PersistenceWorker { - public CpuMetricPersistenceWorker(ModuleManager moduleManager) { + public CpuSecondMetricPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return WorkerIdDefine.CPU_METRIC_PERSISTENCE_WORKER_ID; + return WorkerIdDefine.CPU_SECOND_METRIC_PERSISTENCE_WORKER_ID; } @Override protected boolean needMergeDBData() { @@ -46,17 +46,17 @@ public class CpuMetricPersistenceWorker extends PersistenceWorker { @SuppressWarnings("unchecked") @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(ICpuMetricPersistenceDAO.class); + return getModuleManager().find(StorageModule.NAME).getService(ICpuSecondMetricPersistenceDAO.class); } - public static class Factory extends PersistenceWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public CpuMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new CpuMetricPersistenceWorker(moduleManager); + @Override public CpuSecondMetricPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new CpuSecondMetricPersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/storage/TimePyramid.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/storage/TimePyramid.java index ee35f6e2f..5fd286ada 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/storage/TimePyramid.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/storage/TimePyramid.java @@ -22,7 +22,7 @@ package org.apache.skywalking.apm.collector.core.storage; * @author peng-yongsheng */ public enum TimePyramid { - Minute(0, "minute"), Hour(1, "hour"), Day(2, "day"), Month(3, "month"); + Second(0, "second"), Minute(1, "minute"), Hour(2, "hour"), Day(3, "day"), Month(4, "month"); private final int value; private final String name; diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java index e22a69a27..889691358 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java @@ -74,6 +74,22 @@ public enum TimeBucketUtils { return minuteBucket / 100 / 100 / 100; } + public long secondToMinute(long secondBucket) { + return secondBucket / 100; + } + + public long secondToHour(long secondBucket) { + return secondBucket / 100 / 100; + } + + public long secondToDay(long secondBucket) { + return secondBucket / 100 / 100 / 100; + } + + public long secondToMonth(long secondBucket) { + return secondBucket / 100 / 100 / 100; + } + public long changeTimeBucket2TimeStamp(String timeBucketType, long timeBucket) { if (TimeBucketType.SECOND.name().toLowerCase().equals(timeBucketType.toLowerCase())) { Calendar calendar = Calendar.getInstance(); 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 3a5b78913..93e7d8b0f 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 @@ -35,7 +35,7 @@ import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceAlar 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; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; @@ -114,7 +114,7 @@ public class StorageModule extends Module { } private void addPersistenceDAO(List classes) { - classes.add(ICpuMetricPersistenceDAO.class); + classes.add(ICpuSecondMetricPersistenceDAO.class); classes.add(IGCMetricPersistenceDAO.class); classes.add(IMemoryMetricPersistenceDAO.class); classes.add(IMemoryPoolMetricPersistenceDAO.class); diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuDayMetricPersistenceDAO.java similarity index 82% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricPersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuDayMetricPersistenceDAO.java index 4fa40237a..83ef64dda 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuDayMetricPersistenceDAO.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.apm.collector.storage.dao; +package org.apache.skywalking.apm.collector.storage.dao.cpump; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; @@ -24,5 +24,5 @@ import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; /** * @author peng-yongsheng */ -public interface ICpuMetricPersistenceDAO extends IPersistenceDAO { +public interface ICpuDayMetricPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuHourMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuHourMetricPersistenceDAO.java new file mode 100644 index 000000000..0f2685520 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuHourMetricPersistenceDAO.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.cpump; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public interface ICpuHourMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMinuteMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMinuteMetricPersistenceDAO.java new file mode 100644 index 000000000..edbc21baa --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMinuteMetricPersistenceDAO.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.cpump; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public interface ICpuMinuteMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMonthMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMonthMetricPersistenceDAO.java new file mode 100644 index 000000000..a83d6c522 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuMonthMetricPersistenceDAO.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.cpump; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public interface ICpuMonthMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuSecondMetricPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuSecondMetricPersistenceDAO.java new file mode 100644 index 000000000..f15e16dbf --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cpump/ICpuSecondMetricPersistenceDAO.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.cpump; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; + +/** + * @author peng-yongsheng + */ +public interface ICpuSecondMetricPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetric.java index b0da0d8a9..e689d6f81 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetric.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/jvm/CpuMetric.java @@ -16,11 +16,10 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.jvm; -import org.apache.skywalking.apm.collector.core.data.AbstractData; import org.apache.skywalking.apm.collector.core.data.Column; +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.CoverOperation; import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; @@ -28,10 +27,11 @@ import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class CpuMetric extends AbstractData { +public class CpuMetric extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(CpuMetricTable.COLUMN_ID, new NonOperation()), + new Column(CpuMetricTable.COLUMN_METRIC_ID, new NonOperation()), }; private static final Column[] LONG_COLUMNS = { @@ -49,8 +49,25 @@ public class CpuMetric extends AbstractData { private static final Column[] BOOLEAN_COLUMNS = {}; private static final Column[] BYTE_COLUMNS = {}; - public CpuMetric(String id) { - super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + public CpuMetric() { + 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); + } public Integer getInstanceId() { 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 7283a2a9d..1bae81e4e 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 @@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.imp.IInstanceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO; @@ -74,7 +75,7 @@ public class DataTTLKeeperTimer { } private void deleteJVMRelatedData(long startTimestamp, long endTimestamp) { - ICpuMetricPersistenceDAO cpuMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ICpuMetricPersistenceDAO.class); + ICpuSecondMetricPersistenceDAO cpuMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ICpuSecondMetricPersistenceDAO.class); cpuMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); IGCMetricPersistenceDAO gcMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IGCMetricPersistenceDAO.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 85069500b..b87982709 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 @@ -44,7 +44,7 @@ import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceAlar 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; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; @@ -98,7 +98,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationReferenceAl import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationReferenceAlarmListEsPersistenceDAO; 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.cpump.CpuSecondMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.CpuMetricEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.GCMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.GCMetricEsUIDAO; @@ -227,7 +227,7 @@ public class StorageModuleEsProvider extends ModuleProvider { } private void registerPersistenceDAO() throws ServiceNotProvidedException { - this.registerServiceImplementation(ICpuMetricPersistenceDAO.class, new CpuMetricEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(ICpuSecondMetricPersistenceDAO.class, new CpuSecondMetricEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IGCMetricPersistenceDAO.class, new GCMetricEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IMemoryMetricPersistenceDAO.class, new MemoryMetricEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IMemoryPoolMetricPersistenceDAO.class, new MemoryPoolMetricEsPersistenceDAO(elasticSearchClient)); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsPersistenceDAO.java deleted file mode 100644 index 80b9409f2..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsPersistenceDAO.java +++ /dev/null @@ -1,76 +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.ICpuMetricPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; -import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; -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 CpuMetricEsPersistenceDAO extends EsDAO implements ICpuMetricPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(CpuMetricEsPersistenceDAO.class); - - public CpuMetricEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public CpuMetric get(String id) { - return null; - } - - @Override public IndexRequestBuilder prepareBatchInsert(CpuMetric cpuMetric) { - Map source = new HashMap<>(); - source.put(CpuMetricTable.COLUMN_INSTANCE_ID, cpuMetric.getInstanceId()); - source.put(CpuMetricTable.COLUMN_USAGE_PERCENT, cpuMetric.getUsagePercent()); - source.put(CpuMetricTable.COLUMN_TIME_BUCKET, cpuMetric.getTimeBucket()); - - logger.debug("prepare cpu metric batch insert, getId: {}", cpuMetric.getId()); - return getClient().prepareIndex(CpuMetricTable.TABLE, cpuMetric.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(CpuMetric cpuMetric) { - return null; - } - - @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { - long startTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(startTimestamp); - long endTimeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(endTimestamp); - BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(CpuMetricTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(CpuMetricTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, CpuMetricTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/AbstractCpuMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/AbstractCpuMetricEsPersistenceDAO.java new file mode 100644 index 000000000..824308e38 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/AbstractCpuMetricEsPersistenceDAO.java @@ -0,0 +1,56 @@ +/* + * 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.cpump; + +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.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractCpuMetricEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractCpuMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return CpuMetricTable.COLUMN_TIME_BUCKET; + } + + @Override protected final CpuMetric esDataToStreamData(Map source) { + return null; + } + + @Override protected final Map esStreamDataToEsData(CpuMetric streamData) { + Map source = new HashMap<>(); + source.put(CpuMetricTable.COLUMN_ID, streamData.getId()); + source.put(CpuMetricTable.COLUMN_METRIC_ID, streamData.getMetricId()); + + source.put(CpuMetricTable.COLUMN_INSTANCE_ID, streamData.getInstanceId()); + source.put(CpuMetricTable.COLUMN_USAGE_PERCENT, streamData.getUsagePercent()); + source.put(CpuMetricTable.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/cpump/CpuDayMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuDayMetricEsPersistenceDAO.java new file mode 100644 index 000000000..3ddb77e8e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuDayMetricEsPersistenceDAO.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.cpump; + +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.cpump.ICpuDayMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class CpuDayMetricEsPersistenceDAO extends AbstractCpuMetricEsPersistenceDAO implements ICpuDayMetricPersistenceDAO { + + public CpuDayMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return CpuMetricTable.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/cpump/CpuHourMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuHourMetricEsPersistenceDAO.java new file mode 100644 index 000000000..fc46b8b29 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuHourMetricEsPersistenceDAO.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.cpump; + +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.cpump.ICpuHourMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class CpuHourMetricEsPersistenceDAO extends AbstractCpuMetricEsPersistenceDAO implements ICpuHourMetricPersistenceDAO { + + public CpuHourMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return CpuMetricTable.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/cpump/CpuMinuteMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMinuteMetricEsPersistenceDAO.java new file mode 100644 index 000000000..02e2cdda2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMinuteMetricEsPersistenceDAO.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.cpump; + +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.cpump.ICpuMinuteMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class CpuMinuteMetricEsPersistenceDAO extends AbstractCpuMetricEsPersistenceDAO implements ICpuMinuteMetricPersistenceDAO { + + public CpuMinuteMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return CpuMetricTable.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/cpump/CpuMonthMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMonthMetricEsPersistenceDAO.java new file mode 100644 index 000000000..1a69fe165 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuMonthMetricEsPersistenceDAO.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.cpump; + +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.cpump.ICpuMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class CpuMonthMetricEsPersistenceDAO extends AbstractCpuMetricEsPersistenceDAO implements ICpuMonthMetricPersistenceDAO { + + public CpuMonthMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuSecondMetricEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuSecondMetricEsPersistenceDAO.java new file mode 100644 index 000000000..78850b191 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cpump/CpuSecondMetricEsPersistenceDAO.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.cpump; + +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.cpump.ICpuSecondMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class CpuSecondMetricEsPersistenceDAO extends AbstractCpuMetricEsPersistenceDAO implements ICpuSecondMetricPersistenceDAO { + + public CpuSecondMetricEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return CpuMetricTable.TABLE + Const.ID_SPLIT + TimePyramid.Second.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 b7be5bebe..282f65c24 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 @@ -40,7 +40,7 @@ import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceAlar 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; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; @@ -94,7 +94,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceAl import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceAlarmListH2PersistenceDAO; 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.CpuSecondMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.CpuMetricH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.GCMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.GCMetricH2UIDAO; @@ -205,7 +205,7 @@ public class StorageModuleH2Provider extends ModuleProvider { } private void registerPersistenceDAO() throws ServiceNotProvidedException { - this.registerServiceImplementation(ICpuMetricPersistenceDAO.class, new CpuMetricH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(ICpuSecondMetricPersistenceDAO.class, new CpuSecondMetricH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IGCMetricPersistenceDAO.class, new GCMetricH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IMemoryMetricPersistenceDAO.class, new MemoryMetricH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IMemoryPoolMetricPersistenceDAO.class, new MemoryPoolMetricH2PersistenceDAO(h2Client)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuSecondMetricH2PersistenceDAO.java similarity index 86% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuSecondMetricH2PersistenceDAO.java index a3b52f1c9..47cacb3b7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuSecondMetricH2PersistenceDAO.java @@ -26,7 +26,7 @@ import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetric; import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.cpump.ICpuSecondMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,11 +34,11 @@ import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class CpuMetricH2PersistenceDAO extends H2DAO implements ICpuMetricPersistenceDAO { +public class CpuSecondMetricH2PersistenceDAO extends H2DAO implements ICpuSecondMetricPersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(CpuMetricH2PersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(CpuSecondMetricH2PersistenceDAO.class); - public CpuMetricH2PersistenceDAO(H2Client client) { + public CpuSecondMetricH2PersistenceDAO(H2Client client) { super(client); }