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 bc7c8c34b..dbd912b1f 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 @@ -29,8 +29,13 @@ public class AlarmWorkerIdDefine { public static final int SERVICE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 500; public static final int SERVICE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 500; - public static final int INSTANCE_METRIC_TRANSFORM_WORKER_ID = 502; - public static final int INSTANCE_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 503; + public static final int INSTANCE_METRIC_ALARM_ASSERT_WORKER_ID = 500; + public static final int INSTANCE_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 501; + public static final int INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID = 500; + public static final int INSTANCE_METRIC_ALARM_PERSISTENCE_WORKER_ID = 500; + public static final int INSTANCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID = 500; + public static final int INSTANCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID = 500; + public static final int APPLICATION_METRIC_TRANSFORM_WORKER_ID = 504; public static final int APPLICATION_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID = 505; public static final int ALARM_METRIC_REMOTE_WORKER_ID = 506; diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/AnalysisAlarmModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/AnalysisAlarmModuleProvider.java index fb45aac90..612ac331e 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/AnalysisAlarmModuleProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/AnalysisAlarmModuleProvider.java @@ -21,7 +21,7 @@ package org.apache.skywalking.apm.collector.analysis.alarm.provider; import java.util.Properties; import org.apache.skywalking.apm.collector.analysis.alarm.define.AnalysisAlarmModule; import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.ApplicationMetricTransformGraph; -import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.InstanceMetricTransformGraph; +import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.instance.InstanceMetricAlarmGraph; import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.service.ServiceMetricAlarmGraph; import org.apache.skywalking.apm.collector.analysis.metric.define.AnalysisMetricModule; import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener; @@ -30,6 +30,7 @@ import org.apache.skywalking.apm.collector.core.module.Module; import org.apache.skywalking.apm.collector.core.module.ModuleProvider; import org.apache.skywalking.apm.collector.core.module.ServiceNotProvidedException; import org.apache.skywalking.apm.collector.remote.RemoteModule; +import org.apache.skywalking.apm.collector.storage.StorageModule; /** * @author peng-yongsheng @@ -54,8 +55,8 @@ public class AnalysisAlarmModuleProvider extends ModuleProvider { ServiceMetricAlarmGraph serviceMetricAlarmGraph = new ServiceMetricAlarmGraph(getManager(), workerCreateListener); serviceMetricAlarmGraph.create(); - InstanceMetricTransformGraph instanceMetricTransformGraph = new InstanceMetricTransformGraph(getManager(), workerCreateListener); - instanceMetricTransformGraph.create(); + InstanceMetricAlarmGraph instanceMetricAlarmGraph = new InstanceMetricAlarmGraph(getManager(), workerCreateListener); + instanceMetricAlarmGraph.create(); ApplicationMetricTransformGraph applicationMetricTransformGraph = new ApplicationMetricTransformGraph(getManager(), workerCreateListener); applicationMetricTransformGraph.create(); @@ -67,6 +68,6 @@ public class AnalysisAlarmModuleProvider extends ModuleProvider { } @Override public String[] requiredModules() { - return new String[] {RemoteModule.NAME, AnalysisMetricModule.NAME, ConfigurationModule.NAME}; + return new String[] {RemoteModule.NAME, AnalysisMetricModule.NAME, ConfigurationModule.NAME, StorageModule.NAME}; } } diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/InstanceMetricTransformWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/InstanceMetricTransformWorker.java deleted file mode 100644 index 8f396ca09..000000000 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/InstanceMetricTransformWorker.java +++ /dev/null @@ -1,84 +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.analysis.alarm.provider.worker; - -import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine; -import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; -import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.storage.table.alarm.AlarmMetric; -import org.apache.skywalking.apm.collector.storage.table.alarm.Layer; -import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; - -/** - * @author peng-yongsheng - */ -public class InstanceMetricTransformWorker extends AggregationWorker { - - public InstanceMetricTransformWorker(ModuleManager moduleManager) { - super(moduleManager); - } - - @Override public int id() { - return AlarmWorkerIdDefine.INSTANCE_METRIC_TRANSFORM_WORKER_ID; - } - - @Override protected AlarmMetric transform(InstanceMetric instanceMetric) { - - AlarmMetric alarmMetric = new AlarmMetric(String.valueOf(instanceMetric.getApplicationId())); - alarmMetric.setLayer(Layer.INSTANCE.getValue()); - alarmMetric.setObjectId(instanceMetric.getApplicationId()); - alarmMetric.setApplicationId(instanceMetric.getApplicationId()); - alarmMetric.setSourceValue(instanceMetric.getSourceValue()); - - alarmMetric.setTransactionCalls(instanceMetric.getTransactionCalls()); - alarmMetric.setTransactionDurationSum(instanceMetric.getTransactionDurationSum()); - alarmMetric.setTransactionErrorCalls(instanceMetric.getTransactionErrorCalls()); - alarmMetric.setTransactionErrorDurationSum(instanceMetric.getTransactionErrorDurationSum()); - - alarmMetric.setBusinessTransactionCalls(instanceMetric.getBusinessTransactionCalls()); - alarmMetric.setBusinessTransactionDurationSum(instanceMetric.getBusinessTransactionDurationSum()); - alarmMetric.setBusinessTransactionErrorCalls(instanceMetric.getBusinessTransactionErrorCalls()); - alarmMetric.setBusinessTransactionErrorDurationSum(instanceMetric.getBusinessTransactionErrorDurationSum()); - - alarmMetric.setMqTransactionCalls(instanceMetric.getMqTransactionCalls()); - alarmMetric.setMqTransactionDurationSum(instanceMetric.getMqTransactionDurationSum()); - alarmMetric.setMqTransactionErrorCalls(instanceMetric.getMqTransactionErrorCalls()); - alarmMetric.setMqTransactionErrorDurationSum(instanceMetric.getMqTransactionErrorDurationSum()); - - alarmMetric.setTimeBucket(instanceMetric.getTimeBucket()); - return alarmMetric; - } - - public static class Factory extends AbstractLocalAsyncWorkerProvider { - - public Factory(ModuleManager moduleManager) { - super(moduleManager); - } - - @Override public InstanceMetricTransformWorker workerInstance(ModuleManager moduleManager) { - return new InstanceMetricTransformWorker(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/instance/InstanceMetricAlarmAssertWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmAssertWorker.java new file mode 100644 index 000000000..616518d42 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmAssertWorker.java @@ -0,0 +1,85 @@ +/* + * 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.instance; + +import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorker; +import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.AlarmAssertWorkerProvider; +import org.apache.skywalking.apm.collector.configuration.ConfigurationModule; +import org.apache.skywalking.apm.collector.configuration.service.IInstanceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; + +/** + * @author peng-yongsheng + */ +public class InstanceMetricAlarmAssertWorker extends AlarmAssertWorker { + + private final IInstanceAlarmRuleConfig instanceAlarmRuleConfig; + + public InstanceMetricAlarmAssertWorker(ModuleManager moduleManager) { + super(moduleManager); + this.instanceAlarmRuleConfig = moduleManager.find(ConfigurationModule.NAME).getService(IInstanceAlarmRuleConfig.class); + } + + @Override public int id() { + return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_ASSERT_WORKER_ID; + } + + @Override protected InstanceAlarm newAlarmObject(String id, InstanceMetric inputMetric) { + InstanceAlarm instanceAlarm = new InstanceAlarm(id + Const.ID_SPLIT + inputMetric.getInstanceId()); + instanceAlarm.setApplicationId(inputMetric.getApplicationId()); + instanceAlarm.setInstanceId(inputMetric.getInstanceId()); + return instanceAlarm; + } + + @Override protected Double calleeErrorRateThreshold() { + return instanceAlarmRuleConfig.calleeErrorRateThreshold(); + } + + @Override protected Double callerErrorRateThreshold() { + return instanceAlarmRuleConfig.callerErrorRateThreshold(); + } + + @Override protected Double calleeAverageResponseTimeThreshold() { + return instanceAlarmRuleConfig.calleeAverageResponseTimeThreshold(); + } + + @Override protected Double callerAverageResponseTimeThreshold() { + return instanceAlarmRuleConfig.callerAverageResponseTimeThreshold(); + } + + public static class Factory extends AlarmAssertWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMetricAlarmAssertWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMetricAlarmAssertWorker(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/InstanceMetricTransformGraph.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmGraph.java similarity index 69% rename from apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/InstanceMetricTransformGraph.java rename to apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmGraph.java index 6ee996aee..7fcb54f39 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/InstanceMetricTransformGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmGraph.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker; +package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.instance; import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmGraphIdDefine; import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine; @@ -28,32 +28,43 @@ import org.apache.skywalking.apm.collector.core.graph.GraphManager; import org.apache.skywalking.apm.collector.core.graph.Next; import org.apache.skywalking.apm.collector.core.graph.NodeProcessor; import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.remote.RemoteModule; +import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; /** * @author peng-yongsheng */ -public class InstanceMetricTransformGraph { +public class InstanceMetricAlarmGraph { private final ModuleManager moduleManager; private final WorkerCreateListener workerCreateListener; - public InstanceMetricTransformGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) { + public InstanceMetricAlarmGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) { this.moduleManager = moduleManager; this.workerCreateListener = workerCreateListener; } public void create() { + RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); + Graph graph = GraphManager.INSTANCE.createIfAbsent(AlarmGraphIdDefine.INSTANCE_METRIC_TRANSFORM_GRAPH_ID, InstanceMetric.class); - graph.addNode(new InstanceMetricTransformWorker.Factory(moduleManager).create(workerCreateListener)); + graph.addNode(new InstanceMetricAlarmAssertWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new InstanceMetricAlarmRemoteWorker.Factory(moduleManager, remoteSenderService, AlarmGraphIdDefine.INSTANCE_METRIC_TRANSFORM_GRAPH_ID).create(workerCreateListener)) + .addNext(new InstanceMetricAlarmPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + graph.toFinder().findNode(AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID, InstanceAlarm.class) + .addNext(new InstanceMetricAlarmToListNodeProcessor()) + .addNext(new InstanceMetricAlarmListPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); link(graph); } private void link(Graph graph) { GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.INSTANCE_METRIC_GRAPH_ID, InstanceMetric.class) - .toFinder().findNode(MetricWorkerIdDefine.INSTANCE_METRIC_AGGREGATION_WORKER_ID, InstanceMetric.class) + .toFinder().findNode(MetricWorkerIdDefine.INSTANCE_METRIC_PERSISTENCE_WORKER_ID, InstanceMetric.class) .addNext(new NodeProcessor() { @Override public int id() { return AlarmWorkerIdDefine.INSTANCE_METRIC_TRANSFORM_GRAPH_BRIDGE_WORKER_ID; diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmListPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmListPersistenceWorker.java new file mode 100644 index 000000000..4cf9824c3 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmListPersistenceWorker.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.instance; + +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.IInstanceAlarmListPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmList; + +/** + * @author peng-yongsheng + */ +public class InstanceMetricAlarmListPersistenceWorker extends PersistenceWorker { + + public InstanceMetricAlarmListPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_LIST_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceAlarmListPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMetricAlarmListPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMetricAlarmListPersistenceWorker(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/instance/InstanceMetricAlarmPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmPersistenceWorker.java new file mode 100644 index 000000000..ca8383908 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmPersistenceWorker.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.instance; + +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.IInstanceAlarmPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm; + +/** + * @author peng-yongsheng + */ +public class InstanceMetricAlarmPersistenceWorker extends PersistenceWorker { + + public InstanceMetricAlarmPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IInstanceAlarmPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public InstanceMetricAlarmPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMetricAlarmPersistenceWorker(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/instance/InstanceMetricAlarmRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmRemoteWorker.java new file mode 100644 index 000000000..0edad65d6 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmRemoteWorker.java @@ -0,0 +1,61 @@ +/* + * 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.instance; + +import org.apache.skywalking.apm.collector.analysis.alarm.define.graph.AlarmWorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; +import org.apache.skywalking.apm.collector.remote.service.Selector; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm; + +/** + * @author peng-yongsheng + */ +public class InstanceMetricAlarmRemoteWorker extends AbstractRemoteWorker { + + public InstanceMetricAlarmRemoteWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_REMOTE_WORKER_ID; + } + + @Override public Selector selector() { + return Selector.HashCode; + } + + @Override protected void onWork(InstanceAlarm message) throws WorkerException { + onNext(message); + } + + public static class Factory extends AbstractRemoteWorkerProvider { + + public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { + super(moduleManager, remoteSenderService, graphId); + } + + @Override public InstanceMetricAlarmRemoteWorker workerInstance(ModuleManager moduleManager) { + return new InstanceMetricAlarmRemoteWorker(moduleManager); + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmToListNodeProcessor.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmToListNodeProcessor.java new file mode 100644 index 000000000..0c9f5c0a4 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/instance/InstanceMetricAlarmToListNodeProcessor.java @@ -0,0 +1,51 @@ +/* + * 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.instance; + +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.storage.table.alarm.InstanceAlarm; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmList; + +/** + * @author peng-yongsheng + */ +public class InstanceMetricAlarmToListNodeProcessor implements NodeProcessor { + + @Override public int id() { + return AlarmWorkerIdDefine.INSTANCE_METRIC_ALARM_TO_LIST_NODE_PROCESSOR_ID; + } + + @Override public void process(InstanceAlarm instanceAlarm, Next next) { + String id = instanceAlarm.getLastTimeBucket() + Const.ID_SPLIT + instanceAlarm.getSourceValue() + + Const.ID_SPLIT + instanceAlarm.getAlarmType() + + Const.ID_SPLIT + instanceAlarm.getInstanceId(); + + InstanceAlarmList instanceAlarmList = new InstanceAlarmList(id); + instanceAlarmList.setApplicationId(instanceAlarm.getApplicationId()); + instanceAlarmList.setInstanceId(instanceAlarm.getInstanceId()); + instanceAlarmList.setSourceValue(instanceAlarm.getSourceValue()); + instanceAlarmList.setAlarmType(instanceAlarm.getAlarmType()); + instanceAlarmList.setTimeBucket(instanceAlarm.getLastTimeBucket()); + instanceAlarmList.setAlarmContent(instanceAlarm.getAlarmContent()); + next.execute(instanceAlarmList); + } +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java index 566da4f7f..cea2d7229 100644 --- a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java +++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModule.java @@ -19,6 +19,7 @@ package org.apache.skywalking.apm.collector.configuration; import org.apache.skywalking.apm.collector.configuration.service.IApdexThresholdService; +import org.apache.skywalking.apm.collector.configuration.service.IInstanceAlarmRuleConfig; import org.apache.skywalking.apm.collector.configuration.service.IServiceAlarmRuleConfig; import org.apache.skywalking.apm.collector.core.module.Module; @@ -34,6 +35,6 @@ public class ConfigurationModule extends Module { } @Override public Class[] services() { - return new Class[] {IApdexThresholdService.class, IServiceAlarmRuleConfig.class}; + return new Class[] {IApdexThresholdService.class, IServiceAlarmRuleConfig.class, IInstanceAlarmRuleConfig.class}; } } diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IInstanceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IInstanceAlarmRuleConfig.java new file mode 100644 index 000000000..b53ccaeac --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IInstanceAlarmRuleConfig.java @@ -0,0 +1,34 @@ +/* + * 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.configuration.service; + +import org.apache.skywalking.apm.collector.core.module.Service; + +/** + * @author peng-yongsheng + */ +public interface IInstanceAlarmRuleConfig extends Service { + double calleeErrorRateThreshold(); + + double calleeAverageResponseTimeThreshold(); + + double callerErrorRateThreshold(); + + double callerAverageResponseTimeThreshold(); +} diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java index 7e5e5c41f..a2fa50e46 100644 --- a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java +++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/ConfigurationModuleProvider.java @@ -21,7 +21,9 @@ package org.apache.skywalking.apm.collector.configuration; import java.util.Properties; import org.apache.skywalking.apm.collector.configuration.service.ApdexThresholdService; import org.apache.skywalking.apm.collector.configuration.service.IApdexThresholdService; +import org.apache.skywalking.apm.collector.configuration.service.IInstanceAlarmRuleConfig; import org.apache.skywalking.apm.collector.configuration.service.IServiceAlarmRuleConfig; +import org.apache.skywalking.apm.collector.configuration.service.InstanceAlarmRuleConfig; import org.apache.skywalking.apm.collector.configuration.service.ServiceAlarmRuleConfig; import org.apache.skywalking.apm.collector.core.module.Module; import org.apache.skywalking.apm.collector.core.module.ModuleProvider; @@ -43,6 +45,7 @@ public class ConfigurationModuleProvider extends ModuleProvider { @Override public void prepare(Properties config) throws ServiceNotProvidedException { this.registerServiceImplementation(IApdexThresholdService.class, new ApdexThresholdService()); this.registerServiceImplementation(IServiceAlarmRuleConfig.class, new ServiceAlarmRuleConfig()); + this.registerServiceImplementation(IInstanceAlarmRuleConfig.class, new InstanceAlarmRuleConfig()); } @Override public void start(Properties config) throws ServiceNotProvidedException { diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InstanceAlarmRuleConfig.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InstanceAlarmRuleConfig.java new file mode 100644 index 000000000..f7022729e --- /dev/null +++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/InstanceAlarmRuleConfig.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.configuration.service; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmRuleConfig implements IInstanceAlarmRuleConfig { + + @Override public double calleeErrorRateThreshold() { + return 10.00; + } + + @Override public double calleeAverageResponseTimeThreshold() { + return 2000; + } + + @Override public double callerErrorRateThreshold() { + return 10.00; + } + + @Override public double callerAverageResponseTimeThreshold() { + return 3000; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceAlarmListPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceAlarmListPersistenceDAO.java new file mode 100644 index 000000000..9b28b6f1a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceAlarmListPersistenceDAO.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; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarmList; + +/** + * @author peng-yongsheng + */ +public interface IInstanceAlarmListPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceAlarmPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceAlarmPersistenceDAO.java new file mode 100644 index 000000000..842cc5c6d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceAlarmPersistenceDAO.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; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.alarm.InstanceAlarm; + +/** + * @author peng-yongsheng + */ +public interface IInstanceAlarmPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarm.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarm.java new file mode 100644 index 000000000..40eb96b97 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarm.java @@ -0,0 +1,112 @@ +/* + * 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.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarm extends Data implements Alarm { + + private static final Column[] STRING_COLUMNS = { + new Column(InstanceAlarmTable.COLUMN_ID, new NonOperation()), + new Column(InstanceAlarmTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(InstanceAlarmTable.COLUMN_LAST_TIME_BUCKET, new CoverOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(InstanceAlarmTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(InstanceAlarmTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(InstanceAlarmTable.COLUMN_APPLICATION_ID, new NonOperation()), + new Column(InstanceAlarmTable.COLUMN_INSTANCE_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public InstanceAlarm(String id) { + super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + @Override + public Integer getAlarmType() { + return getDataInteger(0); + } + + @Override + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + @Override + public Integer getSourceValue() { + return getDataInteger(1); + } + + @Override + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getApplicationId() { + return getDataInteger(2); + } + + public void setApplicationId(Integer applicationId) { + setDataInteger(2, applicationId); + } + + public Integer getInstanceId() { + return getDataInteger(3); + } + + public void setInstanceId(Integer instanceId) { + setDataInteger(3, instanceId); + } + + @Override + public Long getLastTimeBucket() { + return getDataLong(0); + } + + @Override + public void setLastTimeBucket(Long lastTimeBucket) { + setDataLong(0, lastTimeBucket); + } + + @Override + public String getAlarmContent() { + return getDataString(1); + } + + @Override + public void setAlarmContent(String alarmContent) { + setDataString(1, alarmContent); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmList.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmList.java new file mode 100644 index 000000000..3516842e5 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmList.java @@ -0,0 +1,104 @@ +/* + * 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.table.alarm; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.Data; +import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmList extends Data { + + private static final Column[] STRING_COLUMNS = { + new Column(InstanceAlarmListTable.COLUMN_ID, new NonOperation()), + new Column(InstanceAlarmListTable.COLUMN_ALARM_CONTENT, new CoverOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(InstanceAlarmListTable.COLUMN_TIME_BUCKET, new NonOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(InstanceAlarmListTable.COLUMN_ALARM_TYPE, new NonOperation()), + new Column(InstanceAlarmListTable.COLUMN_SOURCE_VALUE, new NonOperation()), + new Column(InstanceAlarmListTable.COLUMN_APPLICATION_ID, new NonOperation()), + new Column(InstanceAlarmListTable.COLUMN_INSTANCE_ID, new NonOperation()), + }; + + private static final Column[] BOOLEAN_COLUMNS = {}; + + private static final Column[] BYTE_COLUMNS = {}; + + public InstanceAlarmList(String id) { + super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS); + } + + public Integer getAlarmType() { + return getDataInteger(0); + } + + public void setAlarmType(Integer alarmType) { + setDataInteger(0, alarmType); + } + + public Integer getSourceValue() { + return getDataInteger(1); + } + + public void setSourceValue(Integer sourceValue) { + setDataInteger(1, sourceValue); + } + + public Integer getApplicationId() { + return getDataInteger(2); + } + + public void setApplicationId(Integer applicationId) { + setDataInteger(2, applicationId); + } + + public Integer getInstanceId() { + return getDataInteger(3); + } + + public void setInstanceId(Integer instanceId) { + setDataInteger(3, instanceId); + } + + public Long getTimeBucket() { + return getDataLong(0); + } + + 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-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmListTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmListTable.java new file mode 100644 index 000000000..a7cd8817e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmListTable.java @@ -0,0 +1,30 @@ +/* + * 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.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmListTable extends CommonMetricTable { + public static final String TABLE = "instance_alarm_list"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmTable.java new file mode 100644 index 000000000..54c22cd0b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/alarm/InstanceAlarmTable.java @@ -0,0 +1,31 @@ +/* + * 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.table.alarm; + +import org.apache.skywalking.apm.collector.storage.table.CommonMetricTable; + +/** + * @author peng-yongsheng + */ +public class InstanceAlarmTable extends CommonMetricTable { + public static final String TABLE = "instance_alarm"; + public static final String COLUMN_ALARM_TYPE = "alarm_type"; + public static final String COLUMN_LAST_TIME_BUCKET = "last_time_bucket"; + public static final String COLUMN_ALARM_CONTENT = "alarm_content"; +}