ApplicationDayMetricPersistenceWorker.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.metric;
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.amp.IApplicationDayMetricPersistenceDAO;
29
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric;
30
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetricTable;
P
peng-yongsheng 已提交
31 32 33 34

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

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

    @Override public int id() {
42
        return MetricWorkerIdDefine.APPLICATION_DAY_METRIC_PERSISTENCE_WORKER_ID;
P
peng-yongsheng 已提交
43 44
    }

P
peng-yongsheng 已提交
45 46
    @SuppressWarnings("unchecked")
    @Override protected IPersistenceDAO<?, ?, ApplicationMetric> persistenceDAO() {
47
        return getModuleManager().find(StorageModule.NAME).getService(IApplicationDayMetricPersistenceDAO.class);
P
peng-yongsheng 已提交
48 49
    }

P
peng-yongsheng 已提交
50 51
    @Override protected boolean needMergeDBData() {
        return true;
P
peng-yongsheng 已提交
52 53
    }

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

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

60 61
        @Override public ApplicationDayMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
            return new ApplicationDayMetricPersistenceWorker(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/" + ApplicationMetricTable.TABLE + "/day")
    @Override protected void onWork(ApplicationMetric input) {
        super.onWork(input);
    }
P
peng-yongsheng 已提交
74
}