- All Known Implementing Classes:
DefaultEventLoopGroupProvider
public interface EventLoopGroupProvider
Provider for
EventLoopGroups and EventExecutorGroups. A event loop group is a heavy-weight instance
holding and providing Thread instances. Multiple instances can be created but are expensive. Keeping too many
instances open can exhaust the number of open files.
Usually, the default settings are sufficient. However, customizing might be useful for some special cases where multiple
RedisClient or RedisClusterClient instances are needed that share one
or more event loop groups.
The EventLoopGroupProvider allows to allocate and release instances implementing EventExecutorGroup. The
EventExecutorGroup instances must not be terminated or shutdown by the user. Resources are managed by the particular
EventLoopGroupProvider.
EventLoopGroupProvider to share existing EventLoopGroup's with
lettuce.- Since:
- 3.4
- Author:
- Mark Paluch
-
Method Summary
Modifier and Type Method Description <T extends EventLoopGroup>
Tallocate(Class<T> type)Future<Boolean>release(EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit)Release aeventLoopGroupinstance.Future<Boolean>shutdown(long quietPeriod, long timeout, TimeUnit timeUnit)Shutdown the provider and release all instances.intthreadPoolSize()Returns the pool size (number of threads) for IO threads.
-
Method Details
-
allocate
Retrieve aEventLoopGroupfor thechanneltype. Do not terminate or shutdown the instance. Call therelease(EventExecutorGroup, long, long, TimeUnit)to release an individual instance orshutdown(long, long, TimeUnit)method to free the all resources.- Type Parameters:
T- type of theEventLoopGroup- Parameters:
type- class of theEventLoopGroup, must not benull- Returns:
- the
EventLoopGroup.
-
threadPoolSize
int threadPoolSize()Returns the pool size (number of threads) for IO threads. The indicated size does not reflect the number for all IO threads, it is the number of threads that are used to create a particular thread pool.- Returns:
- the pool size (number of threads) for all IO tasks.
-
release
Future<Boolean> release(EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit)Release aeventLoopGroupinstance. The method will shutdown/terminate theEventExecutorGroupif it is no longer needed.- Parameters:
eventLoopGroup- the eventLoopGroup instance, must not benullquietPeriod- the quiet periodtimeout- the timeoutunit- time unit for the quiet period/the timeout- Returns:
- a close future to synchronize the called for shutting down.
-
shutdown
Shutdown the provider and release all instances.- Parameters:
quietPeriod- the quiet periodtimeout- the timeouttimeUnit- the unit ofquietPeriodandtimeout- Returns:
- a close future to synchronize the called for shutting down.
-