Search in sources :

Example 21 with BrokerInfo

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);
}
Also used : DEBUG_EXPORTER(io.camunda.zeebe.broker.test.EmbeddedBrokerConfigurator.DEBUG_EXPORTER) START_PARTITION_ID(io.camunda.zeebe.protocol.Protocol.START_PARTITION_ID) Address(io.atomix.utils.net.Address) AutoCloseableRule(io.camunda.zeebe.test.util.AutoCloseableRule) EmbeddedBrokerRule.assignSocketAddresses(io.camunda.zeebe.broker.test.EmbeddedBrokerRule.assignSocketAddresses) TimeoutException(java.util.concurrent.TimeoutException) Gateway(io.camunda.zeebe.gateway.Gateway) UncheckedExecutionException(io.camunda.zeebe.util.exception.UncheckedExecutionException) Duration(java.time.Duration) Map(java.util.Map) ClusterCfg(io.camunda.zeebe.gateway.impl.configuration.ClusterCfg) LangUtil(org.agrona.LangUtil) SocketBindingCfg(io.camunda.zeebe.broker.system.configuration.SocketBindingCfg) NettyMessagingService(io.atomix.cluster.messaging.impl.NettyMessagingService) Path(java.nio.file.Path) EmbeddedBrokerConfigurator.setCluster(io.camunda.zeebe.broker.test.EmbeddedBrokerConfigurator.setCluster) ControlledActorClock(io.camunda.zeebe.util.sched.clock.ControlledActorClock) ProcessInstanceCreationRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord) BrokerAdminService(io.camunda.zeebe.broker.system.management.BrokerAdminService) PartitionManagerImpl(io.camunda.zeebe.broker.partitioning.PartitionManagerImpl) Predicate(java.util.function.Predicate) SystemContext(io.camunda.zeebe.broker.system.SystemContext) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Set(java.util.Set) Description(org.junit.runner.Description) DISABLE_EMBEDDED_GATEWAY(io.camunda.zeebe.broker.test.EmbeddedBrokerConfigurator.DISABLE_EMBEDDED_GATEWAY) RecordingExporterTestWatcher(io.camunda.zeebe.test.util.record.RecordingExporterTestWatcher) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) SwimMembershipProtocol(io.atomix.cluster.protocol.SwimMembershipProtocol) UncheckedIOException(java.io.UncheckedIOException) Objects(java.util.Objects) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) ExternalResource(org.junit.rules.ExternalResource) NetworkCfg(io.camunda.zeebe.broker.system.configuration.NetworkCfg) SnapshotId(io.camunda.zeebe.snapshots.SnapshotId) BootstrapDiscoveryProvider(io.atomix.cluster.discovery.BootstrapDiscoveryProvider) Broker(io.camunda.zeebe.broker.Broker) ZeebeClient(io.camunda.zeebe.client.ZeebeClient) Optional(java.util.Optional) Awaitility(org.awaitility.Awaitility) IntStream(java.util.stream.IntStream) Statement(org.junit.runners.model.Statement) AtomixClusterBuilder(io.atomix.cluster.AtomixClusterBuilder) PartitionStatus(io.camunda.zeebe.broker.system.management.PartitionStatus) EmbeddedBrokerConfigurator.setInitialContactPoints(io.camunda.zeebe.broker.test.EmbeddedBrokerConfigurator.setInitialContactPoints) ActorFuture(io.camunda.zeebe.util.sched.future.ActorFuture) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) SpringBrokerBridge(io.camunda.zeebe.broker.SpringBrokerBridge) FileBasedSnapshotMetadata(io.camunda.zeebe.snapshots.impl.FileBasedSnapshotMetadata) PartitionInfo(io.camunda.zeebe.client.api.response.PartitionInfo) RaftPartition(io.atomix.raft.partition.RaftPartition) MemberId(io.atomix.cluster.MemberId) BrokerResponse(io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse) BrokerContext(io.camunda.zeebe.broker.bootstrap.BrokerContext) SocketUtil(io.camunda.zeebe.test.util.socket.SocketUtil) LOG(io.camunda.zeebe.broker.Broker.LOG) Topology(io.camunda.zeebe.client.api.response.Topology) ExporterDirectorContext(io.camunda.zeebe.broker.exporter.stream.ExporterDirectorContext) ClusterConfig(io.atomix.cluster.ClusterConfig) BrokerCfg(io.camunda.zeebe.broker.system.configuration.BrokerCfg) BrokerCreateProcessInstanceRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest) Files(java.nio.file.Files) AtomixCluster(io.atomix.cluster.AtomixCluster) NetUtil(io.netty.util.NetUtil) IOException(java.io.IOException) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) PartitionListener(io.camunda.zeebe.broker.PartitionListener) LogStream(io.camunda.zeebe.logstreams.log.LogStream) Paths(java.nio.file.Paths) QueryService(io.camunda.zeebe.engine.state.QueryService) GatewayCfg(io.camunda.zeebe.gateway.impl.configuration.GatewayCfg) CompletableActorFuture(io.camunda.zeebe.util.sched.future.CompletableActorFuture) NettyUnicastService(io.atomix.cluster.messaging.impl.NettyUnicastService) TEST_RECORDER(io.camunda.zeebe.broker.test.EmbeddedBrokerConfigurator.TEST_RECORDER) Assert(org.junit.Assert) Collections(java.util.Collections) TemporaryFolder(org.junit.rules.TemporaryFolder) ActorScheduler(io.camunda.zeebe.util.sched.ActorScheduler) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 22 with BrokerInfo

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

Example 23 with BrokerInfo

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);
}
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 24 with BrokerInfo

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

Example 25 with BrokerInfo

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

Aggregations

BrokerInfo (io.camunda.zeebe.client.api.response.BrokerInfo)52 Test (org.junit.Test)39 Topology (io.camunda.zeebe.client.api.response.Topology)29 PartitionInfo (io.camunda.zeebe.client.api.response.PartitionInfo)16 ZeebeClient (io.camunda.zeebe.client.ZeebeClient)9 ActivatedJob (io.camunda.zeebe.client.api.response.ActivatedJob)6 InetSocketAddress (java.net.InetSocketAddress)6 HashSet (java.util.HashSet)6 HashMap (java.util.HashMap)5 Test (org.junit.jupiter.api.Test)5 AtomixCluster (io.atomix.cluster.AtomixCluster)3 AtomixClusterBuilder (io.atomix.cluster.AtomixClusterBuilder)3 ClusterConfig (io.atomix.cluster.ClusterConfig)3 MemberId (io.atomix.cluster.MemberId)3 BootstrapDiscoveryProvider (io.atomix.cluster.discovery.BootstrapDiscoveryProvider)3 NettyMessagingService (io.atomix.cluster.messaging.impl.NettyMessagingService)3 NettyUnicastService (io.atomix.cluster.messaging.impl.NettyUnicastService)3 SwimMembershipProtocol (io.atomix.cluster.protocol.SwimMembershipProtocol)3 RaftPartition (io.atomix.raft.partition.RaftPartition)3 Address (io.atomix.utils.net.Address)3