Class TestClusterBuilder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a new Zeebe cluster.useRecordingExporter(boolean useRecordingExporter) If true, registers theRecordingExporterfor each broker.withBrokerConfig(BiConsumer<MemberId, TestStandaloneBroker> modifier) Sets the configuration function that will be executed in thebuild()method on each broker.withBrokerConfig(Consumer<TestStandaloneBroker> modifier) Sets the configuration function that will be executed in thebuild()method on each broker.withBrokersCount(int brokersCount) The number of brokers to create in this cluster.withEmbeddedGateway(boolean useEmbeddedGateway) If true, the brokers created by this cluster will use embedded gateways.withGatewayConfig(BiConsumer<MemberId, TestGateway<?>> modifier) Sets the configuration function that will be executed in thebuild()method on each gateway (including embedded gateways).withGatewayConfig(Consumer<TestGateway<?>> modifier) Sets the configuration function that will be executed in thebuild()method on each gateway (including embedded gateways).withGatewaysCount(int gatewaysCount) The number of standalone gateway to create in this cluster.Sets the name of the cluster.withNodeConfig(Consumer<TestApplication<?>> modifier) Sets the configuration function that will be executed in thebuild()method on both brokers and gateways (embedded gateways included).withPartitionsCount(int partitionsCount) Will set the number of partitions to distribute across the cluster.withReplicationFactor(int replicationFactor) Sets the replication factor for each partition in the cluster.
-
Constructor Details
-
TestClusterBuilder
public TestClusterBuilder()
-
-
Method Details
-
withEmbeddedGateway
If true, the brokers created by this cluster will use embedded gateways. By default this is true.- Parameters:
useEmbeddedGateway- true or false to enable the embedded gateway on the brokers- Returns:
- this builder instance for chaining
-
withGatewaysCount
The number of standalone gateway to create in this cluster. By default, this is 0, and the brokers have embedded gateways.Note that this parameter has no impact on the use of embedded gateways, and a cluster can contain both standalone and embedded gateways.
- Parameters:
gatewaysCount- the number of standalone gateways to create- Returns:
- this builder instance for chaining
-
withBrokersCount
The number of brokers to create in this cluster. By default, this is 1.Note that it's possible to create a cluster with no brokers, as this is could be a valid setup for testing purposes. If that's the case, the gateways will not wait for the topology to be complete (as they cannot know the topology), and will not be configured with a contact point.
NOTE: setting this to 0 will also set the replication factor and partitions count to 0.
- Parameters:
brokersCount- the number of brokers to create- Returns:
- this builder instance for chaining
-
withPartitionsCount
Will set the number of partitions to distribute across the cluster. For example, if there are 3 brokers, 3 partitions, but replication factor of 1, then each broker will get exactly one partition.Note that the number of partitions must be greater than or equal to 1! If you do not want to have any brokers, then set
withBrokersCount(int)to 0 instead.- Parameters:
partitionsCount- the number of partitions to distribute across the cluster- Returns:
- this builder instance for chaining
-
withReplicationFactor
Sets the replication factor for each partition in the cluster. Note that this cannot be less than 1, or greater than the broker count (seewithBrokersCount(int)).- Parameters:
replicationFactor- the replication factor for each partition- Returns:
- this builder instance for chaining
-
withName
Sets the name of the cluster. This can be used to prevent nodes in one cluster from inadvertently communicating with nodes in another cluster.Unless you're deploying multiple clusters in the same network, leave as is.
- Parameters:
name- the cluster name- Returns:
- this builder instance for chaining
-
withNodeConfig
Sets the configuration function that will be executed in thebuild()method on both brokers and gateways (embedded gateways included). NOTE: this configuration has the lowest priority, e.g. other configurations (gatewayConfigorbrokerConfig) will override this configuration in case of conflicts.- Parameters:
modifier- the function that will be applied on all cluster nodes- Returns:
- this builder instance for chaining
-
withGatewayConfig
Sets the configuration function that will be executed in thebuild()method on each gateway (including embedded gateways). The first argument of is the member ID of the gateway, and the second argument is the gateway itself.NOTE: in case of conflicts with
nodeConfigthis configuration will overridenodeConfig.NOTE: in case of conflicts with this configuration is an embedded gateway configuration and a broker configuration, broker configuration will override this configuration.
- Parameters:
modifier- the function that will be applied on all cluster gateways (embedded ones included)- Returns:
- this builder instance for chaining
-
withGatewayConfig
Sets the configuration function that will be executed in thebuild()method on each gateway (including embedded gateways).NOTE: in case of conflicts with
nodeConfigthis configuration will overridenodeConfig.NOTE: in case of conflicts with this configuration is an embedded gateway configuration and a broker configuration, broker configuration will override this configuration.
- Parameters:
modifier- the function that will be applied on all cluster gateways (embedded ones included)- Returns:
- this builder instance for chaining
-
withBrokerConfig
Sets the configuration function that will be executed in thebuild()method on each broker. The first argument is the broker ID, and the second argument is the broker itself.NOTE: in case of conflicts with
nodeConfigorgatewayConfigthis configuration will override them.- Parameters:
modifier- the function that will be applied on all cluster brokers- Returns:
- this builder instance for chaining
-
withBrokerConfig
Sets the configuration function that will be executed in thebuild()method on each broker.NOTE: in case of conflicts with
nodeConfigorgatewayConfigthis configuration will override them.- Parameters:
modifier- the function that will be applied on all cluster brokers- Returns:
- this builder instance for chaining
-
useRecordingExporter
If true, registers theRecordingExporterfor each broker. Defaults to true.- Parameters:
useRecordingExporter- whether to enable the recording exporter- Returns:
- this builder instance for chaining
-
build
Builds a new Zeebe cluster. Will createbrokersCountbrokers (accessible later viaTestCluster.brokers()) andgatewaysCountstandalone gateways (accessible later viaTestCluster.gateways()).If
useEmbeddedGatewayis true, then all brokers will have the embedded gateway enabled and the right topology check configured. Additionally,TestCluster.gateways()will also include them, along with any other additional standalone gateway.For standalone gateways, if
brokersCountis at least one, then a random broker is picked as the contact point for all gateways.- Returns:
- a new Zeebe cluster
-