Package no.shhsoft.k3aembedded
Class K3aEmbedded.Builder
java.lang.Object
no.shhsoft.k3aembedded.K3aEmbedded.Builder
- Enclosing class:
- K3aEmbedded
Builder for
K3aEmbedded instances.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadditionalConfiguration(Map<String, Object> additionalConfiguration) Gives additional broker configuration options.additionalConfigurationProvider(K3aEmbedded.AdditionalConfigurationProvider additionalConfigurationProvider) Sets up anAdditionalConfigurationProviderthat will be called after every other configuration has been settled.additionalListenerWithFixedPort(String name, String securityProtocol, int port) Adds an extra listener.additionalListenerWithPortIndex(String name, String securityProtocol, int portIndex) Adds an extra listener bound to a random port.additionalPorts(int numAdditionalPorts) Allocates additional, random ports that may be used to set up extra listeners beyond the default.brokerPort(int brokerPort) Assigns a fixed port to the broker listener.build()Builds aK3aEmbeddedinstance based on builder settings.controllerPort(int controllerPort) Assigns a fixed port to the controller listener.kraftMode(boolean kraftMode) Specifies whether to use KRaft mode.zooKeeperPort(int zooKeeperPort) Assigns a fixed port to the controller ZooKeeper.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
Builds aK3aEmbeddedinstance based on builder settings.- Returns:
- a new
K3aEmbedded.
-
kraftMode
Specifies whether to use KRaft mode. The default istrue. Iffalseis specified, the resultingK3aEmbeddedwill spawn a ZooKeeper in addition to a broker.- Parameters:
kraftMode- whether to use KRaft mode- Returns:
this
-
brokerPort
Assigns a fixed port to the broker listener. The default is to assign a random port to the broker.- Parameters:
brokerPort- the broker port- Returns:
this
-
controllerPort
Assigns a fixed port to the controller listener. The default is to assign a random port to the controller.- Parameters:
controllerPort- the controller port- Returns:
this
-
zooKeeperPort
Assigns a fixed port to the controller ZooKeeper. The default is to assign a random port.- Parameters:
zooKeeperPort- the ZooKeeper port- Returns:
this
-
additionalPorts
Allocates additional, random ports that may be used to set up extra listeners beyond the default.- Parameters:
numAdditionalPorts- number of extra ports to allocate- Returns:
this
-
additionalConfiguration
Gives additional broker configuration options. The options will be added to, or override the defaults.- Parameters:
additionalConfiguration- the configuration map- Returns:
this
-
additionalListenerWithFixedPort
public K3aEmbedded.Builder additionalListenerWithFixedPort(String name, String securityProtocol, int port) Adds an extra listener.- Parameters:
name- the listener namesecurityProtocol- the security protocol of the listenerport- the (fixed) port the listener binds to- Returns:
this
-
additionalListenerWithPortIndex
public K3aEmbedded.Builder additionalListenerWithPortIndex(String name, String securityProtocol, int portIndex) Adds an extra listener bound to a random port. Requires that additional random ports have been allocated through theadditionalPortsmethod.- Parameters:
name- the listener namesecurityProtocol- the security protocol of the listenerportIndex- an index between0andadditionalPorts - 1- Returns:
this
-
additionalConfigurationProvider
public K3aEmbedded.Builder additionalConfigurationProvider(K3aEmbedded.AdditionalConfigurationProvider additionalConfigurationProvider) Sets up anAdditionalConfigurationProviderthat will be called after every other configuration has been settled. Not often needed, except in cases where the additional configuration relies on the random ports.- Parameters:
additionalConfigurationProvider- theAdditionalConfigurationProvider- Returns:
this
-