Search in sources :

Example 1 with PartitionInfo

use of io.camunda.zeebe.client.api.response.PartitionInfo 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;
}
Also used : HashMap(java.util.HashMap) PartitionInfo(io.camunda.zeebe.client.api.response.PartitionInfo) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo)

Example 2 with PartitionInfo

use of io.camunda.zeebe.client.api.response.PartitionInfo in project zeebe by zeebe-io.

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);
}
Also used : Topology(io.camunda.zeebe.client.api.response.Topology) PartitionInfo(io.camunda.zeebe.client.api.response.PartitionInfo) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Test(org.junit.Test)

Example 3 with PartitionInfo

use of io.camunda.zeebe.client.api.response.PartitionInfo in project zeebe by zeebe-io.

the class TopologyClusterTest method shouldContainAllPartitions.

@Test
public void shouldContainAllPartitions() {
    // 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);
}
Also used : Topology(io.camunda.zeebe.client.api.response.Topology) PartitionInfo(io.camunda.zeebe.client.api.response.PartitionInfo) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Test(org.junit.Test)

Example 4 with PartitionInfo

use of io.camunda.zeebe.client.api.response.PartitionInfo in project zeebe by zeebe-io.

the class TopologyClusterWithoutReplicationTest 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);
}
Also used : Topology(io.camunda.zeebe.client.api.response.Topology) PartitionInfo(io.camunda.zeebe.client.api.response.PartitionInfo) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Test(org.junit.Test)

Example 5 with PartitionInfo

use of io.camunda.zeebe.client.api.response.PartitionInfo 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);
}
Also used : Topology(io.camunda.zeebe.client.api.response.Topology) PartitionInfo(io.camunda.zeebe.client.api.response.PartitionInfo) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Test(org.junit.Test)

Aggregations

BrokerInfo (io.camunda.zeebe.client.api.response.BrokerInfo)13 PartitionInfo (io.camunda.zeebe.client.api.response.PartitionInfo)13 Topology (io.camunda.zeebe.client.api.response.Topology)11 Test (org.junit.Test)9 HashMap (java.util.HashMap)2 Test (org.junit.jupiter.api.Test)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1