Search in sources :

Example 1 with START_PARTITION_ID

use of io.camunda.zeebe.protocol.Protocol.START_PARTITION_ID in project zeebe by camunda.

the class ClusteringRule method forceClusterToHaveNewLeader.

public void forceClusterToHaveNewLeader(final int expectedLeader) {
    final var previousLeader = getCurrentLeaderForPartition(1);
    if (previousLeader.getNodeId() == expectedLeader) {
        return;
    }
    final var broker = brokers.get(expectedLeader);
    final var atomix = broker.getBrokerContext().getClusterServices();
    final MemberId nodeId = atomix.getMembershipService().getLocalMember().id();
    final var raftPartition = broker.getBrokerContext().getPartitionManager().getPartitionGroup().getPartitions().stream().filter(partition -> partition.members().contains(nodeId)).filter(partition -> partition.id().id() == START_PARTITION_ID).map(RaftPartition.class::cast).findFirst().orElseThrow();
    raftPartition.getServer().promote().join();
    awaitOtherLeader(START_PARTITION_ID, previousLeader.getNodeId());
}
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) MemberId(io.atomix.cluster.MemberId) RaftPartition(io.atomix.raft.partition.RaftPartition)

Example 2 with START_PARTITION_ID

use of io.camunda.zeebe.protocol.Protocol.START_PARTITION_ID in project zeebe by zeebe-io.

the class ClusteringRule method forceClusterToHaveNewLeader.

public void forceClusterToHaveNewLeader(final int expectedLeader) {
    final var previousLeader = getCurrentLeaderForPartition(1);
    if (previousLeader.getNodeId() == expectedLeader) {
        return;
    }
    final var broker = brokers.get(expectedLeader);
    final var atomix = broker.getBrokerContext().getClusterServices();
    final MemberId nodeId = atomix.getMembershipService().getLocalMember().id();
    final var raftPartition = broker.getBrokerContext().getPartitionManager().getPartitionGroup().getPartitions().stream().filter(partition -> partition.members().contains(nodeId)).filter(partition -> partition.id().id() == START_PARTITION_ID).map(RaftPartition.class::cast).findFirst().orElseThrow();
    raftPartition.getServer().promote().join();
    awaitOtherLeader(START_PARTITION_ID, previousLeader.getNodeId());
}
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) MemberId(io.atomix.cluster.MemberId) RaftPartition(io.atomix.raft.partition.RaftPartition)

Example 3 with START_PARTITION_ID

use of io.camunda.zeebe.protocol.Protocol.START_PARTITION_ID in project zeebe by camunda-cloud.

the class MessageCorrelationMultiplePartitionsTest method shouldOpenMessageSubscriptionsOnDifferentPartitions.

@Test
public void shouldOpenMessageSubscriptionsOnDifferentPartitions() {
    // when
    IntStream.range(0, 10).forEach(i -> {
        final ProcessInstanceCreationClient processInstanceCreationClient = engine.processInstance().ofBpmnProcessId(PROCESS_ID);
        processInstanceCreationClient.withVariable("key", CORRELATION_KEYS.get(START_PARTITION_ID)).create();
        processInstanceCreationClient.withVariable("key", CORRELATION_KEYS.get(START_PARTITION_ID + 1)).create();
        processInstanceCreationClient.withVariable("key", CORRELATION_KEYS.get(START_PARTITION_ID + 2)).create();
    });
    // then
    assertThat(RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.CREATED).limit(30)).extracting(r -> tuple(r.getPartitionId(), r.getValue().getCorrelationKey())).containsOnly(tuple(START_PARTITION_ID, CORRELATION_KEYS.get(START_PARTITION_ID)), tuple(START_PARTITION_ID + 1, CORRELATION_KEYS.get(START_PARTITION_ID + 1)), tuple(START_PARTITION_ID + 2, CORRELATION_KEYS.get(START_PARTITION_ID + 2)));
}
Also used : IntStream(java.util.stream.IntStream) SubscriptionUtil(io.camunda.zeebe.protocol.impl.SubscriptionUtil) Arrays(java.util.Arrays) START_PARTITION_ID(io.camunda.zeebe.protocol.Protocol.START_PARTITION_ID) MsgPackUtil.asMsgPack(io.camunda.zeebe.test.util.MsgPackUtil.asMsgPack) ProcessInstanceCreationClient(io.camunda.zeebe.engine.util.client.ProcessInstanceClient.ProcessInstanceCreationClient) Assertions.tuple(org.assertj.core.api.Assertions.tuple) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) Test(org.junit.Test) MessageSubscriptionIntent(io.camunda.zeebe.protocol.record.intent.MessageSubscriptionIntent) RecordingExporter(io.camunda.zeebe.test.util.record.RecordingExporter) List(java.util.List) ProcessInstances(io.camunda.zeebe.test.util.record.ProcessInstances) Rule(org.junit.Rule) Maps(io.camunda.zeebe.test.util.collection.Maps) Map(java.util.Map) EngineRule(io.camunda.zeebe.engine.util.EngineRule) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) MapEntry.entry(org.assertj.core.data.MapEntry.entry) BufferUtil(io.camunda.zeebe.util.buffer.BufferUtil) Before(org.junit.Before) ProcessInstanceCreationClient(io.camunda.zeebe.engine.util.client.ProcessInstanceClient.ProcessInstanceCreationClient) Test(org.junit.Test)

