LogIndex nextIndex(AnyObjectId id) { return new LogIndex(id, index + 1); }
/** * Create string suitable for debug logging containing the log index and * abbreviated ObjectId. * * @return string suitable for debug logging containing the log index and * abbreviated ObjectId. */ @SuppressWarnings("boxing") public String describeForLog() { return String.format("%5d/%s", index, abbreviate(6).name()); //$NON-NLS-1$ }
static String str(ObjectId c) { if (c instanceof LogIndex) { return ((LogIndex) c).describeForLog(); } else if (c != null) { return c.abbreviate(8).name(); } return "-"; //$NON-NLS-1$ } }
assert headIndex.equals(runningRound.acceptedNewIndex); int matching = 0; for (KetchReplica r : voters) { if (log.isDebugEnabled()) { log.debug("Committed {} in term {}", //$NON-NLS-1$ committedIndex.describeForLog(), Long.valueOf(term));
/** {@inheritDoc} */ @SuppressWarnings("boxing") @Override public String toString() { return String.format("LogId[%5d/%s]", index, name()); //$NON-NLS-1$ } }
private void initialize() throws IOException { try (Repository git = openRepository(); RevWalk rw = new RevWalk(git)) { self.initialize(git); ObjectId accepted = self.getTxnAccepted(); if (!ObjectId.zeroId().equals(accepted)) { RevCommit c = rw.parseCommit(accepted); headIndex = LogIndex.unknown(accepted); refTree = RefTree.read(rw.getObjectReader(), c.getTree()); } else { headIndex = LogIndex.unknown(ObjectId.zeroId()); refTree = RefTree.newEmptyTree(); } } }
/** * Asynchronously distribute the round's new value for * {@code refs/txn/accepted} to all replicas. * <p> * Invoked by {@link #start()} after new commits have been created for the * log. The method passes {@code newId} to {@link KetchLeader} to be * distributed to all known replicas. * * @param newId * new value for {@code refs/txn/accepted}. */ void runAsync(AnyObjectId newId) { acceptedNewIndex = acceptedOldIndex.nextIndex(newId); leader.runAsync(this); }
private void removeStaged(List<ReceiveCommand> cmds, ObjectId committed) { List<ReceiveCommand> a = staged.remove(committed); if (a != null) { delete(cmds, a); } if (staged.isEmpty() || !(committed instanceof LogIndex)) { return; } LogIndex committedIndex = (LogIndex) committed; Iterator<Map.Entry<ObjectId, List<ReceiveCommand>>> itr = staged .entrySet().iterator(); while (itr.hasNext()) { Map.Entry<ObjectId, List<ReceiveCommand>> e = itr.next(); if (e.getKey() instanceof LogIndex) { LogIndex stagedIndex = (LogIndex) e.getKey(); if (stagedIndex.isBefore(committedIndex)) { delete(cmds, e.getValue()); itr.remove(); } } } }
assert headIndex.equals(runningRound.acceptedNewIndex); int matching = 0; for (KetchReplica r : voters) { if (log.isDebugEnabled()) { log.debug("Committed {} in term {}", //$NON-NLS-1$ committedIndex.describeForLog(), Long.valueOf(term));
@SuppressWarnings("boxing") @Override public String toString() { return String.format("LogId[%5d/%s]", index, name()); //$NON-NLS-1$ } }
private void initialize() throws IOException { try (Repository git = openRepository(); RevWalk rw = new RevWalk(git)) { self.initialize(git); ObjectId accepted = self.getTxnAccepted(); if (!ObjectId.zeroId().equals(accepted)) { RevCommit c = rw.parseCommit(accepted); headIndex = LogIndex.unknown(accepted); refTree = RefTree.read(rw.getObjectReader(), c.getTree()); } else { headIndex = LogIndex.unknown(ObjectId.zeroId()); refTree = RefTree.newEmptyTree(); } } }
/** * Asynchronously distribute the round's new value for * {@code refs/txn/accepted} to all replicas. * <p> * Invoked by {@link #start()} after new commits have been created for the * log. The method passes {@code newId} to {@link KetchLeader} to be * distributed to all known replicas. * * @param newId * new value for {@code refs/txn/accepted}. */ void runAsync(AnyObjectId newId) { acceptedNewIndex = acceptedOldIndex.nextIndex(newId); leader.runAsync(this); }
private void removeStaged(List<ReceiveCommand> cmds, ObjectId committed) { List<ReceiveCommand> a = staged.remove(committed); if (a != null) { delete(cmds, a); } if (staged.isEmpty() || !(committed instanceof LogIndex)) { return; } LogIndex committedIndex = (LogIndex) committed; Iterator<Map.Entry<ObjectId, List<ReceiveCommand>>> itr = staged .entrySet().iterator(); while (itr.hasNext()) { Map.Entry<ObjectId, List<ReceiveCommand>> e = itr.next(); if (e.getKey() instanceof LogIndex) { LogIndex stagedIndex = (LogIndex) e.getKey(); if (stagedIndex.isBefore(committedIndex)) { delete(cmds, e.getValue()); itr.remove(); } } } }
assert headIndex.equals(runningRound.acceptedNewIndex); int matching = 0; for (KetchReplica r : voters) { if (log.isDebugEnabled()) { log.debug("Committed {} in term {}", //$NON-NLS-1$ committedIndex.describeForLog(), Long.valueOf(term));
static LogIndex unknown(AnyObjectId id) { return new LogIndex(id, 0); }
static String str(ObjectId c) { if (c instanceof LogIndex) { return ((LogIndex) c).describeForLog(); } else if (c != null) { return c.abbreviate(8).name(); } return "-"; //$NON-NLS-1$ } }
/** * @return string suitable for debug logging containing the log index and * abbreviated ObjectId. */ @SuppressWarnings("boxing") public String describeForLog() { return String.format("%5d/%s", index, abbreviate(6).name()); //$NON-NLS-1$ }
/** {@inheritDoc} */ @SuppressWarnings("boxing") @Override public String toString() { return String.format("LogId[%5d/%s]", index, name()); //$NON-NLS-1$ } }
private void initialize() throws IOException { try (Repository git = openRepository(); RevWalk rw = new RevWalk(git)) { self.initialize(git); ObjectId accepted = self.getTxnAccepted(); if (!ObjectId.zeroId().equals(accepted)) { RevCommit c = rw.parseCommit(accepted); headIndex = LogIndex.unknown(accepted); refTree = RefTree.read(rw.getObjectReader(), c.getTree()); } else { headIndex = LogIndex.unknown(ObjectId.zeroId()); refTree = RefTree.newEmptyTree(); } } }
/** * Asynchronously distribute the round's new value for * {@code refs/txn/accepted} to all replicas. * <p> * Invoked by {@link #start()} after new commits have been created for the * log. The method passes {@code newId} to {@link KetchLeader} to be * distributed to all known replicas. * * @param newId * new value for {@code refs/txn/accepted}. */ void runAsync(AnyObjectId newId) { acceptedNewIndex = acceptedOldIndex.nextIndex(newId); leader.runAsync(this); }