Search in sources :

Example 1 with NoopSnapshotStoreFactory

use of io.atomix.cluster.NoopSnapshotStoreFactory in project zeebe by camunda.

the class RaftRolesTest method startPartitionManagerWithPartitionConsumer.

private CompletableFuture<Void> startPartitionManagerWithPartitionConsumer(final int nodeId, final int partitionCount, final List<Integer> nodeIds, final Consumer<? super Partition> partitionConsumer) {
    final List<String> memberIds = nodeIds.stream().map(Object::toString).collect(Collectors.toList());
    final RaftPartitionGroup partitionGroup = RaftPartitionGroup.builder("normal").withNumPartitions(partitionCount).withPartitionSize(memberIds.size()).withPriorityElection(false).withMembers(memberIds).withDataDirectory(new File(new File(atomixClusterRule.getDataDir(), "log"), "" + nodeId)).withSnapshotStoreFactory(new NoopSnapshotStoreFactory()).build();
    final var atomixFuture = atomixClusterRule.startAtomix(nodeId, nodeIds, AtomixClusterBuilder::build);
    final AtomixCluster atomix;
    try {
        atomix = atomixFuture.get();
        final var partitionService = new DefaultPartitionService(atomix.getMembershipService(), atomix.getCommunicationService(), partitionGroup);
        partitionGroup.getPartitions().forEach(partitionConsumer);
        return partitionService.start().thenApply(ps -> null);
    } catch (final InterruptedException | ExecutionException e) {
        LangUtil.rethrowUnchecked(e);
        // won't be executed
        return null;
    }
}
Also used : DefaultPartitionService(io.atomix.primitive.partition.impl.DefaultPartitionService) RaftPartitionGroup(io.atomix.raft.partition.RaftPartitionGroup) AtomixClusterBuilder(io.atomix.cluster.AtomixClusterBuilder) ExecutionException(java.util.concurrent.ExecutionException) File(java.io.File) NoopSnapshotStoreFactory(io.atomix.cluster.NoopSnapshotStoreFactory) AtomixCluster(io.atomix.cluster.AtomixCluster)

Example 2 with NoopSnapshotStoreFactory

use of io.atomix.cluster.NoopSnapshotStoreFactory in project zeebe by zeebe-io.

the class RaftRolesTest method startPartitionManagerWithPartitionConsumer.

private CompletableFuture<Void> startPartitionManagerWithPartitionConsumer(final int nodeId, final int partitionCount, final List<Integer> nodeIds, final Consumer<? super Partition> partitionConsumer) {
    final List<String> memberIds = nodeIds.stream().map(Object::toString).collect(Collectors.toList());
    final RaftPartitionGroup partitionGroup = RaftPartitionGroup.builder("normal").withNumPartitions(partitionCount).withPartitionSize(memberIds.size()).withPriorityElection(false).withMembers(memberIds).withDataDirectory(new File(new File(atomixClusterRule.getDataDir(), "log"), "" + nodeId)).withSnapshotStoreFactory(new NoopSnapshotStoreFactory()).build();
    final var atomixFuture = atomixClusterRule.startAtomix(nodeId, nodeIds, AtomixClusterBuilder::build);
    final AtomixCluster atomix;
    try {
        atomix = atomixFuture.get();
        final var partitionService = new DefaultPartitionService(atomix.getMembershipService(), atomix.getCommunicationService(), partitionGroup);
        partitionGroup.getPartitions().forEach(partitionConsumer);
        return partitionService.start().thenApply(ps -> null);
    } catch (final InterruptedException | ExecutionException e) {
        LangUtil.rethrowUnchecked(e);
        // won't be executed
        return null;
    }
}
Also used : DefaultPartitionService(io.atomix.primitive.partition.impl.DefaultPartitionService) RaftPartitionGroup(io.atomix.raft.partition.RaftPartitionGroup) AtomixClusterBuilder(io.atomix.cluster.AtomixClusterBuilder) ExecutionException(java.util.concurrent.ExecutionException) File(java.io.File) NoopSnapshotStoreFactory(io.atomix.cluster.NoopSnapshotStoreFactory) AtomixCluster(io.atomix.cluster.AtomixCluster)

Example 3 with NoopSnapshotStoreFactory

use of io.atomix.cluster.NoopSnapshotStoreFactory in project zeebe by camunda-cloud.

the class RaftRolesTest method startPartitionManagerWithPartitionConsumer.

private CompletableFuture<Void> startPartitionManagerWithPartitionConsumer(final int nodeId, final int partitionCount, final List<Integer> nodeIds, final Consumer<? super Partition> partitionConsumer) {
    final List<String> memberIds = nodeIds.stream().map(Object::toString).collect(Collectors.toList());
    final RaftPartitionGroup partitionGroup = RaftPartitionGroup.builder("normal").withNumPartitions(partitionCount).withPartitionSize(memberIds.size()).withPriorityElection(false).withMembers(memberIds).withDataDirectory(new File(new File(atomixClusterRule.getDataDir(), "log"), "" + nodeId)).withSnapshotStoreFactory(new NoopSnapshotStoreFactory()).build();
    final var atomixFuture = atomixClusterRule.startAtomix(nodeId, nodeIds, AtomixClusterBuilder::build);
    final AtomixCluster atomix;
    try {
        atomix = atomixFuture.get();
        final var partitionService = new DefaultPartitionService(atomix.getMembershipService(), atomix.getCommunicationService(), partitionGroup);
        partitionGroup.getPartitions().forEach(partitionConsumer);
        return partitionService.start().thenApply(ps -> null);
    } catch (final InterruptedException | ExecutionException e) {
        LangUtil.rethrowUnchecked(e);
        // won't be executed
        return null;
    }
}
Also used : DefaultPartitionService(io.atomix.primitive.partition.impl.DefaultPartitionService) RaftPartitionGroup(io.atomix.raft.partition.RaftPartitionGroup) AtomixClusterBuilder(io.atomix.cluster.AtomixClusterBuilder) ExecutionException(java.util.concurrent.ExecutionException) File(java.io.File) NoopSnapshotStoreFactory(io.atomix.cluster.NoopSnapshotStoreFactory) AtomixCluster(io.atomix.cluster.AtomixCluster)

Aggregations

AtomixCluster (io.atomix.cluster.AtomixCluster)3 AtomixClusterBuilder (io.atomix.cluster.AtomixClusterBuilder)3 NoopSnapshotStoreFactory (io.atomix.cluster.NoopSnapshotStoreFactory)3 DefaultPartitionService (io.atomix.primitive.partition.impl.DefaultPartitionService)3 RaftPartitionGroup (io.atomix.raft.partition.RaftPartitionGroup)3 File (java.io.File)3 ExecutionException (java.util.concurrent.ExecutionException)3