java.lang.Object
io.lettuce.core.resource.DefaultClientResources
- All Implemented Interfaces:
ClientResources
public class DefaultClientResources extends Object implements ClientResources
Default instance of the client resources.
The DefaultClientResources instance is stateful, you have to shutdown the instance if you're no longer using it.
DefaultClientResources allow to configure:
- a
addressResolverGroupthat is a provided instance ofAddressResolverGroup. - a
commandLatencyRecorderwhich is a provided instance ofCommandLatencyRecorder - a
dnsResolverwhich is a provided instance ofDnsResolver. - an
eventBuswhich is a provided instance ofEventBus. .
- the
ioThreadPoolSize, alternatively - a
eventLoopGroupProviderwhich is a provided instance ofEventLoopGroupProvider. Higher precedence thanioThreadPoolSize. - computationThreadPoolSize
- a
eventExecutorGroupwhich is a provided instance ofEventExecutorGroup. Higher precedence thancomputationThreadPoolSize. - a
nettyCustomizerthat is a provided instance ofNettyCustomizer. - a
socketAddressResolverwhich is a provided instance ofSocketAddressResolver. - a
threadFactoryProviderto provide aThreadFactoryfor default timer, event loop and event executor instances. - a
timerthat is a provided instance ofHashedWheelTimer. - a
tracingthat is a provided instance ofTracing.
- Since:
- 3.4
- Author:
- Mark Paluch, Yohei Ueki
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultClientResources.BuilderBuilder forDefaultClientResources. -
Field Summary
Fields Modifier and Type Field Description static AddressResolverGroup<?>DEFAULT_ADDRESS_RESOLVER_GROUPDefaultAddressResolverGroup.static intDEFAULT_COMPUTATION_THREADSstatic intDEFAULT_IO_THREADSstatic NettyCustomizerDEFAULT_NETTY_CUSTOMIZERDefault (no-op)NettyCustomizer.static Supplier<Delay>DEFAULT_RECONNECT_DELAYDefault delaySupplierforDelay.exponential()delay.protected static io.netty.util.internal.logging.InternalLoggerloggerstatic intMIN_COMPUTATION_THREADSMinimum number of computation threads.static intMIN_IO_THREADSMinimum number of I/O threads. -
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultClientResources(DefaultClientResources.Builder builder) -
Method Summary
Modifier and Type Method Description AddressResolverGroup<?>addressResolverGroup()Return theAddressResolverGroupinstance for DNS resolution.static DefaultClientResources.Builderbuilder()Returns a newDefaultClientResources.Builderto constructDefaultClientResources.EventPublisherOptionscommandLatencyPublisherOptions()Return theEventPublisherOptionsfor latency event publishing.CommandLatencyRecordercommandLatencyRecorder()Return theCommandLatencyRecorder.intcomputationThreadPoolSize()Return the pool size (number of threads) for all computation tasks.static DefaultClientResourcescreate()Create a newDefaultClientResourcesusing 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.protected voidfinalize()intioThreadPoolSize()Return the pool size (number of threads) for IO threads.DefaultClientResources.Buildermutate()Returns a builder to create newDefaultClientResourceswhose settings are replicated from the currentDefaultClientResources.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.
-
Field Details
-
logger
protected static final io.netty.util.internal.logging.InternalLogger logger -
MIN_IO_THREADS
public static final int MIN_IO_THREADSMinimum number of I/O threads.- See Also:
- Constant Field Values
-
MIN_COMPUTATION_THREADS
public static final int MIN_COMPUTATION_THREADSMinimum number of computation threads.- See Also:
- Constant Field Values
-
DEFAULT_IO_THREADS
public static final int DEFAULT_IO_THREADS -
DEFAULT_COMPUTATION_THREADS
public static final int DEFAULT_COMPUTATION_THREADS -
DEFAULT_RECONNECT_DELAY
Default delaySupplierforDelay.exponential()delay. -
DEFAULT_NETTY_CUSTOMIZER
Default (no-op)NettyCustomizer. -
DEFAULT_ADDRESS_RESOLVER_GROUP
DefaultAddressResolverGroup.
-
-
Constructor Details
-
DefaultClientResources
-
-
Method Details
-
create
Create a newDefaultClientResourcesusing default settings.- Returns:
- a new instance of a default client resources.
-
builder
Returns a newDefaultClientResources.Builderto constructDefaultClientResources.- Returns:
- a new
DefaultClientResources.Builderto constructDefaultClientResources.
-
mutate
Returns a builder to create newDefaultClientResourceswhose settings are replicated from the currentDefaultClientResources.Note: The resulting
DefaultClientResourcesretains shared state forTimer,CommandLatencyRecorder,EventExecutorGroup, andEventLoopGroupProviderif these are left unchanged. Thus you need only to shut down the last createdClientResourcesinstances. Shutdown affects any previously createdClientResources.- Specified by:
mutatein interfaceClientResources- Returns:
- a
DefaultClientResources.Builderto create newDefaultClientResourceswhose settings are replicated from the currentDefaultClientResources. - Since:
- 5.1
-
finalize
-
shutdown
Shutdown theClientResources.- Specified by:
shutdownin interfaceClientResources- Returns:
- eventually the success/failure of the shutdown without errors.
-
shutdown
Shutdown theClientResources.- Specified by:
shutdownin interfaceClientResources- 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.
-
commandLatencyRecorder
Description copied from interface:ClientResourcesReturn theCommandLatencyRecorder.- Specified by:
commandLatencyRecorderin interfaceClientResources- Returns:
- the command latency recorder.
-
commandLatencyPublisherOptions
Description copied from interface:ClientResourcesReturn theEventPublisherOptionsfor latency event publishing.- Specified by:
commandLatencyPublisherOptionsin interfaceClientResources- Returns:
- the
EventPublisherOptionsfor latency event publishing.
-
computationThreadPoolSize
public int computationThreadPoolSize()Description copied from interface:ClientResourcesReturn the pool size (number of threads) for all computation tasks.- Specified by:
computationThreadPoolSizein interfaceClientResources- Returns:
- the pool size (number of threads to use).
-
dnsResolver
Description copied from interface:ClientResourcesReturn theDnsResolver.- Specified by:
dnsResolverin interfaceClientResources- Returns:
- the DNS resolver.
-
eventBus
Description copied from interface:ClientResourcesReturn the event bus used to publish events.- Specified by:
eventBusin interfaceClientResources- Returns:
- the event bus
-
eventLoopGroupProvider
Description copied from interface:ClientResourcesReturn 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.- Specified by:
eventLoopGroupProviderin interfaceClientResources- Returns:
- the
EventLoopGroupProviderwhich provides access to the particularevent loop groups
-
eventExecutorGroup
Description copied from interface:ClientResourcesReturn the computation pool used for internal operations. Such tasks are periodic Redis Cluster and Redis Sentinel topology updates and scheduling of connection reconnection byConnectionWatchdog.- Specified by:
eventExecutorGroupin interfaceClientResources- Returns:
- the computation pool used for internal operations
-
ioThreadPoolSize
public int ioThreadPoolSize()Description copied from interface:ClientResourcesReturn 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.- Specified by:
ioThreadPoolSizein interfaceClientResources- Returns:
- the pool size (number of threads) for all IO tasks.
-
nettyCustomizer
Description copied from interface:ClientResourcesReturn theNettyCustomizerto customize netty components.- Specified by:
nettyCustomizerin interfaceClientResources- Returns:
- the configured
NettyCustomizer.
-
reconnectDelay
Description copied from interface:ClientResourcesReturn theDelayfor reconnect attempts. May return a different instance on each call.- Specified by:
reconnectDelayin interfaceClientResources- Returns:
- the reconnect
Delay.
-
socketAddressResolver
Description copied from interface:ClientResourcesReturn theSocketAddressResolver.- Specified by:
socketAddressResolverin interfaceClientResources- Returns:
- the socket address resolver.
-
timer
Description copied from interface:ClientResourcesReturn 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 usingClientResources.eventExecutorGroup().- Specified by:
timerin interfaceClientResources- Returns:
- the timer.
-
tracing
Description copied from interface:ClientResourcesReturn theTracinginstance to support tracing of Redis commands.- Specified by:
tracingin interfaceClientResources- Returns:
- the configured
Tracing.
-
addressResolverGroup
Description copied from interface:ClientResourcesReturn theAddressResolverGroupinstance for DNS resolution.- Specified by:
addressResolverGroupin interfaceClientResources- Returns:
- the address resolver group.
-