use of io.atomix.raft.partition.RaftPartition in project zeebe by camunda-cloud.
the class ClusteringRule method stepDown.
public void stepDown(final Broker broker, final int partitionId) {
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() == partitionId).map(RaftPartition.class::cast).findFirst().orElseThrow();
raftPartition.getServer().stepDown().join();
}
use of io.atomix.raft.partition.RaftPartition in project zeebe by camunda-cloud.
the class BrokerSnapshotTest method setup.
@Before
public void setup() {
final RaftPartition raftPartition = (RaftPartition) brokerRule.getBroker().getBrokerContext().getPartitionManager().getPartitionGroup().getPartition(PartitionId.from(PartitionManagerImpl.GROUP_NAME, PARTITION_ID));
journalReader = raftPartition.getServer().openReader();
brokerAdminService = brokerRule.getBroker().getBrokerContext().getBrokerAdminService();
final String contactPoint = NetUtil.toSocketAddressString(brokerRule.getGatewayAddress());
final ZeebeClientBuilder zeebeClientBuilder = ZeebeClient.newClientBuilder().usePlaintext().gatewayAddress(contactPoint);
client = zeebeClientBuilder.build();
}
use of io.atomix.raft.partition.RaftPartition in project zeebe by camunda.
the class PartitionFactory method constructPartitions.
List<ZeebePartition> constructPartitions(final RaftPartitionGroup partitionGroup, final List<PartitionListener> partitionListeners, final TopologyManager topologyManager) {
final var partitions = new ArrayList<ZeebePartition>();
final var communicationService = clusterServices.getCommunicationService();
final var eventService = clusterServices.getEventService();
final var membershipService = clusterServices.getMembershipService();
final MemberId nodeId = membershipService.getLocalMember().id();
final List<RaftPartition> owningPartitions = partitionGroup.getPartitionsWithMember(nodeId).stream().map(RaftPartition.class::cast).collect(Collectors.toList());
final var typedRecordProcessorsFactory = createFactory(topologyManager, localBroker, communicationService, eventService, deploymentRequestHandler);
for (final RaftPartition owningPartition : owningPartitions) {
final var partitionId = owningPartition.id().id();
final ConstructableSnapshotStore constructableSnapshotStore = snapshotStoreFactory.getConstructableSnapshotStore(partitionId);
final StateController stateController = createStateController(owningPartition, constructableSnapshotStore, snapshotStoreFactory.getSnapshotStoreConcurrencyControl(partitionId));
final PartitionStartupAndTransitionContextImpl partitionStartupAndTransitionContext = new PartitionStartupAndTransitionContextImpl(localBroker.getNodeId(), owningPartition, partitionListeners, new AtomixPartitionMessagingService(communicationService, membershipService, owningPartition.members()), actorSchedulingService, brokerCfg, commandApiService::newCommandResponseWriter, () -> commandApiService.getOnProcessedListener(partitionId), constructableSnapshotStore, snapshotStoreFactory.getReceivableSnapshotStore(partitionId), stateController, typedRecordProcessorsFactory, exporterRepository, new PartitionProcessingState(owningPartition));
final PartitionTransition newTransitionBehavior = new PartitionTransitionImpl(TRANSITION_STEPS);
final ZeebePartition zeebePartition = new ZeebePartition(partitionStartupAndTransitionContext, newTransitionBehavior, STARTUP_STEPS);
healthCheckService.registerMonitoredPartition(zeebePartition.getPartitionId(), zeebePartition);
partitions.add(zeebePartition);
}
return partitions;
}
use of io.atomix.raft.partition.RaftPartition in project zeebe by camunda.
the class ClusteringRule method stepDown.
public void stepDown(final Broker broker, final int partitionId) {
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() == partitionId).map(RaftPartition.class::cast).findFirst().orElseThrow();
raftPartition.getServer().stepDown().join();
}
use of io.atomix.raft.partition.RaftPartition in project zeebe by camunda.
the class RaftRolesTest method testExceptionInRoleChangedListener.
@Test
public void testExceptionInRoleChangedListener() throws Exception {
// given
final CompletableFuture<Void> roleChanged = new CompletableFuture<>();
final CompletableFuture<Void> joinFuture = startSingleNodeSinglePartitionWithPartitionConsumer(partition -> {
final RaftPartition raftPartition = (RaftPartition) partition;
raftPartition.addRoleChangeListener((role, term) -> {
roleChanged.complete(null);
// when
throw new RuntimeException("expected");
});
});
// then
joinFuture.join();
roleChanged.get(60, TimeUnit.SECONDS);
}
Aggregations