Application metric alarm list graph.

This commit is contained in:
peng-yongsheng 2018-02-12 13:58:26 +08:00
parent 7ab59cb252
commit 52c11398ae
16 changed files with 461 additions and 74 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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<ApplicationAlarmList> {
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<?, ?, ApplicationAlarmList> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListDayPersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<ApplicationAlarmList, ApplicationMetricAlarmListDayPersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public ApplicationMetricAlarmListDayPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new ApplicationMetricAlarmListDayPersistenceWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}

View File

@ -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<ApplicationAlarmList, ApplicationAlarmList> {
@Override public int id() {
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_DAY_TRANSFORM_NODE_ID;
}
@Override
public void process(ApplicationAlarmList applicationAlarmList, Next<ApplicationAlarmList> 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);
}
}

View File

@ -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<ApplicationAlarmList> {
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<?, ?, ApplicationAlarmList> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListHourPersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<ApplicationAlarmList, ApplicationMetricAlarmListHourPersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public ApplicationMetricAlarmListHourPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new ApplicationMetricAlarmListHourPersistenceWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}

View File

@ -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<ApplicationAlarmList, ApplicationAlarmList> {
@Override public int id() {
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_HOUR_TRANSFORM_NODE_ID;
}
@Override
public void process(ApplicationAlarmList applicationAlarmList, Next<ApplicationAlarmList> 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);
}
}

View File

@ -30,14 +30,14 @@ import org.apache.skywalking.apm.collector.storage.table.alarm.ApplicationAlarmL
/**
* @author peng-yongsheng
*/
public class ApplicationMetricAlarmListPersistenceWorker extends PersistenceWorker<ApplicationAlarmList> {
public class ApplicationMetricAlarmListMinutePersistenceWorker extends PersistenceWorker<ApplicationAlarmList> {
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<ApplicationAlarmList, ApplicationMetricAlarmListPersistenceWorker> {
public static class Factory extends PersistenceWorkerProvider<ApplicationAlarmList, ApplicationMetricAlarmListMinutePersistenceWorker> {
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

View File

@ -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<ApplicationAlarmList> {
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<?, ?, ApplicationAlarmList> persistenceDAO() {
return getModuleManager().find(StorageModule.NAME).getService(IApplicationAlarmListMonthPersistenceDAO.class);
}
public static class Factory extends PersistenceWorkerProvider<ApplicationAlarmList, ApplicationMetricAlarmListMonthPersistenceWorker> {
public Factory(ModuleManager moduleManager) {
super(moduleManager);
}
@Override public ApplicationMetricAlarmListMonthPersistenceWorker workerInstance(ModuleManager moduleManager) {
return new ApplicationMetricAlarmListMonthPersistenceWorker(moduleManager);
}
@Override
public int queueSize() {
return 1024;
}
}
}

View File

@ -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<ApplicationAlarmList, ApplicationAlarmList> {
@Override public int id() {
return AlarmWorkerIdDefine.APPLICATION_METRIC_ALARM_LIST_MONTH_TRANSFORM_NODE_ID;
}
@Override
public void process(ApplicationAlarmList applicationAlarmList, Next<ApplicationAlarmList> 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);
}
}

View File

@ -35,12 +35,15 @@ public class ApplicationMetricAlarmToListNodeProcessor implements NodeProcessor<
}
@Override public void process(ApplicationAlarm applicationAlarm, Next<ApplicationAlarmList> 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());

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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<ApplicationAlarmList> {
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<String, Object> 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<String, Object> esStreamDataToEsData(ApplicationAlarmList streamData) {
Map<String, Object> 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());

View File

@ -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()));
}
}

View File

@ -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<String, Object> streamDataToH2Data(ApplicationAlarmList streamData) {
Map<String, Object> 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());