use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe by camunda-cloud.
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);
}
use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe by camunda-cloud.
the class CompleteProcessInstanceAfterLeaderChangeTest method shouldCompleteInstanceAfterLeaderChange.
@Test
public void shouldCompleteInstanceAfterLeaderChange() {
// given
final BrokerInfo leaderForPartition = clusteringRule.getLeaderForPartition(1);
beforeRestart.accept(clientRule);
// when
clusteringRule.stopBrokerAndAwaitNewLeader(leaderForPartition.getNodeId());
// then
afterRestart.accept(clusteringRule, clientRule);
ZeebeAssertHelper.assertProcessInstanceCompleted("process");
}
use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe by camunda-cloud.
the class TopologyClusterSmallerReplicationTest method shouldHaveCorrectReplicationFactorForPartitions.
@Test
public void shouldHaveCorrectReplicationFactorForPartitions() {
// when
final Topology topology = CLIENT_RULE.getClient().newTopologyRequest().send().join();
// then
final List<BrokerInfo> brokers = topology.getBrokers();
assertThat(brokers).flatExtracting(BrokerInfo::getPartitions).filteredOn(PartitionInfo::isLeader).extracting(PartitionInfo::getPartitionId).containsExactlyInAnyOrder(START_PARTITION_ID, START_PARTITION_ID + 1, START_PARTITION_ID + 2);
assertPartitionInTopology(brokers, START_PARTITION_ID);
assertPartitionInTopology(brokers, START_PARTITION_ID + 1);
assertPartitionInTopology(brokers, START_PARTITION_ID + 2);
}
use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe by camunda-cloud.
the class TopologyClusterTest method shouldExposeClusterSettings.
@Test
public void shouldExposeClusterSettings() {
// when
final Topology topology = CLIENT_RULE.getClient().newTopologyRequest().send().join();
// then
assertThat(topology.getClusterSize()).isEqualTo(CLUSTERING_RULE.getClusterSize());
assertThat(topology.getPartitionsCount()).isEqualTo(CLUSTERING_RULE.getPartitionCount());
assertThat(topology.getReplicationFactor()).isEqualTo(CLUSTERING_RULE.getReplicationFactor());
// NOTE: this fails in Intellij because we don't have access to the package version but it works
// when run from the CLI
assertThat(topology.getGatewayVersion()).isEqualTo(Gateway.class.getPackage().getImplementationVersion());
for (final BrokerInfo broker : topology.getBrokers()) {
assertThat(broker.getVersion()).isEqualTo(Broker.class.getPackage().getImplementationVersion());
}
}
use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe by camunda-cloud.
the class TopologyClusterTest method shouldContainAllBrokers.
@Test
public void shouldContainAllBrokers() {
// when
final Topology topology = CLIENT_RULE.getClient().newTopologyRequest().send().join();
// then
final List<BrokerInfo> brokers = topology.getBrokers();
assertThat(brokers.size()).isEqualTo(3);
assertThat(brokers).extracting(BrokerInfo::getNodeId).containsExactlyInAnyOrder(0, 1, 2);
}
Aggregations