Class K3aEmbedded.Builder

java.lang.Object
no.shhsoft.k3aembedded.K3aEmbedded.Builder
Enclosing class:
K3aEmbedded

public static final class K3aEmbedded.Builder extends Object
Builder for K3aEmbedded instances.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • build

      public K3aEmbedded build()
      Builds a K3aEmbedded instance based on builder settings.
      Returns:
      a new K3aEmbedded.
    • kraftMode

      public K3aEmbedded.Builder kraftMode(boolean kraftMode)
      Specifies whether or not to use KRaft mode. The default is true. If false is specified, the resulting K3aEmbedded will spawn a ZooKeeper in addition to a broker.
      Parameters:
      kraftMode - whether or not to use KRaft mode
      Returns:
      this
    • brokerPort

      public K3aEmbedded.Builder brokerPort(int 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

      public K3aEmbedded.Builder controllerPort(int 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

      public K3aEmbedded.Builder zooKeeperPort(int 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

      public K3aEmbedded.Builder additionalPorts(int numAdditionalPorts)
      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

      public K3aEmbedded.Builder additionalConfiguration(Map<String,Object> 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 name
      securityProtocol - the security protocol of the listener
      port - 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 the additionalPorts method.
      Parameters:
      name - the listener name
      securityProtocol - the security protocol of the listener
      portIndex - an index between 0 and additionalPorts - 1
      Returns:
      this
    • additionalConfigurationProvider

      public K3aEmbedded.Builder additionalConfigurationProvider(K3aEmbedded.AdditionalConfigurationProvider additionalConfigurationProvider)
      Sets up an AdditionalConfigurationProvider that 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 - the AdditionalConfigurationProvider
      Returns:
      this