Class StrimziKafkaCluster.StrimziKafkaClusterBuilder

java.lang.Object
io.strimzi.test.container.StrimziKafkaCluster.StrimziKafkaClusterBuilder
Enclosing class:
StrimziKafkaCluster

public static class StrimziKafkaCluster.StrimziKafkaClusterBuilder extends Object
Builder class for StrimziKafkaCluster.

Use this builder to create instances of StrimziKafkaCluster with customized configurations.

  • Constructor Details

    • StrimziKafkaClusterBuilder

      public StrimziKafkaClusterBuilder()
  • Method Details

    • withNumberOfBrokers

      public StrimziKafkaCluster.StrimziKafkaClusterBuilder withNumberOfBrokers(int brokersNum)
      Sets the number of Kafka brokers in the cluster.
      Parameters:
      brokersNum - the number of Kafka brokers
      Returns:
      the current instance of StrimziConnectClusterBuilder for method chaining
    • withInternalTopicReplicationFactor

      public StrimziKafkaCluster.StrimziKafkaClusterBuilder withInternalTopicReplicationFactor(int internalTopicReplicationFactor)
      Sets the internal topic replication factor for Kafka brokers. If not provided, it defaults to the number of brokers.
      Parameters:
      internalTopicReplicationFactor - the replication factor for internal topics
      Returns:
      the current instance of StrimziConnectClusterBuilder for method chaining
    • withAdditionalKafkaConfiguration

      public StrimziKafkaCluster.StrimziKafkaClusterBuilder withAdditionalKafkaConfiguration(Map<String,String> additionalKafkaConfiguration)
      Adds additional Kafka configuration parameters. These configurations are applied to all brokers in the cluster.
      Parameters:
      additionalKafkaConfiguration - a map of additional Kafka configuration options
      Returns:
      the current instance of StrimziConnectClusterBuilder for method chaining
    • withProxyContainer

      public StrimziKafkaCluster.StrimziKafkaClusterBuilder withProxyContainer(org.testcontainers.containers.ToxiproxyContainer proxyContainer)
      Sets a ToxiproxyContainer to simulate network conditions such as latency or disconnection.
      Parameters:
      proxyContainer - the proxy container for simulating network conditions
      Returns:
      the current instance of StrimziConnectClusterBuilder for method chaining
    • withSharedNetwork

      Enables a shared Docker network for the Kafka cluster. This allows the Kafka cluster to interact with other containers on the same network.
      Returns:
      the current instance of StrimziConnectClusterBuilder for method chaining
    • withKafkaVersion

      public StrimziKafkaCluster.StrimziKafkaClusterBuilder withKafkaVersion(String kafkaVersion)
      Specifies the Kafka version to be used for the brokers in the cluster. If no version is provided, the latest Kafka version available from KafkaVersionService will be used.
      Parameters:
      kafkaVersion - the desired Kafka version for the cluster
      Returns:
      the current instance of StrimziConnectClusterBuilder for method chaining
    • withDedicatedRoles

      Configures the cluster to use dedicated controller and broker nodes instead of combined-role nodes. When enabled, you must also specify the number of controllers using withNumberOfControllers(int).
      Returns:
      the current instance of StrimziKafkaClusterBuilder for method chaining
    • withNumberOfControllers

      public StrimziKafkaCluster.StrimziKafkaClusterBuilder withNumberOfControllers(int controllersNum)
      Sets the number of dedicated controller nodes when using combined roles. This method should be used in conjunction with withDedicatedRoles().
      Parameters:
      controllersNum - the number of dedicated controller nodes
      Returns:
      the current instance of StrimziKafkaClusterBuilder for method chaining
    • withLogCollection

      Fluent method to enable log collection with a default log file path. The actual filename is determined at runtime when logs are collected.
      Returns:
      StrimziKafkaContainer instance for method chaining
    • withLogCollection

      public StrimziKafkaCluster.StrimziKafkaClusterBuilder withLogCollection(String logFilePath)
      Fluent method to enable log collection for all containers in the cluster with a custom log file path. If the path ends with "/", role-based filenames are automatically appended at runtime for each container: Controller-only: "kafka-controller-{nodeId}.log" Broker-only: "kafka-broker-{brokerId}.log" Combined: "kafka-container-{brokerId}.log" otherwise, the path doesn't end with "/", it's used as the exact filename base for all containers
      Parameters:
      logFilePath - the base path where container logs will be saved. Use "/" suffix for automatic role-based naming.
      Returns:
      the current instance of StrimziKafkaClusterBuilder for method chaining
    • build

      public StrimziKafkaCluster build()
      Builds and returns a StrimziKafkaCluster instance based on the provided configurations.
      Returns:
      a new instance of StrimziKafkaCluster