Package io.strimzi.test.container
Class StrimziKafkaCluster.StrimziKafkaClusterBuilder
java.lang.Object
io.strimzi.test.container.StrimziKafkaCluster.StrimziKafkaClusterBuilder
- Enclosing class:
- StrimziKafkaCluster
Builder class for
StrimziKafkaCluster.
Use this builder to create instances of StrimziKafkaCluster with customized configurations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds and returns aStrimziKafkaClusterinstance based on the provided configurations.withAdditionalKafkaConfiguration(Map<String, String> additionalKafkaConfiguration) Adds additional Kafka configuration parameters.Configures the cluster to use dedicated controller and broker nodes instead of combined-role nodes.withInternalTopicReplicationFactor(int internalTopicReplicationFactor) Sets the internal topic replication factor for Kafka brokers.withKafkaVersion(String kafkaVersion) Specifies the Kafka version to be used for the brokers in the cluster.Fluent method to enable log collection with a default log file path.withLogCollection(String logFilePath) Fluent method to enable log collection for all containers in the cluster with a custom log file path.withNumberOfBrokers(int brokersNum) Sets the number of Kafka brokers in the cluster.withNumberOfControllers(int controllersNum) Sets the number of dedicated controller nodes when using combined roles.withProxyContainer(org.testcontainers.containers.ToxiproxyContainer proxyContainer) Sets aToxiproxyContainerto simulate network conditions such as latency or disconnection.Enables a shared Docker network for the Kafka cluster.
-
Constructor Details
-
StrimziKafkaClusterBuilder
public StrimziKafkaClusterBuilder()
-
-
Method Details
-
withNumberOfBrokers
Sets the number of Kafka brokers in the cluster.- Parameters:
brokersNum- the number of Kafka brokers- Returns:
- the current instance of
StrimziConnectClusterBuilderfor 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
StrimziConnectClusterBuilderfor 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
StrimziConnectClusterBuilderfor method chaining
-
withProxyContainer
public StrimziKafkaCluster.StrimziKafkaClusterBuilder withProxyContainer(org.testcontainers.containers.ToxiproxyContainer proxyContainer) Sets aToxiproxyContainerto simulate network conditions such as latency or disconnection.- Parameters:
proxyContainer- the proxy container for simulating network conditions- Returns:
- the current instance of
StrimziConnectClusterBuilderfor method chaining
-
withKafkaVersion
Specifies the Kafka version to be used for the brokers in the cluster. If no version is provided, the latest Kafka version available fromKafkaVersionServicewill be used.- Parameters:
kafkaVersion- the desired Kafka version for the cluster- Returns:
- the current instance of
StrimziConnectClusterBuilderfor 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 usingwithNumberOfControllers(int).- Returns:
- the current instance of
StrimziKafkaClusterBuilderfor method chaining
-
withNumberOfControllers
Sets the number of dedicated controller nodes when using combined roles. This method should be used in conjunction withwithDedicatedRoles().- Parameters:
controllersNum- the number of dedicated controller nodes- Returns:
- the current instance of
StrimziKafkaClusterBuilderfor 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
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
StrimziKafkaClusterBuilderfor method chaining
-
build
Builds and returns aStrimziKafkaClusterinstance based on the provided configurations.- Returns:
- a new instance of
StrimziKafkaCluster
-