public class IoEnvironment extends Object
IoEnvironment
holds the I/O event loops and state.
Note that this class only contains tunables and state for the I/O event loops that drive the actual operations
inside netty. If you are looking for general configuration if I/O properties, those are located inside the
IoConfig
class instead.
By default the IO environment creates 3 distinct EventLoopGroups
. One for HTTP services
(which includes query, search, analytics and views), one for the KV service and one for the management service. The
HTTP and the KV service try to occupy a "fair" number of thread pools for each. Usually it will be half the number
of reported logical CPUs by the JVM, but maximum of 8 and minimum of 2 each. The management service will only ever
occupy one thread. The HTTP and KV thread pools are split in SDK 3 (they were not in SDK 2) so that longer running
N1QL queries and larger streaming results do not interfere with high-throughput low-latency KV workloads as much.
By default, the SDK will use "native" event loop groups - epoll on linux and kqueue on OSX in favor of the more
generic and slower NIO transport. This should work fine out of the box nearly always, but you can disable it through
the enableNativeIo(boolean)
builder setting.
You cannot re-use your own event loop groups from your own application because the SDK ships a repackaged netty version to avoid version and classpath issues.
Modifier and Type | Class and Description |
---|---|
static class |
IoEnvironment.Builder |
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_NATIVE_IO_ENABLED
Native IO is enabled by default.
|
Modifier and Type | Method and Description |
---|---|
Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> |
analyticsEventLoopGroup()
Returns the
EventLoopGroup to be used for analytics traffic. |
static IoEnvironment.Builder |
analyticsEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Allows to specify a custom event loop group (I/O event loop thread pool) for the analytics service.
|
static IoEnvironment.Builder |
builder()
Creates a Builder for the
IoEnvironment to customize its settings. |
static IoEnvironment |
create()
Creates the
IoEnvironment with default settings. |
static IoEnvironment.Builder |
enableNativeIo(boolean nativeIoEnabled)
If set to false (enabled by default) will force using the java NIO based IO transport.
|
static IoEnvironment.Builder |
eventLoopThreadCount(int eventLoopThreadCount)
Overrides the number of threads used per event loop.
|
Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> |
kvEventLoopGroup()
Returns the
EventLoopGroup to be used for Key/Value traffic. |
static IoEnvironment.Builder |
kvEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Allows to specify a custom event loop group (I/O event loop thread pool) for the management service.
|
Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> |
managerEventLoopGroup()
Returns the
EventLoopGroup to be used for config traffic. |
static IoEnvironment.Builder |
managerEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Allows to specify a custom event loop group (I/O event loop thread pool) for the management service.
|
boolean |
nativeIoEnabled()
Returns true if native IO is enabled and can be used if supported.
|
Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> |
queryEventLoopGroup()
Returns the
EventLoopGroup to be used for N1QL Query traffic. |
static IoEnvironment.Builder |
queryEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Allows to specify a custom event loop group (I/O event loop thread pool) for the query service.
|
Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> |
searchEventLoopGroup()
Returns the
EventLoopGroup to be used for search traffic. |
static IoEnvironment.Builder |
searchEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Allows to specify a custom event loop group (I/O event loop thread pool) for the search service.
|
Mono<Void> |
shutdown(Duration timeout)
Instructs all the owned event loops to shut down.
|
Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> |
viewEventLoopGroup()
Returns the
EventLoopGroup to be used for view traffic. |
static IoEnvironment.Builder |
viewEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Allows to specify a custom event loop group (I/O event loop thread pool) for the view service.
|
public static final boolean DEFAULT_NATIVE_IO_ENABLED
public static IoEnvironment create()
IoEnvironment
with default settings.public static IoEnvironment.Builder builder()
IoEnvironment
to customize its settings.IoEnvironment.Builder
to customize the settings.public static IoEnvironment.Builder managerEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Note that you usually do not need to tweak the event loop for the manager service, only if you perform long-running management queries that interfere with regular traffic.
Note: tweaking the dedicated event loops should be done with care and only after profiling
indicated that the default event loop setup is not achieving the desired performance characteristics. Please
see the javadoc for the IoEnvironment
class for an explanation how the event loops play together for
all the services and what effect a custom pool might have.
eventLoopGroup
- the dedicated event loop group to use.IoEnvironment.Builder
for chaining purposes.public static IoEnvironment.Builder kvEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Note: tweaking the dedicated event loops should be done with care and only after profiling
indicated that the default event loop setup is not achieving the desired performance characteristics. Please
see the javadoc for the IoEnvironment
class for an explanation how the event loops play together for
all the services and what effect a custom pool might have.
eventLoopGroup
- the dedicated event loop group to use.IoEnvironment.Builder
for chaining purposes.public static IoEnvironment.Builder queryEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Note: tweaking the dedicated event loops should be done with care and only after profiling
indicated that the default event loop setup is not achieving the desired performance characteristics. Please
see the javadoc for the IoEnvironment
class for an explanation how the event loops play together for
all the services and what effect a custom pool might have.
eventLoopGroup
- the dedicated event loop group to use.IoEnvironment.Builder
for chaining purposes.public static IoEnvironment.Builder analyticsEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Note: tweaking the dedicated event loops should be done with care and only after profiling
indicated that the default event loop setup is not achieving the desired performance characteristics. Please
see the javadoc for the IoEnvironment
class for an explanation how the event loops play together for
all the services and what effect a custom pool might have.
eventLoopGroup
- the dedicated event loop group to use.IoEnvironment.Builder
for chaining purposes.public static IoEnvironment.Builder searchEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Note: tweaking the dedicated event loops should be done with care and only after profiling
indicated that the default event loop setup is not achieving the desired performance characteristics. Please
see the javadoc for the IoEnvironment
class for an explanation how the event loops play together for
all the services and what effect a custom pool might have.
eventLoopGroup
- the dedicated event loop group to use.IoEnvironment.Builder
for chaining purposes.public static IoEnvironment.Builder viewEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup)
Note: tweaking the dedicated event loops should be done with care and only after profiling
indicated that the default event loop setup is not achieving the desired performance characteristics. Please
see the javadoc for the IoEnvironment
class for an explanation how the event loops play together for
all the services and what effect a custom pool might have.
eventLoopGroup
- the dedicated event loop group to use.IoEnvironment.Builder
for chaining purposes.public static IoEnvironment.Builder eventLoopThreadCount(int eventLoopThreadCount)
If not manually overridden, a fair thread count is calculated, see fairThreadCount()
for more
information on the heuristics.
Note that the count provided will only be used by event loops that the SDK creates. If you configure a custom
event loop (i.e. through kvEventLoopGroup(EventLoopGroup)
) you are responsible for sizing it
appropriately on your own.
eventLoopThreadCount
- the number of event loops to use per pool.IoEnvironment.Builder
for chaining purposes.public static IoEnvironment.Builder enableNativeIo(boolean nativeIoEnabled)
Usually the native transports used (epoll on linux and kqueue on OSX) are going to be faster and more efficient than the generic NIO one. We recommend to only set this to false if you experience issues with the native transports or instructed by couchbase support to do so for troubleshooting reasons.
nativeIoEnabled
- if native IO should be enabled or disabled.IoEnvironment.Builder
for chaining purposes.public Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> managerEventLoopGroup()
EventLoopGroup
to be used for config traffic.public Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> kvEventLoopGroup()
EventLoopGroup
to be used for Key/Value traffic.public Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> queryEventLoopGroup()
EventLoopGroup
to be used for N1QL Query traffic.public Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> analyticsEventLoopGroup()
EventLoopGroup
to be used for analytics traffic.public Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> searchEventLoopGroup()
EventLoopGroup
to be used for search traffic.public Supplier<com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup> viewEventLoopGroup()
EventLoopGroup
to be used for view traffic.public boolean nativeIoEnabled()
Copyright © 2020 Couchbase, Inc.. All rights reserved.