Class VirtualClusterModel

java.lang.Object
io.kroxylicious.proxy.model.VirtualClusterModel
All Implemented Interfaces:
AutoCloseable

public class VirtualClusterModel extends Object implements AutoCloseable
Runtime representation of a virtual cluster: its name, target Kafka cluster, gateways, TLS configuration, and the components whose lifecycle is bound to this VC.

Owned resources

The VCM owns and is responsible for closing two per-VC components directly: For VCs that use dynamic routing, the DynamicRouting instance carries and owns the RouterChainFactory; the VCM closes it via the routing model.

Lifecycle

The VCM is created when the VC is configured (or reconfigured via hot-reload), and closed via close() when the VC's lifecycle reaches Stopped. The VirtualClusterRegistry drives the close.

close() is idempotent: the underlying components guard against double-close, so accidental redundant close calls are safe.

  • Field Details

    • DEFAULT_SOCKET_FRAME_MAX_SIZE_BYTES

      public static final int DEFAULT_SOCKET_FRAME_MAX_SIZE_BYTES
      See Also:
  • Constructor Details

  • Method Details

    • filterChainFactory

      public FilterChainFactory filterChainFactory()
      Returns this VC's filter chain factory. The returned factory is alive for the lifetime of this VCM; closing the VCM (via close(), driven by VirtualClusterRegistry on transition into Stopped) also closes the FCF. Callers should not retain the reference past the VC's lifetime.
    • createRouter

      public io.kroxylicious.proxy.router.Router createRouter()
    • drainTimeout

      public Duration drainTimeout()
    • routing

      public RoutingModel routing()
    • logVirtualClusterSummary

      public void logVirtualClusterSummary()
    • addGateway

      public void addGateway(String name, NodeIdentificationStrategy nodeIdentificationStrategy, Optional<io.kroxylicious.proxy.config.tls.Tls> tls)
    • getClusterName

      public String getClusterName()
    • isLogNetwork

      public boolean isLogNetwork()
    • isLogFrames

      public boolean isLogFrames()
    • socketFrameMaxSizeBytes

      public int socketFrameMaxSizeBytes()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getUpstreamClusterForRoute

      @Nullable public UpstreamClusterModel getUpstreamClusterForRoute(String routeName)
      Returns the UpstreamClusterModel for a specific route, or null if the route does not target an upstream cluster (e.g. it targets a nested router).
    • close

      public void close()
      Closes resources associated with this virtual cluster — the TLS credential supplier manager(s) held by the routing model and the FilterChainFactory. Called by VirtualClusterRegistry on lifecycle transition into Stopped. Safe to call multiple times — the FCF's underlying Wrapper.close is idempotent via an internal AtomicBoolean, and TlsCredentialSupplierManager.close tolerates re-entry.
      Specified by:
      close in interface AutoCloseable
    • usesDynamicTlsCredentials

      public boolean usesDynamicTlsCredentials()
      Checks if this virtual cluster uses dynamic TLS credential supplier.
      Returns:
      true if a credential supplier is configured
    • configureTrustProvider

      public static NettyTrustProvider configureTrustProvider(io.kroxylicious.proxy.config.tls.Tls tlsConfiguration)
    • configureCipherSuites

      public static void configureCipherSuites(io.netty.handler.ssl.SslContextBuilder sslContextBuilder, io.kroxylicious.proxy.config.tls.Tls tlsConfiguration)
    • configureEnabledProtocols

      public static void configureEnabledProtocols(io.netty.handler.ssl.SslContextBuilder sslContextBuilder, io.kroxylicious.proxy.config.tls.Tls tlsConfiguration)
    • getFilters

      public List<NamedFilterDefinition> getFilters()
    • gateways

      public Map<String,EndpointGateway> gateways()
    • subjectBuilder

      public io.kroxylicious.proxy.authentication.TransportSubjectBuilder subjectBuilder(PluginFactoryRegistry pfr)
    • getTopicNameCacheFilter

      public TopicNameCacheFilter getTopicNameCacheFilter()