Commit 307bd4c2 authored by 彭勇升 pengys's avatar 彭勇升 pengys Committed by 吴晟
Browse files

#1291 (#1294)

Block streaming, mandatory persistent cache data to storage then clean the cache data.
parent a960272f
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -20,12 +20,13 @@ package org.apache.skywalking.apm.collector.analysis.worker.model.impl;

import java.util.*;
import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorker;
import org.apache.skywalking.apm.collector.configuration.ConfigurationModule;
import org.apache.skywalking.apm.collector.configuration.service.IWorkerCacheSizeConfig;
import org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric;
import org.apache.skywalking.apm.collector.core.cache.Collection;
import org.apache.skywalking.apm.collector.core.cache.*;
import org.apache.skywalking.apm.collector.core.data.StreamData;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.StringUtils;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.base.dao.*;
import org.slf4j.*;
@@ -43,12 +44,7 @@ public abstract class PersistenceWorker<INPUT_AND_OUTPUT extends StreamData, COL
    PersistenceWorker(ModuleManager moduleManager) {
        super(moduleManager);
        this.batchDAO = moduleManager.find(StorageModule.NAME).getService(IBatchDAO.class);

        if (StringUtils.isNotEmpty(System.getProperty("batchSize"))) {
            this.blockBatchPersistenceSize = Integer.valueOf(System.getProperty("batchSize"));
        } else {
            this.blockBatchPersistenceSize = 500000;
        }
        this.blockBatchPersistenceSize = moduleManager.find(ConfigurationModule.NAME).getService(IWorkerCacheSizeConfig.class).cacheSize();
    }

    public boolean flushAndSwitch() {
+3 −1
Original line number Diff line number Diff line
@@ -92,3 +92,5 @@ configuration:
# thermodynamic
    thermodynamicResponseTimeStep: 50
    thermodynamicCountOfResponseTimeSteps: 40
# max collection's size of worker cache collection, setting it smaller when collector OutOfMemory crashed.
    workerCacheMaxSize: 10000
 No newline at end of file
+2 −11
Original line number Diff line number Diff line
@@ -18,16 +18,7 @@

package org.apache.skywalking.apm.collector.configuration;

import org.apache.skywalking.apm.collector.configuration.service.IApdexThresholdService;
import org.apache.skywalking.apm.collector.configuration.service.IApplicationAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IApplicationReferenceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.ICollectorConfig;
import org.apache.skywalking.apm.collector.configuration.service.IComponentLibraryCatalogService;
import org.apache.skywalking.apm.collector.configuration.service.IInstanceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IInstanceReferenceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IResponseTimeDistributionConfigService;
import org.apache.skywalking.apm.collector.configuration.service.IServiceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.IServiceReferenceAlarmRuleConfig;
import org.apache.skywalking.apm.collector.configuration.service.*;
import org.apache.skywalking.apm.collector.core.module.ModuleDefine;

/**
@@ -47,6 +38,6 @@ public class ConfigurationModule extends ModuleDefine {
            IApdexThresholdService.class,
            IServiceAlarmRuleConfig.class, IInstanceAlarmRuleConfig.class, IApplicationAlarmRuleConfig.class,
            IServiceReferenceAlarmRuleConfig.class, IInstanceReferenceAlarmRuleConfig.class, IApplicationReferenceAlarmRuleConfig.class,
            IComponentLibraryCatalogService.class, IResponseTimeDistributionConfigService.class};
            IComponentLibraryCatalogService.class, IResponseTimeDistributionConfigService.class, IWorkerCacheSizeConfig.class};
    }
}
+28 −0
Original line number Diff line number Diff line
/*
 * 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.configuration.service;

import org.apache.skywalking.apm.collector.core.module.Service;

/**
 * @author peng-yongsheng
 */
public interface IWorkerCacheSizeConfig extends Service {
    int cacheSize();
}
+9 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ class ConfigurationModuleConfig extends ModuleConfig {
    private int applicationAverageResponseTimeThreshold;
    private int thermodynamicResponseTimeStep;
    private int thermodynamicCountOfResponseTimeSteps;
    private int workerCacheMaxSize;

    public String getNamespace() {
        return namespace;
@@ -115,4 +116,12 @@ class ConfigurationModuleConfig extends ModuleConfig {
    public void setThermodynamicCountOfResponseTimeSteps(int thermodynamicCountOfResponseTimeSteps) {
        this.thermodynamicCountOfResponseTimeSteps = thermodynamicCountOfResponseTimeSteps;
    }

    public int getWorkerCacheMaxSize() {
        return workerCacheMaxSize;
    }

    public void setWorkerCacheMaxSize(int workerCacheMaxSize) {
        this.workerCacheMaxSize = workerCacheMaxSize;
    }
}
Loading