Package io.lettuce.core.resource
Interface EventLoopGroupProvider
-
- All Known Implementing Classes:
DefaultEventLoopGroupProvider
public interface EventLoopGroupProvider
Provider forEventLoopGroups and EventExecutorGroups
. A event loop group is a heavy-weight instance holding and providingThread
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
orRedisClusterClient
instances are needed that share one or more event loop groups.The
You can implement your ownEventLoopGroupProvider
allows to allocate and release instances implementingEventExecutorGroup
. TheEventExecutorGroup
instances must not be terminated or shutdown by the user. Resources are managed by the particularEventLoopGroupProvider
.EventLoopGroupProvider
to share existingEventLoopGroup's
with lettuce.- Since:
- 3.4
- Author:
- Mark Paluch
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends EventLoopGroup>
Tallocate(Class<T> type)
Future<Boolean>
release(EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit)
Release aeventLoopGroup
instance.Future<Boolean>
shutdown(long quietPeriod, long timeout, TimeUnit timeUnit)
Shutdown the provider and release all instances.int
threadPoolSize()
Returns the pool size (number of threads) for IO threads.
-
-
-
Method Detail
-
allocate
<T extends EventLoopGroup> T allocate(Class<T> type)
Retrieve aEventLoopGroup
for thechannel
type
. 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 aeventLoopGroup
instance. The method will shutdown/terminate theEventExecutorGroup
if it is no longer needed.- Parameters:
eventLoopGroup
- the eventLoopGroup instance, must not benull
quietPeriod
- 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
Future<Boolean> shutdown(long quietPeriod, long timeout, TimeUnit timeUnit)
Shutdown the provider and release all instances.- Parameters:
quietPeriod
- the quiet periodtimeout
- the timeouttimeUnit
- the unit ofquietPeriod
andtimeout
- Returns:
- a close future to synchronize the called for shutting down.
-
-