Package io.kroxylicious.proxy.service
Interface NodeIdentificationStrategy
public interface NodeIdentificationStrategy
This is the Strategy for how we expose a virtual kafka cluster on the network. The aim is
to manifest network endpoints such that we can identify which gateway and upstream node the
client wants to connect to.
The strategy may require 'exclusive' ports that cannot be shared with any other gateways.
These are typically used when the only mechanism available to identify the gateway and
upstream broker is the port.
The strategy may require 'shared' ports that can be shared with other gateways. For example
a strategy using TLS with SNI to identify the gateway and broker could share that port with
other gateways that want to use TLS and SNI.
The strategy also controls how we advertise the broker addresses to the clients, so that we can do
things like set a different advertised port, in case there is routing technology between the client
and proxy.
-
Method Summary
Modifier and TypeMethodDescriptionMap of discovery addresses that will be bound by the virtual cluster on start-up (before the first reconcile has taken place).default HostPortgetAdvertisedBrokerAddress(int nodeId) Advertised address of broker with the given node id, (advertised hostname and advertised port).Gets the bind address used when binding socket.getBrokerAddress(int nodeId) Address of broker with the given node id, (advertised hostname and bind port).default IntegergetBrokerIdFromBrokerAddress(HostPort brokerAddress) Generates the node id implied by the given broker address (advertised hostname and bind port).Address of the cluster's bootstrap address.Set of ports number that this provider requires exclusive use.Set of ports number that this provider can share with another provider.default booleanIndicates if the provider requires that connections utilise the Server Name Indication (SNI) extension to TLS.
-
Method Details
-
getClusterBootstrapAddress
HostPort getClusterBootstrapAddress()Address of the cluster's bootstrap address.- Returns:
- cluster's bootstrap address.
-
getBrokerAddress
Address of broker with the given node id, (advertised hostname and bind port). Note thatnodeIdare generally expected to be consecutively numbered and starting from zero. However, gaps in the sequence can potentially emerge as the target cluster topology evolves.- Parameters:
nodeId- node identifier- Returns:
- broker address
- Throws:
IllegalArgumentException- if this provider cannot produce a broker address for the given nodeId.
-
getAdvertisedBrokerAddress
Advertised address of broker with the given node id, (advertised hostname and advertised port). This is what is returned to clients and may differ from the node's bind port as presented bygetBrokerAddress(int). This enables Kroxylicious to sit behind yet another proxy that uses a different port from the kroxylicious bind port.- Parameters:
nodeId- node id- Returns:
- the port to advertise for the nodeId
- Throws:
IllegalArgumentException- if this provider cannot produce a broker address for the given nodeId.
-
getBrokerIdFromBrokerAddress
Generates the node id implied by the given broker address (advertised hostname and bind port). This method make sense only for implementation that embed node id information into the broker address. This information is used at startup time to allow a client that already in possession of a broker address to reconnect to the cluster via Kroxylicious using only that address.
This is an optional method. An implementation can return null.- Parameters:
brokerAddress- broker address- Returns:
- a broker id or null if the broker id cannot be
-
getBindAddress
Gets the bind address used when binding socket. Used to restrict listening to particular network interfaces.- Returns:
- bind address such as "127.0.0.1" or Optional.empty()} if all address should be bound.
-
requiresServerNameIndication
default boolean requiresServerNameIndication()Indicates if the provider requires that connections utilise the Server Name Indication (SNI) extension to TLS. If this is true, then the provider cannot support plain connections.- Returns:
- true if this provider requires Server Name Indication (SNI).
-
getExclusivePorts
Set of ports number that this provider requires exclusive use.- Returns:
- set of port numbers
-
discoveryAddressMap
Map of discovery addresses that will be bound by the virtual cluster on start-up (before the first reconcile has taken place). Discovery bindings always point to a target cluster's bootstrap and are used for purposes of metadata discovery only.
Discovery bindings are replaced by bindings to upstream brokers on reconciliation.- Returns:
- discovery address map
-