Examples of Quorum


Examples of net.kuujo.copycat.internal.util.Quorum

  public CompletableFuture<Long> ping(long index) {
    CompletableFuture<Long> future = new CompletableFuture<>();

    // Set up a read quorum. Once the required number of replicas have been
    // contacted the quorum will succeed.
    final Quorum quorum = new Quorum(readQuorum, succeeded -> {
      if (succeeded) {
        future.complete(index);
      } else {
        future.completeExceptionally(new CopycatException("Failed to obtain quorum"));
      }
    }).countSelf();

    // Iterate through replicas and ping each replica. Internally, this
    // should cause the replica to send any remaining entries if necessary.
    for (NodeReplicator replica : replicaMap.values()) {
      replica.ping(index).whenComplete((resultIndex, error) -> {
        if (error == null) {
          quorum.succeed();
        } else {
          quorum.fail();
        }
      });
    }
    return future;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.