Search in sources :

Example 1 with ConfigurationEntry

use of io.atomix.protocols.raft.storage.log.entry.ConfigurationEntry in project atomix by atomix.

the class LeaderRole method configure.

/**
 * Commits the given configuration.
 */
protected CompletableFuture<Long> configure(Collection<RaftMember> members) {
    raft.checkThread();
    final long term = raft.getTerm();
    return appendAndCompact(new ConfigurationEntry(term, System.currentTimeMillis(), members)).thenComposeAsync(entry -> {
        // Store the index of the configuration entry in order to prevent other configurations from
        // being logged and committed concurrently. This is an important safety property of Raft.
        configuring = entry.index();
        raft.getCluster().configure(new Configuration(entry.index(), entry.entry().term(), entry.entry().timestamp(), entry.entry().members()));
        return appender.appendEntries(entry.index()).whenComplete((commitIndex, commitError) -> {
            raft.checkThread();
            if (isRunning() && commitError == null) {
                raft.getServiceManager().<OperationResult>apply(entry.index());
            }
            configuring = 0;
        });
    }, raft.getThreadContext());
}
Also used : Configuration(io.atomix.protocols.raft.storage.system.Configuration) OperationResult(io.atomix.protocols.raft.impl.OperationResult) ConfigurationEntry(io.atomix.protocols.raft.storage.log.entry.ConfigurationEntry)

Aggregations

OperationResult (io.atomix.protocols.raft.impl.OperationResult)1 ConfigurationEntry (io.atomix.protocols.raft.storage.log.entry.ConfigurationEntry)1 Configuration (io.atomix.protocols.raft.storage.system.Configuration)1