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());
}
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());
}
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)));
}
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());
}
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)));
}
Aggregations