Search in sources :

Example 36 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project elastest-torm by elastest.

the class ElasTestTormApp method getAsyncExecutor.

@Override
public Executor getAsyncExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(4);
    executor.setMaxPoolSize(6);
    executor.setQueueCapacity(500);
    executor.setThreadNamePrefix("ET-");
    executor.initialize();
    return executor;
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)

Example 37 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project hello-world by haoziapple.

the class AsyncConfiguration method getAsyncExecutor.

@Override
@Bean(name = "taskExecutor")
public Executor getAsyncExecutor() {
    log.debug("Creating Async Task Executor");
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(jHipsterProperties.getAsync().getCorePoolSize());
    executor.setMaxPoolSize(jHipsterProperties.getAsync().getMaxPoolSize());
    executor.setQueueCapacity(jHipsterProperties.getAsync().getQueueCapacity());
    executor.setThreadNamePrefix("jh-app-Executor-");
    return new ExceptionHandlingAsyncTaskExecutor(executor);
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) ExceptionHandlingAsyncTaskExecutor(io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor) Bean(org.springframework.context.annotation.Bean)

Example 38 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project cloudbreak by hortonworks.

the class AppConfig method intermediateBuilderExecutor.

@Bean
public AsyncTaskExecutor intermediateBuilderExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(intermediateCorePoolSize);
    executor.setQueueCapacity(intermediateQueueCapacity);
    executor.setThreadNamePrefix("intermediateBuilderExecutor-");
    executor.setTaskDecorator(new MDCCleanerTaskDecorator());
    executor.initialize();
    return executor;
}
Also used : MDCCleanerTaskDecorator(com.sequenceiq.cloudbreak.concurrent.MDCCleanerTaskDecorator) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) GenericFilterBean(org.springframework.web.filter.GenericFilterBean) Bean(org.springframework.context.annotation.Bean)

Example 39 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project cloudbreak by hortonworks.

the class AppConfig method resourceBuilderExecutor.

@Bean
public AsyncTaskExecutor resourceBuilderExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(corePoolSize);
    executor.setQueueCapacity(queueCapacity);
    executor.setThreadNamePrefix("resourceBuilderExecutor-");
    executor.setTaskDecorator(new MDCCleanerTaskDecorator());
    executor.initialize();
    return executor;
}
Also used : MDCCleanerTaskDecorator(com.sequenceiq.cloudbreak.concurrent.MDCCleanerTaskDecorator) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) GenericFilterBean(org.springframework.web.filter.GenericFilterBean) Bean(org.springframework.context.annotation.Bean)

Example 40 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.

the class WebSocketMessageBrokerStatsTests method inboundAndOutboundChannelsWithThreadPoolTaskExecutor.

@Test
void inboundAndOutboundChannelsWithThreadPoolTaskExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.afterPropertiesSet();
    stats.setInboundChannelExecutor(executor);
    stats.setOutboundChannelExecutor(executor);
    assertThat(stats.getClientInboundExecutorStatsInfo()).as("inbound channel stats").isEqualTo("pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0");
    assertThat(stats.getClientOutboundExecutorStatsInfo()).as("outbound channel stats").isEqualTo("pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0");
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Test(org.junit.jupiter.api.Test)

Aggregations

ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)152 Bean (org.springframework.context.annotation.Bean)72 ExceptionHandlingAsyncTaskExecutor (io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor)19 Test (org.junit.jupiter.api.Test)19 BigInteger (java.math.BigInteger)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)15 RateLimiter (com.google.common.util.concurrent.RateLimiter)14 Test (org.junit.Test)14 Random (java.util.Random)12 ApplicationContext (org.springframework.context.ApplicationContext)12 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)9 Service (org.fisco.bcos.channel.client.Service)9 Credentials (org.fisco.bcos.web3j.crypto.Credentials)9 Web3j (org.fisco.bcos.web3j.protocol.Web3j)9 ChannelEthereumService (org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService)9 TransactionReceipt (org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt)9 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)9 CountDownLatch (java.util.concurrent.CountDownLatch)8 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)6 MDCCleanerTaskDecorator (com.sequenceiq.cloudbreak.concurrent.MDCCleanerTaskDecorator)4