Interface SharedResources

All Superinterfaces:
AutoCloseable

public interface SharedResources extends AutoCloseable
A pool of resources that can be shared by multiple Oxia client instances in the same JVM process.

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
    Modifier and Type
    Interface
    Description
    static interface 
    Builder for a SharedResources pool.
  • Method Summary

    Modifier and Type
    Method
    Description
    Create a new builder for a SharedResources pool.
    void
    Release the shared executor, connections and shard-assignment streams.
  • Method Details