Examples of Quorum


Examples of com.basho.riak.client.cap.Quorum

        public DeleteMeta build() {
            return new DeleteMeta(r, pr, w, dw, pw, rw, vclock, timeout);
        }

        public Builder r(int r) {
            this.r = new Quorum(r);
            return this;
        }
View Full Code Here

Examples of com.basho.riak.client.cap.Quorum

            this.r = new Quorum(r);
            return this;
        }

        public Builder r(Quora r) {
            this.r = new Quorum(r);
            return this;
        }
View Full Code Here

Examples of com.basho.riak.client.cap.Quorum

            this.r = r;
            return this;
        }
       
        public Builder pr(int pr) {
            this.pr = new Quorum(pr);
            return this;
        }
View Full Code Here

Examples of com.basho.riak.client.cap.Quorum

            this.pr = new Quorum(pr);
            return this;
        }

        public Builder pr(Quora pr) {
            this.pr = new Quorum(pr);
            return this;
        }
View Full Code Here

Examples of com.basho.riak.client.cap.Quorum

            this.pr = pr;
            return this;
        }
       
        public Builder w(int w) {
            this.w = new Quorum(w);
            return this;
        }
View Full Code Here

Examples of com.basho.riak.client.cap.Quorum

            this.w = new Quorum(w);
            return this;
        }

        public Builder w(Quora w) {
            this.w = new Quorum(w);
            return this;
        }
View Full Code Here

Examples of com.basho.riak.client.cap.Quorum

            this.w = w;
            return this;
        }

        public Builder dw(int dw) {
            this.dw = new Quorum(dw);
            return this;
        }
View Full Code Here

Examples of com.basho.riak.client.cap.Quorum

            this.dw = new Quorum(dw);
            return this;
        }

        public Builder dw(Quora dw) {
            this.dw = new Quorum(dw);
            return this;
        }
View Full Code Here

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

    // Send vote requests to all nodes. The vote request that is sent
    // to this node will be automatically successful.
    // First check if the quorum is null. If the quorum isn't null then that
    // indicates that another vote is already going on.
    final Quorum quorum = new Quorum((int) Math.floor(context.clusterManager().nodes().size() / 2) + 1, (elected) -> {
      complete.set(true);
      if (elected) {
        context.transition(LeaderController.class);
      } else {
        context.transition(FollowerController.class);
      }
    }).countSelf();

    // First, load the last log entry to get its term. We load the entry
    // by its index since the index is required by the protocol.
    final long lastIndex = context.log().lastIndex();
    CopycatEntry lastEntry = context.log().getEntry(lastIndex);

    // Once we got the last log term, iterate through each current member
    // of the cluster and poll each member for a vote.
    LOGGER.info("{} - Polling members {}", context.clusterManager().localNode(), context.clusterManager().cluster().remoteMembers());
    final long lastTerm = lastEntry != null ? lastEntry.term() : 0;
    for (RemoteNode<?> node : (Set<RemoteNode<?>>) context.clusterManager().remoteNodes()) {
      final ProtocolClient client = node.client();
      client.connect().whenComplete((result1, error1) -> {
        if (error1 != null) {
          quorum.fail();
        } else {
          LOGGER.debug("{} - Polling {}", context.clusterManager().localNode(), node.member());
          client.poll(new PollRequest(context.nextCorrelationId(), context.currentTerm(), context.clusterManager()
            .localNode()
            .member()
            .id(), lastIndex, lastTerm)).whenComplete((result2, error2) -> {
            client.close();
            if (!complete.get()) {
              if (error2 != null) {
                LOGGER.warn(context.clusterManager().localNode().toString(), error2);
                quorum.fail();
              } else if (!result2.voteGranted()) {
                LOGGER.info("{} - Received rejected vote from {}", context.clusterManager().localNode(), node.member());
                quorum.fail();
              } else if (result2.term() != context.currentTerm()) {
                LOGGER.info("{} - Received successful vote for a different term from {}", context.clusterManager()
                  .localNode(), node.member());
                quorum.fail();
              } else {
                LOGGER.info("{} - Received successful vote from {}", context.clusterManager()
                  .localNode(), node.member());
                quorum.succeed();
              }
            }
          });
        }
      });
View Full Code Here

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

    CompletableFuture<Long> future = new CompletableFuture<>();

    // Set up a write quorum. Once the log entry has been replicated to
    // the required number of replicas in order to meet the write quorum
    // requirement, the future will succeed.
    final Quorum quorum = new Quorum(writeQuorum, succeeded -> {
      if (succeeded) {
        future.complete(index);
      } else {
        future.completeExceptionally(new CopycatException("Failed to obtain quorum"));
      }
    }).countSelf();

    // Iterate through replicas and commit all entries up to the given index.
    for (NodeReplicator replica : replicaMap.values()) {
      replica.replicate(index).whenComplete((resultIndex, error) -> {
        // Once the commit succeeds, check the commit index of all replicas.
        if (error == null) {
          quorum.succeed();
          checkCommits();
        } 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.