Commit 4fb03a63 authored by Matija Obreza's avatar Matija Obreza
Browse files

Registered thread worker pool

parent 1036413c
/*
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed 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.genesys.catalog.server.config;
import java.util.concurrent.ThreadPoolExecutor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
* Scheduler config.
*/
@EnableAsync
@EnableScheduling
@Configuration
public class SchedulerConfig {
@Bean(destroyMethod = "shutdown")
public ThreadPoolTaskExecutor taskExecutor() {
final ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
pool.setCorePoolSize(4);
pool.setMaxPoolSize(8);
pool.setQueueCapacity(10);
pool.setThreadNamePrefix("genesys-background-");
pool.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
return pool;
}
}
......@@ -23,6 +23,7 @@ import org.genesys.blocks.model.EntityId;
import org.genesys.catalog.server.config.ApplicationConfig;
import org.genesys.catalog.server.config.CacheConfig;
import org.genesys.catalog.server.config.DatabaseConfig;
import org.genesys.catalog.server.config.SchedulerConfig;
import org.genesys.catalog.server.config.SecurityConfig;
import org.genesys.catalog.server.config.SpringAclConfig;
import org.junit.runner.RunWith;
......@@ -47,7 +48,7 @@ import static org.junit.Assert.assertThat;
@RunWith(SpringJUnit4ClassRunner.class)
@EnableAspectJAutoProxy
@ContextConfiguration(name = "root", classes = { DatabaseConfig.class, ApplicationConfig.class, SpringAclConfig.class,
SecurityConfig.class, CacheConfig.class })
SecurityConfig.class, SchedulerConfig.class, CacheConfig.class })
public abstract class BaseTest {
protected final Logger LOG = LoggerFactory.getLogger(getClass());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment