Java Code Examples for org.springframework.scheduling.concurrent.CustomizableThreadFactory#setDaemon()

The following examples show how to use org.springframework.scheduling.concurrent.CustomizableThreadFactory#setDaemon() . 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 vote down vote up
@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 vote down vote up
@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: CircuitBreakerCore.java    From spring-cloud-formula with Apache License 2.0 5 votes vote down vote up
public CircuitBreakerCore(CircuitBreakerManager manager) {
    this.manager = manager;
    CustomizableThreadFactory factory = new CustomizableThreadFactory();
    factory.setDaemon(true);
    factory.setThreadNamePrefix("circuit-breaker-");
    executorService = Executors.newCachedThreadPool(factory);
}
 
Example 4
Source File: RedisLockFactory.java    From summerframework with Apache License 2.0 5 votes vote down vote up
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 5
Source File: LookupCacheInvalidationDispatcher.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 5 votes vote down vote up
public LookupCacheInvalidationDispatcher()
{
	final CustomizableThreadFactory asyncThreadFactory = new CustomizableThreadFactory(LookupCacheInvalidationDispatcher.class.getSimpleName());
	asyncThreadFactory.setDaemon(true);

	async = Executors.newSingleThreadExecutor(asyncThreadFactory);
}
 
Example 6
Source File: DocumentCacheInvalidationDispatcher.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 5 votes vote down vote up
private static Executor createAsyncExecutor()
{
	final CustomizableThreadFactory asyncThreadFactory = new CustomizableThreadFactory(DocumentCacheInvalidationDispatcher.class.getSimpleName());
	asyncThreadFactory.setDaemon(true);

	return Executors.newSingleThreadExecutor(asyncThreadFactory);
}
 
Example 7
Source File: AsyncExecutorServiceImpl.java    From ankush with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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 8
Source File: JmsEventTransportImpl.java    From cougar with Apache License 2.0 4 votes vote down vote up
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 9
Source File: AemServiceConfiguration.java    From jwala with Apache License 2.0 3 votes vote down vote up
/**
 * 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;
}