From 7ab59cb2527281918664ea560a3a1fa699f50ba2 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Mon, 12 Feb 2018 11:21:28 +0800 Subject: [PATCH 1/2] Split application alarm list entity to minute, hour, day, month. --- ...ationMetricAlarmListPersistenceWorker.java | 4 +- .../apm/collector/storage/StorageModule.java | 11 +- ...pplicationAlarmListDayPersistenceDAO.java} | 2 +- ...pplicationAlarmListHourPersistenceDAO.java | 28 +++++ ...licationAlarmListMinutePersistenceDAO.java | 28 +++++ ...plicationAlarmListMonthPersistenceDAO.java | 28 +++++ .../storage/es/StorageModuleEsProvider.java | 16 ++- ...tApplicationAlarmListEsPersistenceDAO.java | 70 ++++++++++++ ...plicationAlarmListEsDayPersistenceDAO.java | 42 +++++++ ...licationAlarmListEsHourPersistenceDAO.java | 42 +++++++ ...cationAlarmListEsMinutePersistenceDAO.java | 42 +++++++ ...icationAlarmListEsMonthPersistenceDAO.java | 42 +++++++ .../ApplicationAlarmListEsPersistenceDAO.java | 104 ------------------ ...actApplicationAlarmListEsTableDefine.java} | 10 +- .../ApplicationAlarmListDayEsTableDefine.java | 37 +++++++ ...ApplicationAlarmListHourEsTableDefine.java | 37 +++++++ ...plicationAlarmListMinuteEsTableDefine.java | 37 +++++++ ...pplicationAlarmListMonthEsTableDefine.java | 37 +++++++ .../resources/META-INF/defines/storage.define | 7 +- .../storage/h2/StorageModuleH2Provider.java | 16 ++- ...ApplicationAlarmListH2PersistenceDAO.java} | 14 +-- ...plicationAlarmListH2DayPersistenceDAO.java | 41 +++++++ ...licationAlarmListH2HourPersistenceDAO.java | 41 +++++++ ...cationAlarmListH2MinutePersistenceDAO.java | 41 +++++++ ...icationAlarmListH2MonthPersistenceDAO.java | 41 +++++++ ...actApplicationAlarmListH2TableDefine.java} | 6 +- .../ApplicationAlarmListDayH2TableDefine.java | 33 ++++++ ...ApplicationAlarmListHourH2TableDefine.java | 33 ++++++ ...plicationAlarmListMinuteH2TableDefine.java | 33 ++++++ ...pplicationAlarmListMonthH2TableDefine.java | 33 ++++++ .../resources/META-INF/defines/storage.define | 7 +- 31 files changed, 826 insertions(+), 137 deletions(-) rename apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/{IApplicationAlarmListPersistenceDAO.java => IApplicationAlarmListDayPersistenceDAO.java} (86%) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListHourPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListMinutePersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListMonthPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/AbstractApplicationAlarmListEsPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsDayPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsHourPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsMinutePersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsMonthPersistenceDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsPersistenceDAO.java rename apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/{ApplicationAlarmListEsTableDefine.java => AbstractApplicationAlarmListEsTableDefine.java} (88%) create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListDayEsTableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListHourEsTableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListMinuteEsTableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListMonthEsTableDefine.java rename apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/{ApplicationAlarmListH2PersistenceDAO.java => AbstractApplicationAlarmListH2PersistenceDAO.java} (78%) create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2DayPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2HourPersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2MinutePersistenceDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2MonthPersistenceDAO.java rename apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/{ApplicationAlarmListH2TableDefine.java => AbstractApplicationAlarmListH2TableDefine.java} (91%) create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListDayH2TableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListHourH2TableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListMinuteH2TableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListMonthH2TableDefine.java 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/ApplicationMetricAlarmListPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListPersistenceWorker.java index 88963870f..191048b2e 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListPersistenceWorker.java @@ -24,7 +24,7 @@ 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.alarm.IApplicationAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListMinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; /** @@ -46,7 +46,7 @@ public class ApplicationMetricAlarmListPersistenceWorker extends PersistenceWork @SuppressWarnings("unchecked") @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListPersistenceDAO.class); + return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListMinutePersistenceDAO.class); } public static class Factory extends PersistenceWorkerProvider { 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 9434ee859..daf060ca5 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 @@ -30,7 +30,10 @@ import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponent import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMonthPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListMonthPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmListPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmPersistenceDAO; @@ -269,6 +272,10 @@ public class StorageModule extends Module { classes.add(IInstanceAlarmPersistenceDAO.class); classes.add(IInstanceAlarmListPersistenceDAO.class); classes.add(IApplicationAlarmPersistenceDAO.class); - classes.add(IApplicationAlarmListPersistenceDAO.class); + + classes.add(IApplicationAlarmListMinutePersistenceDAO.class); + classes.add(IApplicationAlarmListHourPersistenceDAO.class); + classes.add(IApplicationAlarmListDayPersistenceDAO.class); + classes.add(IApplicationAlarmListMonthPersistenceDAO.class); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListDayPersistenceDAO.java similarity index 86% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListPersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListDayPersistenceDAO.java index a2e83fc36..6e0acea8b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListDayPersistenceDAO.java @@ -24,5 +24,5 @@ import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmL /** * @author peng-yongsheng */ -public interface IApplicationAlarmListPersistenceDAO extends IPersistenceDAO { +public interface IApplicationAlarmListDayPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListHourPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListHourPersistenceDAO.java new file mode 100644 index 000000000..bdf4e1025 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListHourPersistenceDAO.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.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; + +/** + * @author peng-yongsheng + */ +public interface IApplicationAlarmListHourPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListMinutePersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListMinutePersistenceDAO.java new file mode 100644 index 000000000..077c4a9b3 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListMinutePersistenceDAO.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.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; + +/** + * @author peng-yongsheng + */ +public interface IApplicationAlarmListMinutePersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListMonthPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListMonthPersistenceDAO.java new file mode 100644 index 000000000..08c0c8170 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/alarm/IApplicationAlarmListMonthPersistenceDAO.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.alarm; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; + +/** + * @author peng-yongsheng + */ +public interface IApplicationAlarmListMonthPersistenceDAO extends IPersistenceDAO { +} 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 789c9d652..c3dcd91f0 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 @@ -39,7 +39,10 @@ import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponent import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMonthPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListMonthPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmListPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmPersistenceDAO; @@ -139,7 +142,10 @@ import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationCompone import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentMinuteEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentMonthEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationAlarmEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationAlarmListEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationAlarmListEsDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationAlarmListEsHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationAlarmListEsMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationAlarmListEsMonthPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationReferenceAlarmEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.alarm.ApplicationReferenceAlarmListEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.alarm.InstanceAlarmEsPersistenceDAO; @@ -429,6 +435,10 @@ public class StorageModuleEsProvider extends ModuleProvider { this.registerServiceImplementation(IInstanceAlarmPersistenceDAO.class, new InstanceAlarmEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IInstanceAlarmListPersistenceDAO.class, new InstanceAlarmListEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IApplicationAlarmPersistenceDAO.class, new ApplicationAlarmEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(IApplicationAlarmListPersistenceDAO.class, new ApplicationAlarmListEsPersistenceDAO(elasticSearchClient)); + + this.registerServiceImplementation(IApplicationAlarmListMinutePersistenceDAO.class, new ApplicationAlarmListEsMinutePersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationAlarmListHourPersistenceDAO.class, new ApplicationAlarmListEsHourPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationAlarmListDayPersistenceDAO.class, new ApplicationAlarmListEsDayPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationAlarmListMonthPersistenceDAO.class, new ApplicationAlarmListEsMonthPersistenceDAO(elasticSearchClient)); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/AbstractApplicationAlarmListEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/AbstractApplicationAlarmListEsPersistenceDAO.java new file mode 100644 index 000000000..f5698c7e1 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/AbstractApplicationAlarmListEsPersistenceDAO.java @@ -0,0 +1,70 @@ +/* + * 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.alarm; + +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.alarm.ApplicationAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractApplicationAlarmListEsPersistenceDAO extends AbstractPersistenceEsDAO { + + private final Logger logger = LoggerFactory.getLogger(AbstractApplicationAlarmListEsPersistenceDAO.class); + + public AbstractApplicationAlarmListEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return ApplicationAlarmListTable.COLUMN_TIME_BUCKET; + } + + @Override protected final ApplicationAlarmList esDataToStreamData(Map source) { + ApplicationAlarmList applicationAlarmList = new ApplicationAlarmList(); + applicationAlarmList.setId((String)source.get(ApplicationAlarmListTable.COLUMN_ID)); + applicationAlarmList.setApplicationId(((Number)source.get(ApplicationAlarmListTable.COLUMN_APPLICATION_ID)).intValue()); + applicationAlarmList.setSourceValue(((Number)source.get(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE)).intValue()); + + applicationAlarmList.setAlarmType(((Number)source.get(ApplicationAlarmListTable.COLUMN_ALARM_TYPE)).intValue()); + applicationAlarmList.setAlarmContent((String)source.get(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT)); + + applicationAlarmList.setTimeBucket(((Number)source.get(ApplicationAlarmListTable.COLUMN_TIME_BUCKET)).longValue()); + return applicationAlarmList; + } + + @Override protected final Map esStreamDataToEsData(ApplicationAlarmList streamData) { + Map source = new HashMap<>(); + source.put(ApplicationAlarmListTable.COLUMN_ID, streamData.getId()); + source.put(ApplicationAlarmListTable.COLUMN_APPLICATION_ID, streamData.getApplicationId()); + source.put(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, streamData.getSourceValue()); + + source.put(ApplicationAlarmListTable.COLUMN_ALARM_TYPE, streamData.getAlarmType()); + source.put(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT, streamData.getAlarmContent()); + + source.put(ApplicationAlarmListTable.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/alarm/ApplicationAlarmListEsDayPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsDayPersistenceDAO.java new file mode 100644 index 000000000..5c129768d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsDayPersistenceDAO.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.alarm; + +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.alarm.IApplicationAlarmListDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListEsDayPersistenceDAO extends AbstractApplicationAlarmListEsPersistenceDAO implements IApplicationAlarmListDayPersistenceDAO { + + public ApplicationAlarmListEsDayPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationAlarmListTable.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/alarm/ApplicationAlarmListEsHourPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsHourPersistenceDAO.java new file mode 100644 index 000000000..3ffd72f32 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsHourPersistenceDAO.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.alarm; + +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.alarm.IApplicationAlarmListHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListEsHourPersistenceDAO extends AbstractApplicationAlarmListEsPersistenceDAO implements IApplicationAlarmListHourPersistenceDAO { + + public ApplicationAlarmListEsHourPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationAlarmListTable.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/alarm/ApplicationAlarmListEsMinutePersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsMinutePersistenceDAO.java new file mode 100644 index 000000000..a2ada3eb6 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsMinutePersistenceDAO.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.alarm; + +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.alarm.IApplicationAlarmListMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListEsMinutePersistenceDAO extends AbstractApplicationAlarmListEsPersistenceDAO implements IApplicationAlarmListMinutePersistenceDAO { + + public ApplicationAlarmListEsMinutePersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationAlarmListTable.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/alarm/ApplicationAlarmListEsMonthPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsMonthPersistenceDAO.java new file mode 100644 index 000000000..1599a8f08 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsMonthPersistenceDAO.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.alarm; + +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.alarm.IApplicationAlarmListMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListEsMonthPersistenceDAO extends AbstractApplicationAlarmListEsPersistenceDAO implements IApplicationAlarmListMonthPersistenceDAO { + + public ApplicationAlarmListEsMonthPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationAlarmListTable.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/alarm/ApplicationAlarmListEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsPersistenceDAO.java deleted file mode 100644 index 92b635727..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/ApplicationAlarmListEsPersistenceDAO.java +++ /dev/null @@ -1,104 +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.alarm; - -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.alarm.IApplicationAlarmListPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; -import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; -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 ApplicationAlarmListEsPersistenceDAO extends EsDAO implements IApplicationAlarmListPersistenceDAO { - - private final Logger logger = LoggerFactory.getLogger(ApplicationAlarmListEsPersistenceDAO.class); - - public ApplicationAlarmListEsPersistenceDAO(ElasticSearchClient client) { - super(client); - } - - @Override public ApplicationAlarmList get(String id) { - GetResponse getResponse = getClient().prepareGet(ApplicationAlarmListTable.TABLE, id).get(); - if (getResponse.isExists()) { - ApplicationAlarmList applicationAlarmList = new ApplicationAlarmList(); - applicationAlarmList.setId(id); - Map source = getResponse.getSource(); - applicationAlarmList.setApplicationId(((Number)source.get(ApplicationAlarmListTable.COLUMN_APPLICATION_ID)).intValue()); - applicationAlarmList.setSourceValue(((Number)source.get(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE)).intValue()); - - applicationAlarmList.setAlarmType(((Number)source.get(ApplicationAlarmListTable.COLUMN_ALARM_TYPE)).intValue()); - applicationAlarmList.setAlarmContent((String)source.get(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT)); - - applicationAlarmList.setTimeBucket(((Number)source.get(ApplicationAlarmListTable.COLUMN_TIME_BUCKET)).longValue()); - return applicationAlarmList; - } else { - return null; - } - } - - @Override public IndexRequestBuilder prepareBatchInsert(ApplicationAlarmList data) { - Map source = new HashMap<>(); - source.put(ApplicationAlarmListTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); - - source.put(ApplicationAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); - source.put(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); - - source.put(ApplicationAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareIndex(ApplicationAlarmListTable.TABLE, data.getId()).setSource(source); - } - - @Override public UpdateRequestBuilder prepareBatchUpdate(ApplicationAlarmList data) { - Map source = new HashMap<>(); - source.put(ApplicationAlarmListTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, data.getSourceValue()); - - source.put(ApplicationAlarmListTable.COLUMN_ALARM_TYPE, data.getAlarmType()); - source.put(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT, data.getAlarmContent()); - - source.put(ApplicationAlarmListTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); - - return getClient().prepareUpdate(ApplicationAlarmListTable.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(ApplicationAlarmListTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(ApplicationAlarmListTable.TABLE) - .get(); - - long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, ApplicationAlarmListTable.TABLE); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/AbstractApplicationAlarmListEsTableDefine.java similarity index 88% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListEsTableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/AbstractApplicationAlarmListEsTableDefine.java index d89582079..97eb5ea1a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/AbstractApplicationAlarmListEsTableDefine.java @@ -25,14 +25,10 @@ import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmL /** * @author peng-yongsheng */ -public class ApplicationAlarmListEsTableDefine extends ElasticSearchTableDefine { +public abstract class AbstractApplicationAlarmListEsTableDefine extends ElasticSearchTableDefine { - public ApplicationAlarmListEsTableDefine() { - super(ApplicationAlarmListTable.TABLE); - } - - @Override public int refreshInterval() { - return 2; + AbstractApplicationAlarmListEsTableDefine(String name) { + super(name); } @Override public void initialize() { diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListDayEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListDayEsTableDefine.java new file mode 100644 index 000000000..b27c60f88 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListDayEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.define.alarm; + +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.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListDayEsTableDefine extends AbstractApplicationAlarmListEsTableDefine { + + public ApplicationAlarmListDayEsTableDefine() { + super(ApplicationAlarmListTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListHourEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListHourEsTableDefine.java new file mode 100644 index 000000000..d5b20981a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListHourEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.define.alarm; + +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.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListHourEsTableDefine extends AbstractApplicationAlarmListEsTableDefine { + + public ApplicationAlarmListHourEsTableDefine() { + super(ApplicationAlarmListTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListMinuteEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListMinuteEsTableDefine.java new file mode 100644 index 000000000..6eb65ebab --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListMinuteEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.define.alarm; + +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.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListMinuteEsTableDefine extends AbstractApplicationAlarmListEsTableDefine { + + public ApplicationAlarmListMinuteEsTableDefine() { + super(ApplicationAlarmListTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListMonthEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListMonthEsTableDefine.java new file mode 100644 index 000000000..8d84017fb --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/ApplicationAlarmListMonthEsTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.define.alarm; + +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.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListMonthEsTableDefine extends AbstractApplicationAlarmListEsTableDefine { + + public ApplicationAlarmListMonthEsTableDefine() { + super(ApplicationAlarmListTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define index 725a4ceef..9b2442521 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define @@ -53,7 +53,12 @@ org.apache.skywalking.apm.collector.storage.es.define.SegmentEsTableDefine org.apache.skywalking.apm.collector.storage.es.define.SegmentDurationEsTableDefine org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmListEsTableDefine + +org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmListMinuteEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmListHourEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmListDayEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmListMonthEsTableDefine + org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationReferenceAlarmEsTableDefine org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationReferenceAlarmListEsTableDefine org.apache.skywalking.apm.collector.storage.es.define.alarm.InstanceAlarmEsTableDefine 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 55c3db8a0..da443c106 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 @@ -35,7 +35,10 @@ import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponent import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMonthPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListMonthPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmListPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationReferenceAlarmPersistenceDAO; @@ -135,7 +138,10 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.acp.ApplicationCompone import org.apache.skywalking.apm.collector.storage.h2.dao.acp.ApplicationComponentMinuteH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.acp.ApplicationComponentMonthH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.alarm.ApplicationAlarmH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.alarm.ApplicationAlarmListH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.alarm.ApplicationAlarmListH2DayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.alarm.ApplicationAlarmListH2HourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.alarm.ApplicationAlarmListH2MinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.alarm.ApplicationAlarmListH2MonthPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.alarm.ApplicationReferenceAlarmH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.alarm.ApplicationReferenceAlarmListH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.alarm.InstanceAlarmH2PersistenceDAO; @@ -405,6 +411,10 @@ public class StorageModuleH2Provider extends ModuleProvider { this.registerServiceImplementation(IInstanceAlarmPersistenceDAO.class, new InstanceAlarmH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IInstanceAlarmListPersistenceDAO.class, new InstanceAlarmListH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IApplicationAlarmPersistenceDAO.class, new ApplicationAlarmH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(IApplicationAlarmListPersistenceDAO.class, new ApplicationAlarmListH2PersistenceDAO(h2Client)); + + this.registerServiceImplementation(IApplicationAlarmListMinutePersistenceDAO.class, new ApplicationAlarmListH2MinutePersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationAlarmListHourPersistenceDAO.class, new ApplicationAlarmListH2HourPersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationAlarmListDayPersistenceDAO.class, new ApplicationAlarmListH2DayPersistenceDAO(h2Client)); + this.registerServiceImplementation(IApplicationAlarmListMonthPersistenceDAO.class, new ApplicationAlarmListH2MonthPersistenceDAO(h2Client)); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/AbstractApplicationAlarmListH2PersistenceDAO.java similarity index 78% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/AbstractApplicationAlarmListH2PersistenceDAO.java index 700698e42..f5e23daf6 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/AbstractApplicationAlarmListH2PersistenceDAO.java @@ -23,26 +23,20 @@ import java.sql.SQLException; import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.storage.dao.alarm.IApplicationAlarmListPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.AbstractPersistenceH2DAO; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; /** * @author peng-yongsheng */ -public class ApplicationAlarmListH2PersistenceDAO extends AbstractPersistenceH2DAO implements IApplicationAlarmListPersistenceDAO { +public abstract class AbstractApplicationAlarmListH2PersistenceDAO extends AbstractPersistenceH2DAO { - public ApplicationAlarmListH2PersistenceDAO(H2Client client) { + public AbstractApplicationAlarmListH2PersistenceDAO(H2Client client) { super(client); } - @Override protected String tableName() { - return ApplicationAlarmListTable.TABLE; - } - - @Override protected ApplicationAlarmList h2DataToStreamData(ResultSet resultSet) throws SQLException { + @Override protected final ApplicationAlarmList h2DataToStreamData(ResultSet resultSet) throws SQLException { ApplicationAlarmList applicationAlarmList = new ApplicationAlarmList(); applicationAlarmList.setId(resultSet.getString(ApplicationAlarmListTable.COLUMN_ID)); applicationAlarmList.setSourceValue(resultSet.getInt(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE)); @@ -57,7 +51,7 @@ public class ApplicationAlarmListH2PersistenceDAO extends AbstractPersistenceH2D return applicationAlarmList; } - @Override protected Map streamDataToH2Data(ApplicationAlarmList streamData) { + @Override protected final Map streamDataToH2Data(ApplicationAlarmList streamData) { Map source = new HashMap<>(); source.put(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, streamData.getSourceValue()); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2DayPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2DayPersistenceDAO.java new file mode 100644 index 000000000..c4aafee37 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2DayPersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.h2.dao.alarm; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +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.alarm.IApplicationAlarmListDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListH2DayPersistenceDAO extends AbstractApplicationAlarmListH2PersistenceDAO implements IApplicationAlarmListDayPersistenceDAO { + + public ApplicationAlarmListH2DayPersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationAlarmListTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2HourPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2HourPersistenceDAO.java new file mode 100644 index 000000000..7653b1ef5 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2HourPersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.h2.dao.alarm; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +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.alarm.IApplicationAlarmListHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListH2HourPersistenceDAO extends AbstractApplicationAlarmListH2PersistenceDAO implements IApplicationAlarmListHourPersistenceDAO { + + public ApplicationAlarmListH2HourPersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationAlarmListTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2MinutePersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2MinutePersistenceDAO.java new file mode 100644 index 000000000..6ae540d9a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2MinutePersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.h2.dao.alarm; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +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.alarm.IApplicationAlarmListMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListH2MinutePersistenceDAO extends AbstractApplicationAlarmListH2PersistenceDAO implements IApplicationAlarmListMinutePersistenceDAO { + + public ApplicationAlarmListH2MinutePersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationAlarmListTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2MonthPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2MonthPersistenceDAO.java new file mode 100644 index 000000000..bc09f0b6c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/ApplicationAlarmListH2MonthPersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.h2.dao.alarm; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +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.alarm.IApplicationAlarmListMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListH2MonthPersistenceDAO extends AbstractApplicationAlarmListH2PersistenceDAO implements IApplicationAlarmListMonthPersistenceDAO { + + public ApplicationAlarmListH2MonthPersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ApplicationAlarmListTable.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/define/alarm/ApplicationAlarmListH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/AbstractApplicationAlarmListH2TableDefine.java similarity index 91% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListH2TableDefine.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/AbstractApplicationAlarmListH2TableDefine.java index e54b7af13..65bc8902d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/AbstractApplicationAlarmListH2TableDefine.java @@ -25,10 +25,10 @@ import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmL /** * @author peng-yongsheng */ -public class ApplicationAlarmListH2TableDefine extends H2TableDefine { +public abstract class AbstractApplicationAlarmListH2TableDefine extends H2TableDefine { - public ApplicationAlarmListH2TableDefine() { - super(ApplicationAlarmListTable.TABLE); + AbstractApplicationAlarmListH2TableDefine(String name) { + super(name); } @Override public void initialize() { diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListDayH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListDayH2TableDefine.java new file mode 100644 index 000000000..2d79d633b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListDayH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.h2.define.alarm; + +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.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListDayH2TableDefine extends AbstractApplicationAlarmListH2TableDefine { + + public ApplicationAlarmListDayH2TableDefine() { + super(ApplicationAlarmListTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListHourH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListHourH2TableDefine.java new file mode 100644 index 000000000..f1e0242bf --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListHourH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.h2.define.alarm; + +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.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListHourH2TableDefine extends AbstractApplicationAlarmListH2TableDefine { + + public ApplicationAlarmListHourH2TableDefine() { + super(ApplicationAlarmListTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListMinuteH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListMinuteH2TableDefine.java new file mode 100644 index 000000000..d69724ad5 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListMinuteH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.h2.define.alarm; + +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.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListMinuteH2TableDefine extends AbstractApplicationAlarmListH2TableDefine { + + public ApplicationAlarmListMinuteH2TableDefine() { + super(ApplicationAlarmListTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListMonthH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListMonthH2TableDefine.java new file mode 100644 index 000000000..5c4e294db --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/alarm/ApplicationAlarmListMonthH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.h2.define.alarm; + +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.table.alarm.ApplicationAlarmListTable; + +/** + * @author peng-yongsheng + */ +public class ApplicationAlarmListMonthH2TableDefine extends AbstractApplicationAlarmListH2TableDefine { + + public ApplicationAlarmListMonthH2TableDefine() { + super(ApplicationAlarmListTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define index fdb2fd844..b99dbd23e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define @@ -77,7 +77,12 @@ org.apache.skywalking.apm.collector.storage.h2.define.srmp.ServiceReferenceDayMe org.apache.skywalking.apm.collector.storage.h2.define.srmp.ServiceReferenceMonthMetricH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationAlarmH2TableDefine -org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationAlarmListH2TableDefine + +org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationAlarmListMinuteH2TableDefine +org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationAlarmListHourH2TableDefine +org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationAlarmListDayH2TableDefine +org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationAlarmListMonthH2TableDefine + org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationReferenceAlarmH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationReferenceAlarmListH2TableDefine From 52c11398ae6f9557393cc2186bb400d04925a9cb Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Mon, 12 Feb 2018 13:58:26 +0800 Subject: [PATCH 2/2] Application metric alarm list graph. --- .../define/graph/AlarmWorkerIdDefine.java | 79 ++++++++++--------- .../ApplicationMetricAlarmGraph.java | 15 +++- .../ApplicationMetricAlarmListCopy.java | 40 ++++++++++ ...onMetricAlarmListDayPersistenceWorker.java | 66 ++++++++++++++++ ...cationMetricAlarmListDayTransformNode.java | 46 +++++++++++ ...nMetricAlarmListHourPersistenceWorker.java | 66 ++++++++++++++++ ...ationMetricAlarmListHourTransformNode.java | 46 +++++++++++ ...tricAlarmListMinutePersistenceWorker.java} | 12 +-- ...MetricAlarmListMonthPersistenceWorker.java | 66 ++++++++++++++++ ...tionMetricAlarmListMonthTransformNode.java | 46 +++++++++++ ...icationMetricAlarmToListNodeProcessor.java | 5 +- .../define/graph/MetricWorkerIdDefine.java | 10 --- .../table/alarm/ApplicationAlarmList.java | 21 ++--- ...tApplicationAlarmListEsPersistenceDAO.java | 9 +-- ...ractApplicationAlarmListEsTableDefine.java | 6 +- ...tApplicationAlarmListH2PersistenceDAO.java | 2 + 16 files changed, 461 insertions(+), 74 deletions(-) create mode 100644 apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListCopy.java create mode 100644 apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListDayPersistenceWorker.java create mode 100644 apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListDayTransformNode.java create mode 100644 apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListHourPersistenceWorker.java create mode 100644 apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListHourTransformNode.java rename apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/{ApplicationMetricAlarmListPersistenceWorker.java => ApplicationMetricAlarmListMinutePersistenceWorker.java} (81%) create mode 100644 apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListMonthPersistenceWorker.java create mode 100644 apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListMonthTransformNode.java diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/define/graph/AlarmWorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/define/graph/AlarmWorkerIdDefine.java index 0241473f6..d36427468 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/define/graph/AlarmWorkerIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-define/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/define/graph/AlarmWorkerIdDefine.java @@ -22,45 +22,52 @@ package org.apache.skywalking.apm.collector.analysis.alarm.define.graph; * @author peng-yongsheng */ public class AlarmWorkerIdDefine { - public static final int SERVICE_METRIC_ALARM_ASSERT_WORKER_ID = 500; - public static final int SERVICE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 501; - public static final int SERVICE_METRIC_ALARM_REMOTE_WORKER_ID = 502; - public static final int SERVICE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 503; - public static final int SERVICE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 504; - public static final int SERVICE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 505; + public static final int SERVICE_METRIC_ALARM_ASSERT_WORKER_ID = 5000; + public static final int SERVICE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 5001; + public static final int SERVICE_METRIC_ALARM_REMOTE_WORKER_ID = 5002; + public static final int SERVICE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 5003; + public static final int SERVICE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 5004; + public static final int SERVICE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 5005; - public static final int INSTANCE_METRIC_ALARM_ASSERT_WORKER_ID = 510; - public static final int INSTANCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 511; - public static final int INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID = 512; - public static final int INSTANCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 513; - public static final int INSTANCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 514; - public static final int INSTANCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 515; + public static final int INSTANCE_METRIC_ALARM_ASSERT_WORKER_ID = 5010; + public static final int INSTANCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 5011; + public static final int INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID = 5012; + public static final int INSTANCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 5013; + public static final int INSTANCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 5014; + public static final int INSTANCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 5015; - public static final int APPLICATION_METRIC_ALARM_ASSERT_WORKER_ID = 520; - public static final int APPLICATION_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 521; - public static final int APPLICATION_METRIC_ALARM_REMOTE_WORKER_ID = 522; - public static final int APPLICATION_METRIC_ALARM_PERSISTENCE_WORKER_ID = 523; - public static final int APPLICATION_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 524; - public static final int APPLICATION_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 525; + public static final int APPLICATION_METRIC_ALARM_ASSERT_WORKER_ID = 5020; + public static final int APPLICATION_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 5021; + public static final int APPLICATION_METRIC_ALARM_REMOTE_WORKER_ID = 5022; + public static final int APPLICATION_METRIC_ALARM_PERSISTENCE_WORKER_ID = 5023; + public static final int APPLICATION_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 5024; - public static final int SERVICE_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID = 530; - public static final int SERVICE_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 531; - public static final int SERVICE_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID = 532; - public static final int SERVICE_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 533; - public static final int SERVICE_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 534; - public static final int SERVICE_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 535; + public static final int SERVICE_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID = 5030; + public static final int SERVICE_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 5031; + public static final int SERVICE_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID = 5032; + public static final int SERVICE_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 5033; + public static final int SERVICE_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 5034; + public static final int SERVICE_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 5035; - public static final int INSTANCE_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID = 540; - public static final int INSTANCE_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 541; - public static final int INSTANCE_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID = 542; - public static final int INSTANCE_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 543; - public static final int INSTANCE_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 544; - public static final int INSTANCE_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 545; + public static final int INSTANCE_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID = 5040; + public static final int INSTANCE_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 5041; + public static final int INSTANCE_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID = 5042; + public static final int INSTANCE_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 5043; + public static final int INSTANCE_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 5044; + public static final int INSTANCE_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 5045; - public static final int APPLICATION_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID = 550; - public static final int APPLICATION_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 551; - public static final int APPLICATION_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID = 552; - public static final int APPLICATION_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 553; - public static final int APPLICATION_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 554; - public static final int APPLICATION_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 555; + public static final int APPLICATION_REFERENCE_METRIC_ALARM_ASSERT_WORKER_ID = 5050; + public static final int APPLICATION_REFERENCE_METRIC_ALARM_GRAPH_BRIDGE_WORKER_ID = 5051; + public static final int APPLICATION_REFERENCE_METRIC_ALARM_REMOTE_WORKER_ID = 5052; + public static final int APPLICATION_REFERENCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 5053; + public static final int APPLICATION_REFERENCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 5054; + public static final int APPLICATION_REFERENCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 5055; + + public static final int APPLICATION_METRIC_ALARM_LIST_MINUTE_PERSISTENCE_WORKER_ID = 5051; + public static final int APPLICATION_METRIC_ALARM_LIST_HOUR_PERSISTENCE_WORKER_ID = 5052; + public static final int APPLICATION_METRIC_ALARM_LIST_DAY_PERSISTENCE_WORKER_ID = 5053; + public static final int APPLICATION_METRIC_ALARM_LIST_MONTH_PERSISTENCE_WORKER_ID = 5054; + public static final int APPLICATION_METRIC_ALARM_LIST_HOUR_TRANSFORM_NODE_ID = 5055; + public static final int APPLICATION_METRIC_ALARM_LIST_DAY_TRANSFORM_NODE_ID = 5056; + public static final int APPLICATION_METRIC_ALARM_LIST_MONTH_TRANSFORM_NODE_ID = 5057; } 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/ApplicationMetricAlarmGraph.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmGraph.java index 0733dbab0..4963ad049 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmGraph.java @@ -31,6 +31,7 @@ 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.alarm.ApplicationAlarm; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; /** @@ -57,7 +58,19 @@ public class ApplicationMetricAlarmGraph { graph.toFinder().findNode(AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_REMOTE_WORKER_ID, ApplicationAlarm.class) .addNext(new ApplicationMetricAlarmToListNodeProcessor()) - .addNext(new ApplicationMetricAlarmListPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + .addNext(new ApplicationMetricAlarmListMinutePersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + graph.toFinder().findNode(AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_MINUTE_PERSISTENCE_WORKER_ID, ApplicationAlarmList.class) + .addNext(new ApplicationMetricAlarmListHourTransformNode()) + .addNext(new ApplicationMetricAlarmListHourPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + graph.toFinder().findNode(AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_MINUTE_PERSISTENCE_WORKER_ID, ApplicationAlarmList.class) + .addNext(new ApplicationMetricAlarmListDayTransformNode()) + .addNext(new ApplicationMetricAlarmListDayPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + graph.toFinder().findNode(AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_MINUTE_PERSISTENCE_WORKER_ID, ApplicationAlarmList.class) + .addNext(new ApplicationMetricAlarmListMonthTransformNode()) + .addNext(new ApplicationMetricAlarmListMonthPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); link(graph); } 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/ApplicationMetricAlarmListCopy.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListCopy.java new file mode 100644 index 000000000..70ca915fb --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListCopy.java @@ -0,0 +1,40 @@ +/* + * 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.alarm.provider.worker.application; + +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; + +/** + * @author peng-yongsheng + */ +public class ApplicationMetricAlarmListCopy { + + public static ApplicationAlarmList copy(ApplicationAlarmList applicationAlarmList) { + ApplicationAlarmList newApplicationAlarmList = new ApplicationAlarmList(); + newApplicationAlarmList.setId(applicationAlarmList.getId()); + newApplicationAlarmList.setMetricId(applicationAlarmList.getMetricId()); + + newApplicationAlarmList.setAlarmContent(applicationAlarmList.getAlarmContent()); + newApplicationAlarmList.setAlarmType(applicationAlarmList.getAlarmType()); + newApplicationAlarmList.setSourceValue(applicationAlarmList.getSourceValue()); + newApplicationAlarmList.setApplicationId(applicationAlarmList.getApplicationId()); + newApplicationAlarmList.setTimeBucket(newApplicationAlarmList.getTimeBucket()); + return newApplicationAlarmList; + } +} 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/ApplicationMetricAlarmListDayPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListDayPersistenceWorker.java new file mode 100644 index 000000000..1d08b2037 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListDayPersistenceWorker.java @@ -0,0 +1,66 @@ +/* + * 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.alarm.provider.worker.application; + +import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine; +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.alarm.IApplicationAlarmListDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; + +/** + * @author peng-yongsheng + */ +public class ApplicationMetricAlarmListDayPersistenceWorker extends PersistenceWorker { + + public ApplicationMetricAlarmListDayPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_DAY_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListDayPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationMetricAlarmListDayPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMetricAlarmListDayPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} 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/ApplicationMetricAlarmListDayTransformNode.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListDayTransformNode.java new file mode 100644 index 000000000..d79065b98 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListDayTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.alarm.provider.worker.application; + +import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine; +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.alarm.ApplicationAlarmList; + +/** + * @author peng-yongsheng + */ +public class ApplicationMetricAlarmListDayTransformNode implements NodeProcessor { + + @Override public int id() { + return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_DAY_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationAlarmList applicationAlarmList, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(applicationAlarmList.getTimeBucket()); + + ApplicationAlarmList newApplicationAlarmList = ApplicationMetricAlarmListCopy.copy(applicationAlarmList); + newApplicationAlarmList.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationAlarmList.getMetricId()); + newApplicationAlarmList.setTimeBucket(timeBucket); + next.execute(newApplicationAlarmList); + } +} 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/ApplicationMetricAlarmListHourPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListHourPersistenceWorker.java new file mode 100644 index 000000000..340844437 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListHourPersistenceWorker.java @@ -0,0 +1,66 @@ +/* + * 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.alarm.provider.worker.application; + +import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine; +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.alarm.IApplicationAlarmListHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; + +/** + * @author peng-yongsheng + */ +public class ApplicationMetricAlarmListHourPersistenceWorker extends PersistenceWorker { + + public ApplicationMetricAlarmListHourPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_HOUR_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListHourPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationMetricAlarmListHourPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMetricAlarmListHourPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} 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/ApplicationMetricAlarmListHourTransformNode.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListHourTransformNode.java new file mode 100644 index 000000000..9d8609048 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListHourTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.alarm.provider.worker.application; + +import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine; +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.alarm.ApplicationAlarmList; + +/** + * @author peng-yongsheng + */ +public class ApplicationMetricAlarmListHourTransformNode implements NodeProcessor { + + @Override public int id() { + return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_HOUR_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationAlarmList applicationAlarmList, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(applicationAlarmList.getTimeBucket()); + + ApplicationAlarmList newApplicationAlarmList = ApplicationMetricAlarmListCopy.copy(applicationAlarmList); + newApplicationAlarmList.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationAlarmList.getMetricId()); + newApplicationAlarmList.setTimeBucket(timeBucket); + next.execute(newApplicationAlarmList); + } +} 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/ApplicationMetricAlarmListPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListMinutePersistenceWorker.java similarity index 81% rename from apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListMinutePersistenceWorker.java index 191048b2e..114757202 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListMinutePersistenceWorker.java @@ -30,14 +30,14 @@ import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmL /** * @author peng-yongsheng */ -public class ApplicationMetricAlarmListPersistenceWorker extends PersistenceWorker { +public class ApplicationMetricAlarmListMinutePersistenceWorker extends PersistenceWorker { - public ApplicationMetricAlarmListPersistenceWorker(ModuleManager moduleManager) { + public ApplicationMetricAlarmListMinutePersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID; + return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_MINUTE_PERSISTENCE_WORKER_ID; } @Override protected boolean needMergeDBData() { @@ -49,13 +49,13 @@ public class ApplicationMetricAlarmListPersistenceWorker extends PersistenceWork return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListMinutePersistenceDAO.class); } - public static class Factory extends PersistenceWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public ApplicationMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new ApplicationMetricAlarmListPersistenceWorker(moduleManager); + @Override public ApplicationMetricAlarmListMinutePersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMetricAlarmListMinutePersistenceWorker(moduleManager); } @Override 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/ApplicationMetricAlarmListMonthPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListMonthPersistenceWorker.java new file mode 100644 index 000000000..fb8534e77 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListMonthPersistenceWorker.java @@ -0,0 +1,66 @@ +/* + * 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.alarm.provider.worker.application; + +import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine; +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.alarm.IApplicationAlarmListMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; + +/** + * @author peng-yongsheng + */ +public class ApplicationMetricAlarmListMonthPersistenceWorker extends PersistenceWorker { + + public ApplicationMetricAlarmListMonthPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_MONTH_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListMonthPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ApplicationMetricAlarmListMonthPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ApplicationMetricAlarmListMonthPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } +} 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/ApplicationMetricAlarmListMonthTransformNode.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListMonthTransformNode.java new file mode 100644 index 000000000..9bfb20413 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmListMonthTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.alarm.provider.worker.application; + +import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine; +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.alarm.ApplicationAlarmList; + +/** + * @author peng-yongsheng + */ +public class ApplicationMetricAlarmListMonthTransformNode implements NodeProcessor { + + @Override public int id() { + return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_MONTH_TRANSFORM_NODE_ID; + } + + @Override + public void process(ApplicationAlarmList applicationAlarmList, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(applicationAlarmList.getTimeBucket()); + + ApplicationAlarmList newApplicationAlarmList = ApplicationMetricAlarmListCopy.copy(applicationAlarmList); + newApplicationAlarmList.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + applicationAlarmList.getMetricId()); + newApplicationAlarmList.setTimeBucket(timeBucket); + next.execute(newApplicationAlarmList); + } +} 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/ApplicationMetricAlarmToListNodeProcessor.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmToListNodeProcessor.java index fbebedf06..de9e4a67f 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmToListNodeProcessor.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/application/ApplicationMetricAlarmToListNodeProcessor.java @@ -35,12 +35,15 @@ public class ApplicationMetricAlarmToListNodeProcessor implements NodeProcessor< } @Override public void process(ApplicationAlarm applicationAlarm, Next next) { - String id = applicationAlarm.getLastTimeBucket() + Const.ID_SPLIT + applicationAlarm.getSourceValue() + String metricId = applicationAlarm.getSourceValue() + Const.ID_SPLIT + applicationAlarm.getAlarmType() + Const.ID_SPLIT + applicationAlarm.getApplicationId(); + String id = applicationAlarm.getLastTimeBucket() + Const.ID_SPLIT + metricId; + ApplicationAlarmList applicationAlarmList = new ApplicationAlarmList(); applicationAlarmList.setId(id); + applicationAlarmList.setMetricId(metricId); applicationAlarmList.setApplicationId(applicationAlarm.getApplicationId()); applicationAlarmList.setSourceValue(applicationAlarm.getSourceValue()); applicationAlarmList.setAlarmType(applicationAlarm.getAlarmType()); 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 80e6d31c5..1b78839b0 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 @@ -52,16 +52,6 @@ public class MetricWorkerIdDefine { public static final int APPLICATION_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4037; public static final int APPLICATION_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4038; - public static final int SERVICE_MAPPING_MINUTE_AGGREGATION_WORKER_ID = 4040; - public static final int SERVICE_MAPPING_MINUTE_REMOTE_WORKER_ID = 4041; - public static final int SERVICE_MAPPING_MINUTE_PERSISTENCE_WORKER_ID = 4042; - public static final int SERVICE_MAPPING_HOUR_PERSISTENCE_WORKER_ID = 4043; - public static final int SERVICE_MAPPING_HOUR_TRANSFORM_NODE_ID = 4044; - public static final int SERVICE_MAPPING_DAY_PERSISTENCE_WORKER_ID = 4045; - public static final int SERVICE_MAPPING_DAY_TRANSFORM_NODE_ID = 4046; - public static final int SERVICE_MAPPING_MONTH_PERSISTENCE_WORKER_ID = 4047; - public static final int SERVICE_MAPPING_MONTH_TRANSFORM_NODE_ID = 4048; - public static final int SERVICE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4400; public static final int SERVICE_MINUTE_METRIC_REMOTE_WORKER_ID = 4401; public static final int SERVICE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4402; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmList.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmList.java index db8b935c7..2b68ab7d2 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmList.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/ApplicationAlarmList.java @@ -30,6 +30,7 @@ public class ApplicationAlarmList extends StreamData { private static final Column[] STRING_COLUMNS = { new Column(ApplicationAlarmListTable.COLUMN_ID, new NonOperation()), + new Column(ApplicationAlarmListTable.COLUMN_METRIC_ID, new NonOperation()), new Column(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT, new CoverOperation()), }; @@ -60,11 +61,19 @@ public class ApplicationAlarmList extends StreamData { } @Override public String getMetricId() { - return getId(); + return getDataString(1); } @Override public void setMetricId(String metricId) { - setId(metricId); + setDataString(1, metricId); + } + + public String getAlarmContent() { + return getDataString(2); + } + + public void setAlarmContent(String alarmContent) { + setDataString(2, alarmContent); } public Integer getAlarmType() { @@ -98,12 +107,4 @@ public class ApplicationAlarmList extends StreamData { public void setTimeBucket(Long timeBucket) { setDataLong(0, timeBucket); } - - public String getAlarmContent() { - return getDataString(1); - } - - public void setAlarmContent(String alarmContent) { - setDataString(1, alarmContent); - } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/AbstractApplicationAlarmListEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/AbstractApplicationAlarmListEsPersistenceDAO.java index f5698c7e1..f711d900d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/AbstractApplicationAlarmListEsPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/alarm/AbstractApplicationAlarmListEsPersistenceDAO.java @@ -24,17 +24,13 @@ import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchCli import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmList; import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmListTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ public abstract class AbstractApplicationAlarmListEsPersistenceDAO extends AbstractPersistenceEsDAO { - private final Logger logger = LoggerFactory.getLogger(AbstractApplicationAlarmListEsPersistenceDAO.class); - - public AbstractApplicationAlarmListEsPersistenceDAO(ElasticSearchClient client) { + AbstractApplicationAlarmListEsPersistenceDAO(ElasticSearchClient client) { super(client); } @@ -45,6 +41,7 @@ public abstract class AbstractApplicationAlarmListEsPersistenceDAO extends Abstr @Override protected final ApplicationAlarmList esDataToStreamData(Map source) { ApplicationAlarmList applicationAlarmList = new ApplicationAlarmList(); applicationAlarmList.setId((String)source.get(ApplicationAlarmListTable.COLUMN_ID)); + applicationAlarmList.setMetricId((String)source.get(ApplicationAlarmListTable.COLUMN_METRIC_ID)); applicationAlarmList.setApplicationId(((Number)source.get(ApplicationAlarmListTable.COLUMN_APPLICATION_ID)).intValue()); applicationAlarmList.setSourceValue(((Number)source.get(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE)).intValue()); @@ -57,7 +54,7 @@ public abstract class AbstractApplicationAlarmListEsPersistenceDAO extends Abstr @Override protected final Map esStreamDataToEsData(ApplicationAlarmList streamData) { Map source = new HashMap<>(); - source.put(ApplicationAlarmListTable.COLUMN_ID, streamData.getId()); + source.put(ApplicationAlarmListTable.COLUMN_METRIC_ID, streamData.getMetricId()); source.put(ApplicationAlarmListTable.COLUMN_APPLICATION_ID, streamData.getApplicationId()); source.put(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, streamData.getSourceValue()); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/AbstractApplicationAlarmListEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/AbstractApplicationAlarmListEsTableDefine.java index 97eb5ea1a..408328f46 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/AbstractApplicationAlarmListEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/alarm/AbstractApplicationAlarmListEsTableDefine.java @@ -32,13 +32,11 @@ public abstract class AbstractApplicationAlarmListEsTableDefine extends ElasticS } @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_ALARM_TYPE, ElasticSearchColumnDefine.Type.Integer.name())); - - addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_ALARM_CONTENT, ElasticSearchColumnDefine.Type.Text.name())); - addColumn(new ElasticSearchColumnDefine(ApplicationAlarmListTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/AbstractApplicationAlarmListH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/AbstractApplicationAlarmListH2PersistenceDAO.java index f5e23daf6..e99f70c1d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/AbstractApplicationAlarmListH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/alarm/AbstractApplicationAlarmListH2PersistenceDAO.java @@ -39,6 +39,7 @@ public abstract class AbstractApplicationAlarmListH2PersistenceDAO extends Abstr @Override protected final ApplicationAlarmList h2DataToStreamData(ResultSet resultSet) throws SQLException { ApplicationAlarmList applicationAlarmList = new ApplicationAlarmList(); applicationAlarmList.setId(resultSet.getString(ApplicationAlarmListTable.COLUMN_ID)); + applicationAlarmList.setMetricId(resultSet.getString(ApplicationAlarmListTable.COLUMN_METRIC_ID)); applicationAlarmList.setSourceValue(resultSet.getInt(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE)); applicationAlarmList.setAlarmType(resultSet.getInt(ApplicationAlarmListTable.COLUMN_ALARM_TYPE)); @@ -53,6 +54,7 @@ public abstract class AbstractApplicationAlarmListH2PersistenceDAO extends Abstr @Override protected final Map streamDataToH2Data(ApplicationAlarmList streamData) { Map source = new HashMap<>(); + source.put(ApplicationAlarmListTable.COLUMN_METRIC_ID, streamData.getMetricId()); source.put(ApplicationAlarmListTable.COLUMN_SOURCE_VALUE, streamData.getSourceValue()); source.put(ApplicationAlarmListTable.COLUMN_ALARM_TYPE, streamData.getAlarmType());