org.springframework.scheduling.concurrent.CustomizableThreadFactory Java Examples
The following examples show how to use
org.springframework.scheduling.concurrent.CustomizableThreadFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Resilience4jTest.java From spring-cloud-formula with Apache License 2.0 | 6 votes |
@Before public void init() { TimeLimiterConfig timeLimiterConfig = TimeLimiterConfig.custom() .timeoutDuration(Duration.ofSeconds(1)) .cancelRunningFuture(true) .build(); timeLimiter = TimeLimiter.of(timeLimiterConfig); CustomizableThreadFactory factory = new CustomizableThreadFactory("timeLimiter-"); factory.setDaemon(true); executorService = Executors.newCachedThreadPool(factory); CircuitBreakerConfig circuitBreakerConfig = CircuitBreakerConfig .custom() .enableAutomaticTransitionFromOpenToHalfOpen() .failureRateThreshold(50) .ringBufferSizeInClosedState(10) .ringBufferSizeInHalfOpenState(2) .build(); circuitBreaker = CircuitBreaker.of("backendName", circuitBreakerConfig); }
Example #2
Source File: RaptorHttpClientConfiguration.java From raptor with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnMissingBean(HttpClientConnectionManager.class) public HttpClientConnectionManager createConnectionManager( ApacheHttpClientConnectionManagerFactory connectionManagerFactory) { final HttpClientConnectionManager connectionManager = connectionManagerFactory .newConnectionManager(httpClientProperties.isDisableSslValidation(), httpClientProperties.getMaxConnections(), httpClientProperties.getMaxConnectionsPerRoute(), httpClientProperties.getTimeToLive(), httpClientProperties.getTimeToLiveUnit(), registryBuilder); CustomizableThreadFactory customizableThreadFactory = new CustomizableThreadFactory("RaptorHttpClient.connectionManager.schedule"); customizableThreadFactory.setDaemon(true); connectionManagerSchedule = new ScheduledThreadPoolExecutor(1, customizableThreadFactory); connectionManagerSchedule.scheduleAtFixedRate(new Runnable() { @Override public void run() { connectionManager.closeExpiredConnections(); } }, 30000, httpClientProperties.getConnectionTimerRepeat(), TimeUnit.MILLISECONDS); return connectionManager; }
Example #3
Source File: BeanAggregateAutoConfiguration.java From spring-boot-data-aggregator with Apache License 2.0 | 5 votes |
/** * 允许用户自定义线程池 * * @return 线程池服务 */ @Bean(name = "aggregateExecutorService") @ConditionalOnMissingBean(name = "aggregateExecutorService",value=ExecutorService.class) public ExecutorService aggregateExecutorService() { return new ThreadPoolExecutor( properties.getThreadNumber(), properties.getThreadNumber() , 2L, TimeUnit.HOURS, new LinkedBlockingDeque<>(properties.getQueueSize()), new CustomizableThreadFactory(properties.getThreadPrefix())); }
Example #4
Source File: AsyncExecutorServiceImpl.java From ankush with GNU Lesser General Public License v3.0 | 5 votes |
/** * Instantiates a new async executor service impl. */ public AsyncExecutorServiceImpl() { super(MIN_THREAD_POOL_SIZE, MAX_THREAD_POOL_SIZE, KEEP_ALIVE_TIME, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new CustomizableThreadFactory()); ThreadFactory factory = this.getThreadFactory(); if (factory instanceof CustomizableThreadFactory) { CustomizableThreadFactory customizableThreadFactory = (CustomizableThreadFactory) factory; customizableThreadFactory .setThreadNamePrefix("AnkushProgressAwareThread_"); customizableThreadFactory.setDaemon(true); } }
Example #5
Source File: CustomSchedulingConfiguration.java From booties with Apache License 2.0 | 5 votes |
@Bean(destroyMethod = "shutdown") @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public ScheduledExecutorService scheduledExecutorService() { ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(properties.getCorePoolSize()); executor.setMaximumPoolSize(properties.getMaxPoolSize()); executor.setThreadFactory(new CustomizableThreadFactory(properties.getThreadNamePrefix())); executor.setRejectedExecutionHandler(getConfiguredRejectedExecutionHandler()); return executor; }
Example #6
Source File: ManualConfiguration.java From riptide with MIT License | 5 votes |
@Bean(destroyMethod = "shutdown") public ExecutorService executor(final Tracer tracer) { return new TracedExecutorService( ThreadPoolExecutors.builder() .withoutQueue() .elasticSize(1, 20) .keepAlive(1, MINUTES) .threadFactory(new CustomizableThreadFactory("http-example-")) .build(), tracer); }
Example #7
Source File: ThreadPoolFactory.java From riptide with MIT License | 5 votes |
public static ThreadPoolExecutor create( final String id, final Threads threads) { final TimeSpan keepAlive = threads.getKeepAlive(); return configure(threads) .keepAlive(keepAlive.getAmount(), keepAlive.getUnit()) .threadFactory(new CustomizableThreadFactory("http-" + id + "-")) .build(); }
Example #8
Source File: Watchdog.java From haven-platform with Apache License 2.0 | 5 votes |
@Autowired Watchdog(List<LimitExcessListener> listeners) { this.listeners = Collections.unmodifiableList(new ArrayList<>(listeners)); //we need executor which cannot blocked by unknown task // also in health() we need to check for hangs tasks and report it this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new CustomizableThreadFactory("watchdog-")); }
Example #9
Source File: MailServiceConfiguration.java From haven-platform with Apache License 2.0 | 5 votes |
@Bean ExecutorService mailSenderExecutor() { return new ThreadPoolExecutor(2, 2, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(queueCapacity), new CustomizableThreadFactory("MailSender")); }
Example #10
Source File: DocumentCacheInvalidationDispatcher.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 5 votes |
private static Executor createAsyncExecutor() { final CustomizableThreadFactory asyncThreadFactory = new CustomizableThreadFactory(DocumentCacheInvalidationDispatcher.class.getSimpleName()); asyncThreadFactory.setDaemon(true); return Executors.newSingleThreadExecutor(asyncThreadFactory); }
Example #11
Source File: LookupCacheInvalidationDispatcher.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 5 votes |
public LookupCacheInvalidationDispatcher() { final CustomizableThreadFactory asyncThreadFactory = new CustomizableThreadFactory(LookupCacheInvalidationDispatcher.class.getSimpleName()); asyncThreadFactory.setDaemon(true); async = Executors.newSingleThreadExecutor(asyncThreadFactory); }
Example #12
Source File: RedisLockFactory.java From summerframework with Apache License 2.0 | 5 votes |
public RedisLockFactory(RedisTemplate redisTemplate, LockHandler lockHandler,int scheduledPoolSize) { CustomizableThreadFactory threadFactory=new CustomizableThreadFactory("redis-lock"); threadFactory.setDaemon(true); this.redisTemplate = redisTemplate; this.lockHandler = lockHandler; scheduledThreadPoolExecutor=new ScheduledThreadPoolExecutor(scheduledPoolSize,threadFactory); }
Example #13
Source File: CircuitBreakerCore.java From spring-cloud-formula with Apache License 2.0 | 5 votes |
public CircuitBreakerCore(CircuitBreakerManager manager) { this.manager = manager; CustomizableThreadFactory factory = new CustomizableThreadFactory(); factory.setDaemon(true); factory.setThreadNamePrefix("circuit-breaker-"); executorService = Executors.newCachedThreadPool(factory); }
Example #14
Source File: AggregatorCustomConfiguration.java From spring-boot-data-aggregator with Apache License 2.0 | 5 votes |
/** * 自定义ExecutorService, 替代aggregator库使用的executorService * @return */ @Bean public ExecutorService aggregateExecutorService() { return new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),Runtime.getRuntime().availableProcessors() * 2 , 2L, TimeUnit.HOURS, new LinkedBlockingDeque<>(1024), new CustomizableThreadFactory("example-async")); }
Example #15
Source File: SchedulerConfiguration.java From eventeum with Apache License 2.0 | 4 votes |
@Bean(destroyMethod="shutdown") public Executor taskScheduler(NodeSettings nodeSettings) { scheduledExecutorService = Executors.newScheduledThreadPool(nodeSettings.getNodes().size(), new CustomizableThreadFactory("eventeum-scheduler")); return scheduledExecutorService; }
Example #16
Source File: SchedulerProxyScheduledExecutorServiceSchedulerTest.java From ShedLock with Apache License 2.0 | 4 votes |
@Bean public ScheduledExecutorService executorService() { return Executors.newScheduledThreadPool(10, new CustomizableThreadFactory("my-thread")); }
Example #17
Source File: SchedulerProxyCglibTest.java From ShedLock with Apache License 2.0 | 4 votes |
MyTaskScheduler() { super(Executors.newScheduledThreadPool(10, new CustomizableThreadFactory("my-thread"))); }
Example #18
Source File: SchedulerProxyTest.java From ShedLock with Apache License 2.0 | 4 votes |
MyTaskScheduler() { super(Executors.newScheduledThreadPool(10, new CustomizableThreadFactory("my-thread"))); }
Example #19
Source File: EnableAsyncTests.java From java-technology-stack with MIT License | 4 votes |
@Bean public Executor taskExecutor() { return Executors.newSingleThreadExecutor(new CustomizableThreadFactory("Custom-")); }
Example #20
Source File: ExecutorServiceConfig.java From bswen-project with Apache License 2.0 | 4 votes |
@Bean("customFixedThreadPool") public ExecutorService customFixedThreadPool() { return Executors.newFixedThreadPool(2,new CustomizableThreadFactory("customFixedThreadPool")); }
Example #21
Source File: EnableAsyncTests.java From spring-analysis-note with MIT License | 4 votes |
@Bean public Executor taskExecutor() { return Executors.newSingleThreadExecutor(new CustomizableThreadFactory("Custom-")); }
Example #22
Source File: JmsEventTransportImpl.java From cougar with Apache License 2.0 | 4 votes |
public void initThreadPool() { CustomizableThreadFactory ctf = new CustomizableThreadFactory(); ctf.setDaemon(true); ctf.setThreadNamePrefix(getTransportName()+"-Publisher-"); threadPool = new JMXReportingThreadPoolExecutor(threadPoolSize, threadPoolSize, 0, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), ctf); }
Example #23
Source File: AemServiceConfiguration.java From jwala with Apache License 2.0 | 3 votes |
/** * Bean method to create a thread factory that creates daemon threads. * <code> * <bean id="pollingThreadFactory" class="org.springframework.scheduling.concurrent.CustomizableThreadFactory"> * <constructor-arg value="polling-"/> * </bean></code> */ @Bean(name = "pollingThreadFactory") public ThreadFactory getPollingThreadFactory() { CustomizableThreadFactory tf = new CustomizableThreadFactory("polling-"); tf.setDaemon(true); return tf; }