Interface SharedResources
- All Superinterfaces:
AutoCloseable
Each standalone client normally owns a full footprint: a background thread pool, its own gRPC
connections to every data server, and its own shard-assignment stream per namespace. When many
clients (or many sessions) run in a single process, this footprint dominates. A
SharedResources lets those clients multiplex over a shared transport instead:
- a single background thread pool;
- a single pool of gRPC connections;
- a single shard-assignment stream per
(serviceAddress, namespace).
Each client keeps its own sessions, ephemeral records, notifications and batching — closing an
individual client only releases that per-client state. The shared resources live until this
object is closed.
try (SharedResources shared = SharedResources.builder().numWorkerThreads(4).build()) {
AsyncOxiaClient c1 = OxiaClientBuilder.create("localhost:6648")
.sharedResources(shared)
.clientIdentifier("app-1")
.asyncClient()
.join();
// c1..cN share the executor, connections and shard-assignment stream.
} // releases the shared executor, connections and shard managers
Transport-level settings (TLS, authentication, connection keep-alive and pool size) are
governed by this object; a client built with OxiaClientBuilder.sharedResources(SharedResources) inherits them. Setting any transport-level option on such a client is a
configuration error, rejected with an IllegalArgumentException — configure them here
instead, and only share a pool between clients whose transport settings match.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic SharedResources.Builderbuilder()Create a new builder for aSharedResourcespool.voidclose()Release the shared executor, connections and shard-assignment streams.
-
Method Details
-
builder
Create a new builder for aSharedResourcespool.- Returns:
- the builder instance
-
close
void close()Release the shared executor, connections and shard-assignment streams.- Specified by:
closein interfaceAutoCloseable
-