- All Known Implementing Classes:
DefaultClientResources
public interface ClientResources
Strategy interface to provide all the infrastructure building blocks like environment settings and thread pools so that the
client can work with it properly.
ClientResources can be shared amongst multiple client instances if created outside
the client creation. Implementations of ClientResources are stateful and must be shutdown() after they are
no longer in use.
ClientResources provides in particular:
AddressResolverGroupfor DNS resolution.CommandLatencyRecorderto collect latency details. Enabled usingDefaultCommandLatencyCollectorwhen HdrHistogram is on the classpath.EventBusfor client event dispatchingEventLoopGroupProviderto obtain particularEventLoopGroupsEventExecutorGroupto perform internal computation tasks- Reconnect
Delay. SocketAddressResolverfor to map/resolve DNS addresses to aInetSocketAddress.Timerfor schedulingTracingto trace Redis commands.
- Since:
- 3.4
- Author:
- Mark Paluch, Mikhael Sokolov, Yohei Ueki
- See Also:
DefaultClientResources
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceClientResources.BuilderBuilder forClientResources. -
Method Summary
Modifier and Type Method Description AddressResolverGroup<?>addressResolverGroup()Return theAddressResolverGroupinstance for DNS resolution.static ClientResources.Builderbuilder()Create a newClientResourcesusing default settings.EventPublisherOptionscommandLatencyPublisherOptions()Return theEventPublisherOptionsfor latency event publishing.CommandLatencyRecordercommandLatencyRecorder()Return theCommandLatencyRecorder.intcomputationThreadPoolSize()Return the pool size (number of threads) for all computation tasks.static ClientResourcescreate()Create a newClientResourcesusing default settings.static ClientResourcescreate(ThreadFactoryProvider threadFactoryProvider)Create a newClientResourcesusing default settings.DnsResolverdnsResolver()Return theDnsResolver.EventBuseventBus()Return the event bus used to publish events.EventExecutorGroupeventExecutorGroup()Return the computation pool used for internal operations.EventLoopGroupProvidereventLoopGroupProvider()Return theEventLoopGroupProviderthat provides access to the particularevent loop groups.intioThreadPoolSize()Return the pool size (number of threads) for IO threads.ClientResources.Buildermutate()Return a builder to create newClientResourceswhose settings are replicated from the currentClientResources.NettyCustomizernettyCustomizer()Return theNettyCustomizerto customize netty components.DelayreconnectDelay()Return theDelayfor reconnect attempts.Future<Boolean>shutdown()Shutdown theClientResources.Future<Boolean>shutdown(long quietPeriod, long timeout, TimeUnit timeUnit)Shutdown theClientResources.SocketAddressResolversocketAddressResolver()Return theSocketAddressResolver.Timertimer()Return theTimerto schedule events.Tracingtracing()Return theTracinginstance to support tracing of Redis commands.
-
Method Details
-
create
Create a newClientResourcesusing default settings.- Returns:
- a new instance of default client resources.
-
create
Create a newClientResourcesusing default settings.- Parameters:
threadFactoryProvider- provides aThreadFactoryto create threads.- Returns:
- a new instance of default client resources.
- Since:
- 6.1.1
-
builder
Create a newClientResourcesusing default settings.- Returns:
- a new instance of a default client resources.
-
mutate
ClientResources.Builder mutate()Return a builder to create newClientResourceswhose settings are replicated from the currentClientResources.- Returns:
- a
ClientResources.Builderto create newClientResourceswhose settings are replicated from the currentClientResources - Since:
- 5.1
-
shutdown
Shutdown theClientResources.- Returns:
- eventually the success/failure of the shutdown without errors.
-
shutdown
Shutdown theClientResources.- Parameters:
quietPeriod- the quiet period as described in the documentationtimeout- the maximum amount of time to wait until the executor is shutdown regardless if a task was submitted during the quiet periodtimeUnit- the unit ofquietPeriodandtimeout- Returns:
- eventually the success/failure of the shutdown without errors.
-
addressResolverGroup
AddressResolverGroup<?> addressResolverGroup()Return theAddressResolverGroupinstance for DNS resolution.- Returns:
- the address resolver group.
- Since:
- 6.1
-
commandLatencyPublisherOptions
EventPublisherOptions commandLatencyPublisherOptions()Return theEventPublisherOptionsfor latency event publishing.- Returns:
- the
EventPublisherOptionsfor latency event publishing.
-
commandLatencyRecorder
CommandLatencyRecorder commandLatencyRecorder()Return theCommandLatencyRecorder.- Returns:
- the command latency recorder.
- Since:
- 6.0
-
computationThreadPoolSize
int computationThreadPoolSize()Return the pool size (number of threads) for all computation tasks.- Returns:
- the pool size (number of threads to use).
-
dnsResolver
DnsResolver dnsResolver()Return theDnsResolver.- Returns:
- the DNS resolver.
- Since:
- 4.3
-
eventBus
EventBus eventBus()Return the event bus used to publish events.- Returns:
- the event bus
-
eventLoopGroupProvider
EventLoopGroupProvider eventLoopGroupProvider()Return theEventLoopGroupProviderthat provides access to the particularevent loop groups. lettuce requires at least two implementations:NioEventLoopGroupfor TCP/IP connections andEpollEventLoopGroupfor unix domain socket connections (epoll). You can useDefaultEventLoopGroupProvideras default implementation or implement an ownEventLoopGroupProviderto share existingEventLoopGroup'swith lettuce.- Returns:
- the
EventLoopGroupProviderwhich provides access to the particularevent loop groups
-
eventExecutorGroup
EventExecutorGroup eventExecutorGroup()Return the computation pool used for internal operations. Such tasks are periodic Redis Cluster and Redis Sentinel topology updates and scheduling of connection reconnection byConnectionWatchdog.- Returns:
- the computation pool used for internal operations
-
ioThreadPoolSize
int ioThreadPoolSize()Return the pool size (number of threads) for IO threads. The indicated size does not reflect the number for all IO threads. TCP and socket connections (epoll) require different IO pool.- Returns:
- the pool size (number of threads) for all IO tasks.
-
nettyCustomizer
NettyCustomizer nettyCustomizer()Return theNettyCustomizerto customize netty components.- Returns:
- the configured
NettyCustomizer. - Since:
- 4.4
-
reconnectDelay
Delay reconnectDelay()Return theDelayfor reconnect attempts. May return a different instance on each call.- Returns:
- the reconnect
Delay. - Since:
- 4.3
-
socketAddressResolver
SocketAddressResolver socketAddressResolver()Return theSocketAddressResolver.- Returns:
- the socket address resolver.
- Since:
- 5.1
-
timer
Timer timer()Return theTimerto schedule events. A timer object may run single- or multi-threaded but must be used for scheduling of short-running jobs only. Long-running jobs should be scheduled and executed usingeventExecutorGroup().- Returns:
- the timer.
- Since:
- 4.3
-
tracing
Tracing tracing()Return theTracinginstance to support tracing of Redis commands.- Returns:
- the configured
Tracing. - Since:
- 5.1
-