List of usage examples for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor setQueueCapacity
public void setQueueCapacity(int queueCapacity)
From source file:org.cloudfoundry.caldecott.client.TunnelServer.java
protected static TaskExecutor getDefaultThreadExecutor() { ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor(); te.setCorePoolSize(5);//from w w w . j ava 2 s .co m te.setMaxPoolSize(10); te.setQueueCapacity(100); return te; }
From source file:com.ciphertool.zodiacengine.genetic.algorithms.ConcurrentBasicGeneticAlgorithmTest.java
@BeforeClass public static void setUp() { FitnessEvaluator fitnessEvaluator = new CipherSolutionKnownSolutionFitnessEvaluator(); fitnessEvaluator.setGeneticStructure(zodiac408); CrossoverAlgorithm crossoverAlgorithm = new LowestCommonGroupCrossoverAlgorithm(); crossoverAlgorithm.setFitnessEvaluator(fitnessEvaluator); SingleSequenceMutationAlgorithm mutationAlgorithm = new SingleSequenceMutationAlgorithm(); mutationAlgorithm.setSequenceDao(new PlaintextSequenceDao()); ProbabilisticSelectionAlgorithm selectionAlgorithm = new ProbabilisticSelectionAlgorithm(); Selector selector = new RouletteSelector(); GeneticAlgorithmStrategy geneticAlgorithmStrategy = new GeneticAlgorithmStrategy(zodiac408, POPULATION_SIZE, LIFESPAN, MAX_GENERATIONS, SURVIVAL_RATE, MUTATION_RATE, MAX_MUTATIONS_PER_INDIVIDUAL, CROSSOVER_RATE, MUTATE_DURING_CROSSOVER, fitnessEvaluator, crossoverAlgorithm, mutationAlgorithm, selectionAlgorithm, selector); population.setBreeder(solutionBreederMock); population.setSelector(selector);/*from w w w .ja va 2 s . c om*/ ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); taskExecutor.setCorePoolSize(MAX_THREADS); taskExecutor.setMaxPoolSize(MAX_THREADS); taskExecutor.setQueueCapacity(THREAD_EXECUTOR_QUEUE_CAPACITY); taskExecutor.setKeepAliveSeconds(1); taskExecutor.setAllowCoreThreadTimeOut(true); taskExecutor.initialize(); population.setTaskExecutor(taskExecutor); geneticAlgorithm = new ConcurrentBasicGeneticAlgorithm(); geneticAlgorithm.setPopulation(population); geneticAlgorithm.setStrategy(geneticAlgorithmStrategy); ((ConcurrentBasicGeneticAlgorithm) geneticAlgorithm).setTaskExecutor(taskExecutor); ExecutionStatisticsDao executionStatisticsDaoMock = mock(ExecutionStatisticsDao.class); ((ConcurrentBasicGeneticAlgorithm) geneticAlgorithm).setExecutionStatisticsDao(executionStatisticsDaoMock); }
From source file:com.ciphertool.zodiacengine.genetic.PopulationTest.java
@BeforeClass public static void setUp() { population.setSelector(new RouletteSelector()); population.setBreeder(solutionBreederMock); ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); taskExecutor.setCorePoolSize(4);// ww w .j av a 2s .com taskExecutor.setMaxPoolSize(4); taskExecutor.setQueueCapacity(100); taskExecutor.setKeepAliveSeconds(1); taskExecutor.setAllowCoreThreadTimeOut(true); taskExecutor.initialize(); population.setTaskExecutor(taskExecutor); CipherSolutionKnownSolutionFitnessEvaluator cipherSolutionKnownSolutionFitnessEvaluator = new CipherSolutionKnownSolutionFitnessEvaluator(); cipherSolutionKnownSolutionFitnessEvaluator.setGeneticStructure(zodiac408); population.setFitnessEvaluator(cipherSolutionKnownSolutionFitnessEvaluator); population.setLifespan(LIFESPAN); population.setFitnessComparator(new AscendingFitnessComparator()); dummySolution = knownSolution.clone(); dummySolution.getGenes().get(0).insertSequence(0, new PlaintextSequence(0, "i", dummySolution.getGenes().get(0))); }
From source file:com.ciphertool.zodiacengine.genetic.algorithms.BasicGeneticAlgorithmTest.java
@BeforeClass public static void setUp() { FitnessEvaluator fitnessEvaluator = new CipherSolutionKnownSolutionFitnessEvaluator(); fitnessEvaluator.setGeneticStructure(zodiac408); CrossoverAlgorithm crossoverAlgorithm = new LowestCommonGroupCrossoverAlgorithm(); crossoverAlgorithm.setFitnessEvaluator(fitnessEvaluator); SingleSequenceMutationAlgorithm mutationAlgorithm = new SingleSequenceMutationAlgorithm(); mutationAlgorithm.setSequenceDao(new PlaintextSequenceDao()); ProbabilisticSelectionAlgorithm selectionAlgorithm = new ProbabilisticSelectionAlgorithm(); Selector selector = new RouletteSelector(); GeneticAlgorithmStrategy geneticAlgorithmStrategy = new GeneticAlgorithmStrategy(zodiac408, POPULATION_SIZE, LIFESPAN, MAX_GENERATIONS, SURVIVAL_RATE, MUTATION_RATE, MAX_MUTATIONS_PER_INDIVIDUAL, CROSSOVER_RATE, MUTATE_DURING_CROSSOVER, fitnessEvaluator, crossoverAlgorithm, mutationAlgorithm, selectionAlgorithm, selector); population.setBreeder(solutionBreederMock); population.setSelector(selector);//from w ww . j av a 2s. co m ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); taskExecutor.setCorePoolSize(MAX_THREADS); taskExecutor.setMaxPoolSize(MAX_THREADS); taskExecutor.setQueueCapacity(THREAD_EXECUTOR_QUEUE_CAPACITY); taskExecutor.setKeepAliveSeconds(1); taskExecutor.setAllowCoreThreadTimeOut(true); taskExecutor.initialize(); population.setTaskExecutor(taskExecutor); geneticAlgorithm = new BasicGeneticAlgorithm(); geneticAlgorithm.setPopulation(population); geneticAlgorithm.setStrategy(geneticAlgorithmStrategy); ExecutionStatisticsDao executionStatisticsDaoMock = mock(ExecutionStatisticsDao.class); ((BasicGeneticAlgorithm) geneticAlgorithm).setExecutionStatisticsDao(executionStatisticsDaoMock); }
From source file:com.aol.advertising.qiao.util.CommonUtils.java
public static ThreadPoolTaskExecutor createThreadPoolExecutor(int corePoolSize, int maxPoolSize, int queueCapacity) { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); executor.setRejectedExecutionHandler(new CallerRunsPolicy()); return executor; }
From source file:com.aol.advertising.qiao.util.CommonUtils.java
public static ThreadPoolTaskExecutor createFixedThreadPoolExecutor(int threadPoolSize) { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(threadPoolSize); executor.setMaxPoolSize(threadPoolSize); executor.setQueueCapacity(0); executor.setRejectedExecutionHandler(new CallerRunsPolicy()); return executor; }
From source file:kymr.github.io.future.FutureSpringApplication.java
@Bean ThreadPoolTaskExecutor tp() {//from w w w . j a va 2 s. co m ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor(); te.setCorePoolSize(10); // default core thread pool te.setQueueCapacity(200); te.setMaxPoolSize(100); // after core pool is full -> after queue capacity (generally, unlimited) is full -> then, max pool size works. te.setThreadNamePrefix("mythread"); te.initialize(); //te.setAllowCoreThreadTimeOut(); //te.getKeepAliveSeconds() //te.setTaskDecorator(); // for task monitoring return te; }
From source file:net.brainage.nest.NestApplication.java
@Bean public AsyncTaskExecutor asyncTaskExecutor() { ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); taskExecutor.setCorePoolSize(5);/*from w w w .j ava 2 s .c om*/ taskExecutor.setMaxPoolSize(200); taskExecutor.setQueueCapacity(100); taskExecutor.setThreadNamePrefix("async-task-executor-"); taskExecutor.initialize(); return taskExecutor; }
From source file:com.github.javarch.support.config.TaskConfig.java
/**. *///from ww w . j a va 2 s. c om @Bean public Executor taskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(7); executor.setMaxPoolSize(42); executor.setQueueCapacity(11); executor.setThreadNamePrefix("Executor-"); executor.initialize(); return executor; }
From source file:com.nayidisha.slowglow.config.SchedulerConfig.java
@Bean(name = "threadPoolTaskExecutor") public ThreadPoolTaskExecutor threadPoolTaskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setMaxPoolSize(5);/* ww w.j a v a2 s . c om*/ executor.setCorePoolSize(2); executor.setQueueCapacity(25); executor.setWaitForTasksToCompleteOnShutdown(true); return executor; }