public class DefaultClientResources extends Object implements ClientResources
The DefaultClientResources instance is stateful, you have to shutdown the instance if you're no longer using it.
DefaultClientResources allow to configure:
ioThreadPoolSize, alternativelyeventLoopGroupProvider which is a provided instance of EventLoopGroupProvider. Higher precedence than
ioThreadPoolSize.eventExecutorGroup which is a provided instance of EventExecutorGroup. Higher precedence than
computationThreadPoolSize.eventBus which is a provided instance of EventBus.commandLatencyCollector which is a provided instance of CommandLatencyCollector
.dnsResolver which is a provided instance of DnsResolver.socketAddressResolver which is a provided instance of SocketAddressResolver.timer that is a provided instance of HashedWheelTimer.nettyCustomizer that is a provided instance of NettyCustomizer.tracerProvider that is a provided instance of TracerProvider.| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultClientResources.Builder
Builder for
DefaultClientResources. |
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_COMPUTATION_THREADS |
static int |
DEFAULT_IO_THREADS |
static NettyCustomizer |
DEFAULT_NETTY_CUSTOMIZER
Default (no-op)
NettyCustomizer. |
static Supplier<Delay> |
DEFAULT_RECONNECT_DELAY
Default delay
Supplier for Delay.exponential() delay. |
protected static io.netty.util.internal.logging.InternalLogger |
logger |
static int |
MIN_COMPUTATION_THREADS
Minimum number of computation threads.
|
static int |
MIN_IO_THREADS
Minimum number of I/O threads.
|
| Modifier | Constructor and Description |
|---|---|
protected |
DefaultClientResources(DefaultClientResources.Builder builder) |
| Modifier and Type | Method and Description |
|---|---|
static DefaultClientResources.Builder |
builder()
Returns a new
DefaultClientResources.Builder to construct DefaultClientResources. |
CommandLatencyCollector |
commandLatencyCollector()
Returns the
CommandLatencyCollector. |
EventPublisherOptions |
commandLatencyPublisherOptions()
Returns the
EventPublisherOptions for latency event publishing. |
int |
computationThreadPoolSize()
Returns the pool size (number of threads) for all computation tasks.
|
static DefaultClientResources |
create()
Create a new
DefaultClientResources using default settings. |
DnsResolver |
dnsResolver()
Returns the
DnsResolver. |
EventBus |
eventBus()
Returns the event bus used to publish events.
|
EventExecutorGroup |
eventExecutorGroup()
Returns the computation pool used for internal operations.
|
EventLoopGroupProvider |
eventLoopGroupProvider()
Returns the
EventLoopGroupProvider that provides access to the particular event loop groups. lettuce requires at least two implementations: NioEventLoopGroup for
TCP/IP connections and EpollEventLoopGroup for unix domain socket connections (epoll). |
protected void |
finalize() |
int |
ioThreadPoolSize()
Returns the pool size (number of threads) for IO threads.
|
DefaultClientResources.Builder |
mutate()
Returns a builder to create new
DefaultClientResources whose settings are replicated from the current
DefaultClientResources. |
NettyCustomizer |
nettyCustomizer()
Returns the
NettyCustomizer to customize netty components. |
Delay |
reconnectDelay()
Returns the
Delay for reconnect attempts. |
Future<Boolean> |
shutdown()
Shutdown the
ClientResources. |
Future<Boolean> |
shutdown(long quietPeriod,
long timeout,
TimeUnit timeUnit)
Shutdown the
ClientResources. |
SocketAddressResolver |
socketAddressResolver()
Returns the
SocketAddressResolver. |
Timer |
timer()
Returns the
Timer to schedule events. |
Tracing |
tracing()
Returns the
Tracing instance to support tracing of Redis commands. |
protected static final io.netty.util.internal.logging.InternalLogger logger
public static final int MIN_IO_THREADS
public static final int MIN_COMPUTATION_THREADS
public static final int DEFAULT_IO_THREADS
public static final int DEFAULT_COMPUTATION_THREADS
public static final Supplier<Delay> DEFAULT_RECONNECT_DELAY
Supplier for Delay.exponential() delay.public static final NettyCustomizer DEFAULT_NETTY_CUSTOMIZER
NettyCustomizer.protected DefaultClientResources(DefaultClientResources.Builder builder)
public static DefaultClientResources create()
DefaultClientResources using default settings.create in interface ClientResourcespublic static DefaultClientResources.Builder builder()
DefaultClientResources.Builder to construct DefaultClientResources.builder in interface ClientResourcesDefaultClientResources.Builder to construct DefaultClientResources.public DefaultClientResources.Builder mutate()
DefaultClientResources whose settings are replicated from the current
DefaultClientResources.
Note: The resulting DefaultClientResources retains shared state for Timer,
CommandLatencyCollector, EventExecutorGroup, and EventLoopGroupProvider if these are left
unchanged. Thus you need only to shut down the last created ClientResources instances. Shutdown affects any
previously created ClientResources.
mutate in interface ClientResourcesDefaultClientResources.Builder to create new DefaultClientResources whose settings are
replicated from the current DefaultClientResources.protected void finalize()
throws Throwable
public Future<Boolean> shutdown()
ClientResources.shutdown in interface ClientResourcespublic Future<Boolean> shutdown(long quietPeriod, long timeout, TimeUnit timeUnit)
ClientResources.shutdown in interface ClientResourcesquietPeriod - the quiet period as described in the documentation.timeout - the maximum amount of time to wait until the executor is shutdown regardless if a task was submitted
during the quiet period.timeUnit - the unit of quietPeriod and timeout.public EventLoopGroupProvider eventLoopGroupProvider()
ClientResourcesEventLoopGroupProvider that provides access to the particular event loop groups. lettuce requires at least two implementations: NioEventLoopGroup for
TCP/IP connections and EpollEventLoopGroup for unix domain socket connections (epoll).
You can use DefaultEventLoopGroupProvider as default implementation or implement an own
EventLoopGroupProvider to share existing EventLoopGroup's with lettuce.eventLoopGroupProvider in interface ClientResourcesEventLoopGroupProvider which provides access to the particular event loop groups.public EventExecutorGroup eventExecutorGroup()
ClientResourcesConnectionWatchdog.eventExecutorGroup in interface ClientResourcespublic int ioThreadPoolSize()
ClientResourcesioThreadPoolSize in interface ClientResourcespublic int computationThreadPoolSize()
ClientResourcescomputationThreadPoolSize in interface ClientResourcespublic EventBus eventBus()
ClientResourceseventBus in interface ClientResourcespublic Timer timer()
ClientResourcesTimer to 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 using
ClientResources.eventExecutorGroup().timer in interface ClientResourcespublic CommandLatencyCollector commandLatencyCollector()
ClientResourcesCommandLatencyCollector.commandLatencyCollector in interface ClientResourcespublic EventPublisherOptions commandLatencyPublisherOptions()
ClientResourcesEventPublisherOptions for latency event publishing.commandLatencyPublisherOptions in interface ClientResourcesEventPublisherOptions for latency event publishing.public DnsResolver dnsResolver()
ClientResourcesDnsResolver.dnsResolver in interface ClientResourcespublic SocketAddressResolver socketAddressResolver()
ClientResourcesSocketAddressResolver.socketAddressResolver in interface ClientResourcespublic Delay reconnectDelay()
ClientResourcesDelay for reconnect attempts. May return a different instance on each call.reconnectDelay in interface ClientResourcesDelay.public NettyCustomizer nettyCustomizer()
ClientResourcesNettyCustomizer to customize netty components.nettyCustomizer in interface ClientResourcesNettyCustomizer.public Tracing tracing()
ClientResourcesTracing instance to support tracing of Redis commands.tracing in interface ClientResourcesTracing.Copyright © 2021 lettuce.io. All rights reserved.