use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe-test-container by camunda-community-hub.
the class ClusterWithGatewayExampleTest method shouldStartCluster.
@Test
@Timeout(value = 15, unit = TimeUnit.MINUTES)
void shouldStartCluster() {
// given
Startables.deepStart(brokers).join();
gatewayContainer.start();
// when
final Topology topology;
try (final ZeebeClient client = newZeebeClient(gatewayContainer)) {
topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
}
// then
final List<BrokerInfo> brokers = topology.getBrokers();
Assertions.assertThat(brokers).as("the topology contains all the brokers, advertising the right address").hasSize(3).extracting(BrokerInfo::getAddress).containsExactlyInAnyOrder(brokerZeroContainer.getInternalCommandAddress(), brokerOneContainer.getInternalCommandAddress(), brokerTwoContainer.getInternalCommandAddress());
}
use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe-test-container by camunda-community-hub.
the class ZeebeClusterSingleNodeExampleTest method shouldConnectToZeebe.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
void shouldConnectToZeebe() {
// given
final Topology topology;
// when
try (final ZeebeClient client = cluster.newClientBuilder().build()) {
topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
}
// then
final List<BrokerInfo> brokers = topology.getBrokers();
Assertions.assertThat(brokers).as("the topology contains all the brokers, advertising the expected address").hasSize(1).extracting(BrokerInfo::getAddress).containsExactlyInAnyOrder(cluster.getBrokers().get(0).getInternalCommandAddress());
}
use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe-test-container by camunda-community-hub.
the class ZeebeClusterWithEmbeddedGatewaysExampleTest method shouldStartCluster.
@Test
@Timeout(value = 15, unit = TimeUnit.MINUTES)
void shouldStartCluster() {
// given
final Topology topology;
// when
try (final ZeebeClient client = cluster.newClientBuilder().build()) {
topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
}
// then
final List<BrokerInfo> brokers = topology.getBrokers();
Assertions.assertThat(brokers).as("the topology contains all the brokers, advertising the expected address").hasSize(2).extracting(BrokerInfo::getAddress).containsExactlyInAnyOrder(cluster.getBrokers().get(0).getInternalCommandAddress(), cluster.getBrokers().get(1).getInternalCommandAddress());
}
use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe-test-container by camunda-community-hub.
the class ZeebeTopologyWaitStrategy method buildPartitionsMap.
private Map<Integer, Partition> buildPartitionsMap(final Topology topology) {
final Map<Integer, Partition> partitions = new HashMap<>();
for (final BrokerInfo broker : topology.getBrokers()) {
final int nodeId = broker.getNodeId();
for (final PartitionInfo partitionInfo : broker.getPartitions()) {
final int partitionId = partitionInfo.getPartitionId();
partitions.putIfAbsent(partitionId, new Partition());
final Partition partition = partitions.get(partitionId);
if (partitionInfo.isLeader()) {
partition.leaderIds.add(nodeId);
} else {
partition.followerIds.add(nodeId);
}
}
}
return partitions;
}
use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe by camunda.
the class ClusteringRule method hasPartitionsWithReplicationFactor.
private boolean hasPartitionsWithReplicationFactor(final List<BrokerInfo> brokers, final int partitionCount, final int replicationFactor) {
final AtomicLong leaders = new AtomicLong();
final AtomicLong followers = new AtomicLong();
brokers.stream().flatMap(b -> b.getPartitions().stream()).forEach(p -> {
if (p.isLeader()) {
leaders.getAndIncrement();
} else {
followers.getAndIncrement();
}
});
return leaders.get() >= partitionCount && followers.get() >= partitionCount * (replicationFactor - 1);
}
Aggregations