Example usage for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor initialize

List of usage examples for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor initialize

Introduction

In this page you can find the example usage for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor initialize.

Prototype

public void initialize() 

Source Link

Document

Set up the ExecutorService.

Usage

From source file:com.bt.aloha.media.convedia.conference.MaxConferenceDurationTerminationTest.java

@Test
public void testInitializeWithTermination() {
    //setup//from   ww w  .  j a v a 2s.co m
    conferenceCollection.add(conferenceInfoInPast);
    maxConferenceDurationTermination.setConferenceCollection(conferenceCollection);
    ConferenceBean conferenceBean = EasyMock.createMock(ConferenceBean.class);
    conferenceBean.endConference(conferenceInfoInPast.getId(),
            ConferenceTerminationCause.MaximumDurationExceeded);
    EasyMock.replay(conferenceBean);
    maxConferenceDurationTermination.setConferenceBean(conferenceBean);
    ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor();
    te.initialize();
    maxConferenceDurationTermination.setTaskExecutor(te);

    //act
    maxConferenceDurationTermination.runTask();
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {
        e.printStackTrace();
    } // allow time for thread to run

    //assert
    EasyMock.verify(conferenceBean);
}

From source file:org.tocode.poc.service.config.ServiceConfig.java

@Override
public Executor getAsyncExecutor() {

    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(20);//from  ww  w. j  av a 2  s.  c om
    executor.setMaxPoolSize(50);
    executor.setQueueCapacity(500);
    executor.setThreadNamePrefix("Service-Thread");
    executor.initialize();
    return executor;
}

From source file:com.aol.advertising.qiao.agent.DataDisruptor.java

public void init() throws IOException {

    if (!CommonUtils.isPowerOfTwo(capacity))
        capacity = CommonUtils.power2(capacity);

    if (waitStrategy == null)
        waitStrategy = new BlockingWaitStrategy();

    //disruptor = new Disruptor<EventWrapper>(EventWrapper.EVENT_FACTORY,
    //        capacity, Executors.newCachedThreadPool(), ProducerType.SINGLE,
    //        waitStrategy);

    ThreadPoolTaskExecutor executor = CommonUtils.createFixedThreadPoolExecutor(threadPoolSize);
    executor.setThreadNamePrefix(this.getClass().getSimpleName());
    executor.initialize();

    disruptor = new Disruptor<EventWrapper>(EventWrapper.EVENT_FACTORY, capacity, executor, ProducerType.SINGLE,
            waitStrategy);/*from w  w  w . ja  va 2 s  .  c  o m*/

    disruptor.handleEventsWith(eventHandlerList.toArray(new EventHandler[0]));
}

From source file:org.apache.nutch.storage.local.SpringConfiguration.java

@Override
public Executor getAsyncExecutor() {
    // TODO move magic numbers to properties file
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(7);//from  ww w .ja v a 2s.  c o  m
    executor.setMaxPoolSize(42);
    executor.setQueueCapacity(11);
    executor.setThreadNamePrefix("SpringExecutor-");
    executor.initialize();
    return executor;
}

From source file:com.sample.config.AsyncConfig.java

@Override
public Executor getAsyncExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(2); // seems like too many thread here will make gmail return error
    executor.setMaxPoolSize(2);/*from w w  w  .j  a v a 2  s  . c o  m*/
    executor.setQueueCapacity(3000);
    executor.setThreadNamePrefix("EmailExecutor-");
    executor.initialize();
    return executor;
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.config.AsyncConfiguration.java

/**
 * Executor dedicated to searches against lucene index
 * /*from   www.j a  v a  2s.  c o m*/
 * @return
 */
public @Bean ThreadPoolTaskExecutor fsSearchTaskExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(fsThreadPoolSize);
    executor.setMaxPoolSize(fsThreadPoolSize);
    executor.setQueueCapacity(fsQueueCapacity);
    executor.setThreadNamePrefix("fsSearchTaskExecutor-");
    executor.initialize();
    return executor;
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.config.AsyncConfiguration.java

/**
 * executor dedicated to searches against in memory index
 * //from   www  . j ava2  s. com
 * @return
 */
public @Bean ThreadPoolTaskExecutor memorySearchTaskExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(memoryThreadPoolSize);
    executor.setMaxPoolSize(memoryThreadPoolSize);
    executor.setQueueCapacity(memoryQueueCapacity);
    executor.setThreadNamePrefix("memorySearchTaskExecutor-");
    executor.initialize();
    return executor;
}

From source file:cn.org.once.cstack.config.AsyncConfiguration.java

@Override
@Bean/*from  w  w  w. j av a 2s .c  o m*/
public Executor getAsyncExecutor() {
    log.debug("Creating Async Task Executor");
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(5);
    executor.setMaxPoolSize(50);

    executor.setWaitForTasksToCompleteOnShutdown(true);

    executor.setQueueCapacity(10000);
    executor.setThreadNamePrefix("cloudunit-Executor-");
    executor.initialize();
    return executor;
}

From source file:com.axel.config.ServiceConfig.java

@Override
public Executor getAsyncExecutor() {
    log.debug("Creating Async Task Executor");
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    // to customize with your requirements
    executor.setCorePoolSize(5);//from w w  w. ja va  2  s.com
    executor.setMaxPoolSize(40);
    executor.setQueueCapacity(100);
    executor.setThreadNamePrefix("MyExecutor-");
    executor.initialize();
    return executor;
}

From source file:cz.muni.fi.editor.test.service.support.configs.TestConfiguration.java

@Override
public Executor getAsyncExecutor() {
    // move to configuration
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(4);/*from  w  ww  .j  a v  a  2  s.c  o  m*/
    executor.setMaxPoolSize(42);
    executor.setQueueCapacity(11);
    executor.setThreadNamePrefix("EditorExecutor-");
    executor.initialize();

    return executor;
}