Search in sources :

Example 76 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project faf-java-server by FAForever.

the class LegacyAdapterConfig method createNioTaskExecutor.

@NotNull
private Executor createNioTaskExecutor(String threadNamePrefix) {
    ThreadPoolTaskExecutor ioExecutor = new ThreadPoolTaskExecutor();
    ioExecutor.setCorePoolSize(1);
    ioExecutor.setMaxPoolSize(4);
    ioExecutor.setQueueCapacity(0);
    ioExecutor.setThreadNamePrefix(threadNamePrefix);
    ioExecutor.setRejectedExecutionHandler(new AbortPolicy());
    ioExecutor.initialize();
    return ioExecutor;
}
Also used : AbortPolicy(java.util.concurrent.ThreadPoolExecutor.AbortPolicy) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) NotNull(org.jetbrains.annotations.NotNull)

Example 77 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-cloud-gcp by spring-cloud.

the class CloudVisionAutoConfiguration method cloudVisionExecutor.

@Bean
@ConditionalOnMissingBean(name = "cloudVisionExecutor")
public Executor cloudVisionExecutor() {
    ThreadPoolTaskExecutor ackExecutor = new ThreadPoolTaskExecutor();
    ackExecutor.setMaxPoolSize(this.cloudVisionProperties.getExecutorThreadsCount());
    ackExecutor.setThreadNamePrefix("gcp-cloud-vision-ocr-executor");
    ackExecutor.setDaemon(true);
    return ackExecutor;
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 78 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project data-prep by Talend.

the class TaskExecution method dataPrepAsyncTaskExecutor.

/**
 * @return an Authenticated task executor for event multi casting.
 * @see DataPrepEvents
 */
@Bean(name = "applicationEventMulticaster#executor")
public TaskExecutor dataPrepAsyncTaskExecutor() {
    final ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(2);
    taskExecutor.setMaxPoolSize(10);
    taskExecutor.setWaitForTasksToCompleteOnShutdown(false);
    taskExecutor.initialize();
    return taskExecutor;
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Bean(org.springframework.context.annotation.Bean)

Example 79 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project data-prep by Talend.

the class TaskExecution method getAsyncExecutor.

/**
 * @return an Authenticated task executor ready to run.
 */
protected AsyncListenableTaskExecutor getAsyncExecutor() {
    final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(2);
    executor.setMaxPoolSize(10);
    executor.setWaitForTasksToCompleteOnShutdown(false);
    executor.initialize();
    return executor;
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)

Example 80 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project data-prep by Talend.

the class AsyncAspectTest method getManagedTaskExecutorEngine.

@Bean(name = "managedTaskEngine")
public TaskExecutor getManagedTaskExecutorEngine() {
    final ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
    threadPoolTaskExecutor.setMaxPoolSize(1);
    threadPoolTaskExecutor.setWaitForTasksToCompleteOnShutdown(false);
    threadPoolTaskExecutor.initialize();
    return threadPoolTaskExecutor;
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Bean(org.springframework.context.annotation.Bean)

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