Search in sources :

Example 6 with PartitionId

use of io.atomix.primitive.partition.PartitionId in project atomix by atomix.

the class PrimaryBackupPartition method open.

/**
 * Opens the primary-backup partition.
 */
CompletableFuture<Partition> open(PartitionManagementService managementService, ThreadContextFactory threadFactory) {
    election = managementService.getElectionService().getElectionFor(partitionId);
    server = new PrimaryBackupPartitionServer(this, managementService, memberGroupProvider, threadFactory);
    client = new PrimaryBackupPartitionClient(this, managementService, threadFactory);
    return server.start().thenCompose(v -> client.start()).thenApply(v -> this);
}
Also used : NodeId(io.atomix.cluster.NodeId) Collection(java.util.Collection) CompletableFuture(java.util.concurrent.CompletableFuture) PrimaryBackupPartitionClient(io.atomix.protocols.backup.partition.impl.PrimaryBackupPartitionClient) Collectors(java.util.stream.Collectors) Member(io.atomix.primitive.partition.Member) PartitionId(io.atomix.primitive.partition.PartitionId) ThreadContextFactory(io.atomix.utils.concurrent.ThreadContextFactory) PrimaryBackupPartitionServer(io.atomix.protocols.backup.partition.impl.PrimaryBackupPartitionServer) Partition(io.atomix.primitive.partition.Partition) PartitionManagementService(io.atomix.primitive.partition.PartitionManagementService) PrimaryElection(io.atomix.primitive.partition.PrimaryElection) MemberGroupProvider(io.atomix.primitive.partition.MemberGroupProvider) MultiPrimaryProtocol(io.atomix.protocols.backup.MultiPrimaryProtocol) PrimitiveClient(io.atomix.primitive.PrimitiveClient) MoreObjects.toStringHelper(com.google.common.base.MoreObjects.toStringHelper) PrimaryBackupPartitionClient(io.atomix.protocols.backup.partition.impl.PrimaryBackupPartitionClient) PrimaryBackupPartitionServer(io.atomix.protocols.backup.partition.impl.PrimaryBackupPartitionServer)

Example 7 with PartitionId

use of io.atomix.primitive.partition.PartitionId in project atomix by atomix.

the class PrimaryElectorService method onSessionEnd.

private void onSessionEnd(Session session) {
    listeners.remove(session.sessionId().id());
    Set<PartitionId> partitions = elections.keySet();
    partitions.forEach(partitionId -> {
        PrimaryTerm oldTerm = term(partitionId);
        elections.compute(partitionId, (k, v) -> v.cleanup(session));
        PrimaryTerm newTerm = term(partitionId);
        if (!Objects.equals(oldTerm, newTerm)) {
            notifyTermChange(partitionId, newTerm);
            scheduleRebalance();
        }
    });
}
Also used : PartitionId(io.atomix.primitive.partition.PartitionId) PrimaryTerm(io.atomix.primitive.partition.PrimaryTerm)

Aggregations

PartitionId (io.atomix.primitive.partition.PartitionId)7 Partition (io.atomix.primitive.partition.Partition)5 Map (java.util.Map)5 CompletableFuture (java.util.concurrent.CompletableFuture)5 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)4 Lists (com.google.common.collect.Lists)4 Maps (com.google.common.collect.Maps)4 PrimitiveProtocol (io.atomix.primitive.PrimitiveProtocol)4 PartitionGroup (io.atomix.primitive.partition.PartitionGroup)4 Futures (io.atomix.utils.concurrent.Futures)4 PrimitiveManagementService (io.atomix.primitive.PrimitiveManagementService)3 Partitioner (io.atomix.primitive.partition.Partitioner)3 Collectors (java.util.stream.Collectors)3 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)2 Sets (com.google.common.collect.Sets)2 Hashing (com.google.common.hash.Hashing)2 NodeId (io.atomix.cluster.NodeId)2 Member (io.atomix.primitive.partition.Member)2 PartitionManagementService (io.atomix.primitive.partition.PartitionManagementService)2 PrimaryTerm (io.atomix.primitive.partition.PrimaryTerm)2