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