ServiceMinuteMetricPersistenceWorker.java 3.1 KB
Newer Older
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
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.service.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 26
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.storage.StorageModule;
P
peng-yongsheng 已提交
27
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
28
import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMinuteMetricPersistenceDAO;
29
import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetric;
30
import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable;
31 32 33 34

/**
 * @author peng-yongsheng
 */
35
public class ServiceMinuteMetricPersistenceWorker extends MergePersistenceWorker<ServiceMetric> {
36

37
    private ServiceMinuteMetricPersistenceWorker(ModuleManager moduleManager) {
38 39 40 41
        super(moduleManager);
    }

    @Override public int id() {
42
        return MetricWorkerIdDefine.SERVICE_MINUTE_METRIC_PERSISTENCE_WORKER_ID;
43 44
    }

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

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

54
    public static class Factory extends MergePersistenceWorkerProvider<ServiceMetric, ServiceMinuteMetricPersistenceWorker> {
55

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

60 61
        @Override public ServiceMinuteMetricPersistenceWorker workerInstance(ModuleManager moduleManager) {
            return new ServiceMinuteMetricPersistenceWorker(moduleManager);
62 63 64 65 66 67 68
        }

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

    @GraphComputingMetric(name = "/persistence/onWork/" + ServiceMetricTable.TABLE + "/minute")
    @Override protected void onWork(ServiceMetric input) {
        super.onWork(input);
    }
74
}