AnalysisAlarmModuleProvider.java 5.0 KB
Newer Older
P
peng-yongsheng 已提交
1
/*
wu-sheng's avatar
wu-sheng 已提交
2 3 4 5 6 7
 * 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
P
peng-yongsheng 已提交
8 9 10 11 12 13 14 15 16 17 18
 *
 *     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.
 *
 */

19
package org.apache.skywalking.apm.collector.analysis.alarm.provider;
P
peng-yongsheng 已提交
20

21
import org.apache.skywalking.apm.collector.analysis.alarm.define.AnalysisAlarmModule;
22 23 24
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.application.*;
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.instance.*;
import org.apache.skywalking.apm.collector.analysis.alarm.provider.worker.service.*;
P
peng-yongsheng 已提交
25 26
import org.apache.skywalking.apm.collector.analysis.metric.define.AnalysisMetricModule;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
P
peng-yongsheng 已提交
27
import org.apache.skywalking.apm.collector.analysis.worker.timer.PersistenceTimer;
P
peng-yongsheng 已提交
28
import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
29
import org.apache.skywalking.apm.collector.core.module.*;
P
peng-yongsheng 已提交
30
import org.apache.skywalking.apm.collector.remote.RemoteModule;
31
import org.apache.skywalking.apm.collector.remote.service.RemoteDataRegisterService;
P
peng-yongsheng 已提交
32
import org.apache.skywalking.apm.collector.storage.StorageModule;
33
import org.apache.skywalking.apm.collector.storage.table.alarm.*;
P
peng-yongsheng 已提交
34 35 36 37

/**
 * @author peng-yongsheng
 */
P
peng-yongsheng 已提交
38
public class AnalysisAlarmModuleProvider extends ModuleProvider {
P
peng-yongsheng 已提交
39

40 41 42 43 44 45 46
    private final AnalysisAlarmModuleConfig config;

    public AnalysisAlarmModuleProvider() {
        super();
        this.config = new AnalysisAlarmModuleConfig();
    }

P
peng-yongsheng 已提交
47 48 49 50
    @Override public String name() {
        return "default";
    }

51
    @Override public Class<? extends ModuleDefine> module() {
52
        return AnalysisAlarmModule.class;
P
peng-yongsheng 已提交
53 54
    }

55 56 57
    @Override public ModuleConfig createConfigBeanIfAbsent() {
        return config;
    }
P
peng-yongsheng 已提交
58

59
    @Override public void prepare() {
P
peng-yongsheng 已提交
60 61
    }

62
    @Override public void start() {
P
peng-yongsheng 已提交
63 64
        WorkerCreateListener workerCreateListener = new WorkerCreateListener();

65 66 67 68 69 70
        new ServiceMetricAlarmGraph(getManager(), workerCreateListener).create();
        new InstanceMetricAlarmGraph(getManager(), workerCreateListener).create();
        new ApplicationMetricAlarmGraph(getManager(), workerCreateListener).create();
        new ServiceReferenceMetricAlarmGraph(getManager(), workerCreateListener).create();
        new InstanceReferenceMetricAlarmGraph(getManager(), workerCreateListener).create();
        new ApplicationReferenceMetricAlarmGraph(getManager(), workerCreateListener).create();
P
peng-yongsheng 已提交
71

72 73
        registerRemoteData();

彭勇升 pengys 已提交
74
        PersistenceTimer.INSTANCE.start(getManager(), workerCreateListener.getPersistenceWorkers());
P
peng-yongsheng 已提交
75 76
    }

77
    @Override public void notifyAfterCompleted() {
P
peng-yongsheng 已提交
78 79 80
    }

    @Override public String[] requiredModules() {
P
peng-yongsheng 已提交
81
        return new String[] {RemoteModule.NAME, AnalysisMetricModule.NAME, ConfigurationModule.NAME, StorageModule.NAME};
P
peng-yongsheng 已提交
82
    }
83 84 85 86 87

    private void registerRemoteData() {
        RemoteDataRegisterService remoteDataRegisterService = getManager().find(RemoteModule.NAME).getService(RemoteDataRegisterService.class);
        remoteDataRegisterService.register(ApplicationAlarm.class, new ApplicationAlarm.InstanceCreator());
        remoteDataRegisterService.register(ApplicationAlarmList.class, new ApplicationAlarmList.InstanceCreator());
彭勇升 pengys 已提交
88 89
        remoteDataRegisterService.register(ApplicationReferenceAlarm.class, new ApplicationReferenceAlarm.InstanceCreator());
        remoteDataRegisterService.register(ApplicationReferenceAlarmList.class, new ApplicationReferenceAlarmList.InstanceCreator());
90 91
        remoteDataRegisterService.register(InstanceAlarm.class, new InstanceAlarm.InstanceCreator());
        remoteDataRegisterService.register(InstanceAlarmList.class, new InstanceAlarmList.InstanceCreator());
彭勇升 pengys 已提交
92 93
        remoteDataRegisterService.register(InstanceReferenceAlarm.class, new InstanceReferenceAlarm.InstanceCreator());
        remoteDataRegisterService.register(InstanceReferenceAlarmList.class, new InstanceReferenceAlarmList.InstanceCreator());
94 95
        remoteDataRegisterService.register(ServiceAlarm.class, new ServiceAlarm.InstanceCreator());
        remoteDataRegisterService.register(ServiceAlarmList.class, new ServiceAlarmList.InstanceCreator());
彭勇升 pengys 已提交
96 97
        remoteDataRegisterService.register(ServiceReferenceAlarm.class, new ServiceReferenceAlarm.InstanceCreator());
        remoteDataRegisterService.register(ServiceReferenceAlarmList.class, new ServiceReferenceAlarmList.InstanceCreator());
98
    }
P
peng-yongsheng 已提交
99
}