Example 4 with START_PARTITION_ID

use of io.camunda.zeebe.protocol.Protocol.START_PARTITION_ID in project zeebe by camunda-cloud.

the class ClusteringRule method forceClusterToHaveNewLeader.

public void forceClusterToHaveNewLeader(final int expectedLeader) {
    final var previousLeader = getCurrentLeaderForPartition(1);
    if (previousLeader.getNodeId() == expectedLeader) {
        return;
    }
    final var broker = brokers.get(expectedLeader);
    final var atomix = broker.getBrokerContext().getClusterServices();
    final MemberId nodeId = atomix.getMembershipService().getLocalMember().id();
    final var raftPartition = broker.getBrokerContext().getPartitionManager().getPartitionGroup().getPartitions().stream().filter(partition -> partition.members().contains(nodeId)).filter(partition -> partition.id().id() == START_PARTITION_ID).map(RaftPartition.class::cast).findFirst().orElseThrow();
    raftPartition.getServer().promote().join();
    awaitOtherLeader(START_PARTITION_ID, previousLeader.getNodeId());
}
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) MemberId(io.atomix.cluster.MemberId) RaftPartition(io.atomix.raft.partition.RaftPartition)

Example 5 with START_PARTITION_ID

use of io.camunda.zeebe.protocol.Protocol.START_PARTITION_ID in project zeebe by zeebe-io.

the class MessageCorrelationMultiplePartitionsTest method shouldOpenMessageSubscriptionsOnDifferentPartitions.

@Test
public void shouldOpenMessageSubscriptionsOnDifferentPartitions() {
    // when
    IntStream.range(0, 10).forEach(i -> {
        final ProcessInstanceCreationClient processInstanceCreationClient = engine.processInstance().ofBpmnProcessId(PROCESS_ID);
        processInstanceCreationClient.withVariable("key", CORRELATION_KEYS.get(START_PARTITION_ID)).create();
        processInstanceCreationClient.withVariable("key", CORRELATION_KEYS.get(START_PARTITION_ID + 1)).create();
        processInstanceCreationClient.withVariable("key", CORRELATION_KEYS.get(START_PARTITION_ID + 2)).create();
    });
    // then
    assertThat(RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.CREATED).limit(30)).extracting(r -> tuple(r.getPartitionId(), r.getValue().getCorrelationKey())).containsOnly(tuple(START_PARTITION_ID, CORRELATION_KEYS.get(START_PARTITION_ID)), tuple(START_PARTITION_ID + 1, CORRELATION_KEYS.get(START_PARTITION_ID + 1)), tuple(START_PARTITION_ID + 2, CORRELATION_KEYS.get(START_PARTITION_ID + 2)));
}
Also used : IntStream(java.util.stream.IntStream) SubscriptionUtil(io.camunda.zeebe.protocol.impl.SubscriptionUtil) Arrays(java.util.Arrays) START_PARTITION_ID(io.camunda.zeebe.protocol.Protocol.START_PARTITION_ID) MsgPackUtil.asMsgPack(io.camunda.zeebe.test.util.MsgPackUtil.asMsgPack) ProcessInstanceCreationClient(io.camunda.zeebe.engine.util.client.ProcessInstanceClient.ProcessInstanceCreationClient) Assertions.tuple(org.assertj.core.api.Assertions.tuple) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) Test(org.junit.Test) MessageSubscriptionIntent(io.camunda.zeebe.protocol.record.intent.MessageSubscriptionIntent) RecordingExporter(io.camunda.zeebe.test.util.record.RecordingExporter) List(java.util.List) ProcessInstances(io.camunda.zeebe.test.util.record.ProcessInstances) Rule(org.junit.Rule) Maps(io.camunda.zeebe.test.util.collection.Maps) Map(java.util.Map) EngineRule(io.camunda.zeebe.engine.util.EngineRule) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) MapEntry.entry(org.assertj.core.data.MapEntry.entry) BufferUtil(io.camunda.zeebe.util.buffer.BufferUtil) Before(org.junit.Before) ProcessInstanceCreationClient(io.camunda.zeebe.engine.util.client.ProcessInstanceClient.ProcessInstanceCreationClient) Test(org.junit.Test)

Aggregations

START_PARTITION_ID (io.camunda.zeebe.protocol.Protocol.START_PARTITION_ID)6 List (java.util.List)6 Map (java.util.Map)6 IntStream (java.util.stream.IntStream)6 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 Broker (io.camunda.zeebe.broker.Broker)3 LOG (io.camunda.zeebe.broker.Broker.LOG)3 PartitionListener (io.camunda.zeebe.broker.PartitionListener)3 SpringBrokerBridge (io.camunda.zeebe.broker.SpringBrokerBridge)3 BrokerContext (io.camunda.zeebe.broker.bootstrap.BrokerContext)3 ExporterDirectorContext (io.camunda.zeebe.broker.exporter.stream.ExporterDirectorContext)3