List of usage examples for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor setMaxPoolSize
public void setMaxPoolSize(int maxPoolSize)
From source file:com.netflix.spinnaker.orca.config.JedisConfiguration.java
private static ThreadPoolTaskExecutor newFixedThreadPool(int threadPoolSize) { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(threadPoolSize); executor.setMaxPoolSize(threadPoolSize); return executor; }
From source file:org.cloudfoundry.caldecott.client.TunnelServer.java
protected static TaskExecutor getDefaultThreadExecutor() { ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor(); te.setCorePoolSize(5);//from w w w. ja v a 2s . c o m te.setMaxPoolSize(10); te.setQueueCapacity(100); return te; }
From source file:org.mimacom.sample.integration.patterns.user.service.integration.AsyncSearchServiceIntegration.java
private static AsyncRestTemplate initializeRestTemplate() { ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); threadPoolTaskExecutor.setCorePoolSize(2); threadPoolTaskExecutor.setMaxPoolSize(2); threadPoolTaskExecutor.setThreadNamePrefix("SearchServiceIntegration-"); threadPoolTaskExecutor.afterPropertiesSet(); return new AsyncRestTemplate(threadPoolTaskExecutor); }
From source file:org.mimacom.sample.integration.patterns.user.service.integration.BulkHeadedSearchServiceIntegration.java
private static AsyncRestTemplate initializeRestTemplate(String threadNamePrefix) { ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); threadPoolTaskExecutor.setCorePoolSize(2); threadPoolTaskExecutor.setMaxPoolSize(2); threadPoolTaskExecutor.setThreadNamePrefix(threadNamePrefix); threadPoolTaskExecutor.afterPropertiesSet(); return new AsyncRestTemplate(threadPoolTaskExecutor); }
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);/* w ww .ja v a2 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);/*w ww . ja va 2s.co m*/ 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);/*ww w. j a v a 2 s . com*/ 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);//from w w w. j av a 2 s . com executor.setRejectedExecutionHandler(new CallerRunsPolicy()); return executor; }
From source file:com.nayidisha.slowglow.config.SchedulerConfig.java
@Bean(name = "threadPoolTaskExecutor") public ThreadPoolTaskExecutor threadPoolTaskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setMaxPoolSize(5); executor.setCorePoolSize(2);//from w w w. j a va2 s. c o m executor.setQueueCapacity(25); executor.setWaitForTasksToCompleteOnShutdown(true); return executor; }