ApplicationMappingHourPersistenceWorker.java 3.1 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.metric.provider.worker.application.mapping;
20

P
peng-yongsheng 已提交
21
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine;
22 23
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.MergePersistenceWorker;
import org.apache.skywalking.apm.collector.analysis.worker.model.impl.MergePersistenceWorkerProvider;
24
import org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric;
25
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
P
peng-yongsheng 已提交
26
import org.apache.skywalking.apm.collector.storage.StorageModule;
27
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
28
import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingHourPersistenceDAO;
29
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping;
30
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable;
P
peng-yongsheng 已提交
31 32 33 34

/**
 * @author peng-yongsheng
 */
35
public class ApplicationMappingHourPersistenceWorker extends MergePersistenceWorker<ApplicationMapping> {
P
peng-yongsheng 已提交
36

37
    private ApplicationMappingHourPersistenceWorker(ModuleManager moduleManager) {
P
peng-yongsheng 已提交
38
        super(moduleManager);
P
peng-yongsheng 已提交
39 40 41
    }

    @Override public int id() {
42
        return MetricWorkerIdDefine.APPLICATION_MAPPING_HOUR_PERSISTENCE_WORKER_ID;
P
peng-yongsheng 已提交
43 44 45 46 47 48
    }

    @Override protected boolean needMergeDBData() {
        return true;
    }

P
peng-yongsheng 已提交
49 50
    @SuppressWarnings("unchecked")
    @Override protected IPersistenceDAO<?, ?, ApplicationMapping> persistenceDAO() {
51
        return getModuleManager().find(StorageModule.NAME).getService(IApplicationMappingHourPersistenceDAO.class);
P
peng-yongsheng 已提交
52 53
    }

54
    public static class Factory extends MergePersistenceWorkerProvider<ApplicationMapping, ApplicationMappingHourPersistenceWorker> {
P
peng-yongsheng 已提交
55

P
peng-yongsheng 已提交
56 57
        public Factory(ModuleManager moduleManager) {
            super(moduleManager);
P
peng-yongsheng 已提交
58 59
        }

60 61
        @Override public ApplicationMappingHourPersistenceWorker workerInstance(ModuleManager moduleManager) {
            return new ApplicationMappingHourPersistenceWorker(moduleManager);
P
peng-yongsheng 已提交
62 63 64 65 66 67 68
        }

        @Override
        public int queueSize() {
            return 1024;
        }
    }
69 70 71 72 73

    @GraphComputingMetric(name = "/persistence/onWork/" + ApplicationMappingTable.TABLE + "/hour")
    @Override protected void onWork(ApplicationMapping input) {
        super.onWork(input);
    }
P
peng-yongsheng 已提交
74
}