Package net.kuujo.copycat.internal.log

Examples of net.kuujo.copycat.internal.log.CopycatEntry.term()


    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();
View Full Code Here


    // can be overwritten.
    CopycatEntry entry = context.log().getEntry(request.logIndex());
    if (entry == null) {
      logger().warn("{} - Rejected {}: request entry not found in local log", context.clusterManager().localNode(), request);
      return new PingResponse(request.id(), context.currentTerm(), false);
    } else if (entry.term() != request.logTerm()) {
      logger().warn("{} - Rejected {}: request entry term does not match local log", context.clusterManager().localNode(), request);
      return new PingResponse(request.id(), context.currentTerm(), false);
    } else {
      doApplyCommits(request.commitIndex());
      return new PingResponse(request.id(), context.currentTerm(), true);
View Full Code Here

    // can be overwritten.
    CopycatEntry entry = context.log().getEntry(request.prevLogIndex());
    if (entry == null) {
      logger().warn("{} - Rejected {}: request entry not found in local log", context.clusterManager().localNode(), request);
      return new SyncResponse(request.id(), context.currentTerm(), false, context.log().lastIndex());
    } else if (entry.term() != request.prevLogTerm()) {
      logger().warn("{} - Rejected {}: request entry term does not match local log", context.clusterManager().localNode(), request);
      return new SyncResponse(request.id(), context.currentTerm(), false, context.log().lastIndex());
    } else {
      return doAppendEntries(request);
    }
View Full Code Here

          if (entry instanceof SnapshotEntry) {
            installSnapshot(index, (SnapshotEntry) entry);
          } else {
            CopycatEntry match = context.log().getEntry(index);
            if (match != null) {
              if (entry.term() != match.term()) {
                logger().warn("{} - Synced entry does not match local log, removing incorrect entries", context.clusterManager().localNode());
                context.log().removeAfter(index - 1);
                context.log().appendEntry(entry);
                logger().debug("{} - Appended {} to log at index {}", context.clusterManager().localNode(), entry, index);
              }
View Full Code Here

                .member()));
            logger().debug("{} - Accepted {}: candidate's log is up-to-date", context.clusterManager().localNode(), request);
            return new PollResponse(request.id(), context.currentTerm(), true);
          }

          long lastTerm = entry.term();
          if (request.lastLogIndex() >= lastIndex) {
            if (request.lastLogTerm() >= lastTerm) {
              context.lastVotedFor(request.candidate());
              context.events()
                .voteCast()
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.