All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.seide.thread.LoadSheddingPolicy Maven / Gradle / Ivy

The newest version!
package net.sf.seide.thread;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

import net.sf.seide.core.RuntimeStage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoadSheddingPolicy
    implements RejectedExecutionHandler {

    private final static Logger LOGGER = LoggerFactory.getLogger(LoadSheddingPolicy.class);
    private RuntimeStage runtimeStage;

    public LoadSheddingPolicy(RuntimeStage runtimeStage) {
        this.runtimeStage = runtimeStage;
    }

    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        this.runtimeStage.getStageStats().trackDiscardedExecution();
        LOGGER.info("Discarded execution for stage [" + this.runtimeStage.getId() + "]...");
    }

    public void setStageContext(RuntimeStage runtimeStage) {
        this.runtimeStage = runtimeStage;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy