boolean canDelete(Ref ref) { String name = ref.getName(); if (HEAD.equals(name)) { return false; } if (name.startsWith(getSystem().getTxnNamespace())) { return false; } // TODO(sop) Do not delete precious names from replica. return true; }
/** * Update the leader's view of the replica after a poll. * <p> * Called with {@link KetchLeader#lock} held by caller. * * @param refs * map of refs from the replica. */ void initialize(Map<String, Ref> refs) { if (txnAccepted == null) { txnAccepted = getId(refs.get(getSystem().getTxnAccepted())); } if (txnCommitted == null) { txnCommitted = getId(refs.get(getSystem().getTxnCommitted())); } }
private void prepareTxnCommitted(List<ReceiveCommand> cmds, ObjectId committed) { removeStaged(cmds, committed); cmds.add(new ReceiveCommand( txnCommitted, committed, getSystem().getTxnCommitted())); }
private void updateView(ReplicaPushRequest req, @Nullable ObjectId acceptId, ReceiveCommand commitCmd) { if (acceptId != null) { txnAccepted = acceptId; } ObjectId committed = readId(req, commitCmd); if (committed != null) { txnCommitted = committed; } else if (acceptId != null && txnCommitted == null) { // Initialize during first conversation. Map<String, Ref> adv = req.getRefs(); if (adv != null) { Ref refs = adv.get(getSystem().getTxnCommitted()); txnCommitted = getId(refs); } } }
private void retryLater(ReplicaPushRequest req) { Collection<ReceiveCommand> cmds = req.getCommands(); for (ReceiveCommand cmd : cmds) { cmd.setResult(NOT_ATTEMPTED, null); if (!waiting.containsKey(cmd.getRefName())) { waiting.put(cmd.getRefName(), cmd); } } queued.add(0, new ReplicaPushRequest(this, cmds)); if (!waitingForRetry()) { long delay = KetchSystem.delay( lastRetryMillis, minRetryMillis, maxRetryMillis); if (log.isDebugEnabled()) { log.debug("Retrying {} after {} ms", //$NON-NLS-1$ describeForLog(), Long.valueOf(delay)); } lastRetryMillis = delay; retryAtMillis = SystemReader.getInstance().getCurrentTime() + delay; retryFuture = getSystem().getExecutor() .schedule(new WeakRetryPush(this), delay, MILLISECONDS); } }
/** * Schedule a proposal round with the replica. * <p> * Called with {@link KetchLeader#lock} held by caller. * * @param round * current round being run by the leader. */ void pushTxnAcceptedAsync(Round round) { List<ReceiveCommand> cmds = new ArrayList<>(); if (commitSpeed == BATCHED) { LogIndex committedIndex = leader.getCommitted(); if (equals(txnAccepted, committedIndex) && !equals(txnCommitted, committedIndex)) { prepareTxnCommitted(cmds, committedIndex); } } // TODO(sop) Lagging replicas should build accept on the fly. if (round.stageCommands != null) { for (ReceiveCommand cmd : round.stageCommands) { // TODO(sop): Do not send certain object graphs to replica. cmds.add(copy(cmd)); } } cmds.add(new ReceiveCommand( round.acceptedOldIndex, round.acceptedNewIndex, getSystem().getTxnAccepted())); pushAsync(new ReplicaPushRequest(this, cmds)); }
boolean canDelete(Ref ref) { String name = ref.getName(); if (HEAD.equals(name)) { return false; } if (name.startsWith(getSystem().getTxnNamespace())) { return false; } // TODO(sop) Do not delete precious names from replica. return true; }
boolean canDelete(Ref ref) { String name = ref.getName(); if (HEAD.equals(name)) { return false; } if (name.startsWith(getSystem().getTxnNamespace())) { return false; } // TODO(sop) Do not delete precious names from replica. return true; }
/** * Update the leader's view of the replica after a poll. * <p> * Called with {@link KetchLeader#lock} held by caller. * * @param refs * map of refs from the replica. */ void initialize(Map<String, Ref> refs) { if (txnAccepted == null) { txnAccepted = getId(refs.get(getSystem().getTxnAccepted())); } if (txnCommitted == null) { txnCommitted = getId(refs.get(getSystem().getTxnCommitted())); } }
/** * Update the leader's view of the replica after a poll. * <p> * Called with {@link KetchLeader#lock} held by caller. * * @param refs * map of refs from the replica. */ void initialize(Map<String, Ref> refs) { if (txnAccepted == null) { txnAccepted = getId(refs.get(getSystem().getTxnAccepted())); } if (txnCommitted == null) { txnCommitted = getId(refs.get(getSystem().getTxnCommitted())); } }
private void prepareTxnCommitted(List<ReceiveCommand> cmds, ObjectId committed) { removeStaged(cmds, committed); cmds.add(new ReceiveCommand( txnCommitted, committed, getSystem().getTxnCommitted())); }
private void prepareTxnCommitted(List<ReceiveCommand> cmds, ObjectId committed) { removeStaged(cmds, committed); cmds.add(new ReceiveCommand( txnCommitted, committed, getSystem().getTxnCommitted())); }
private void updateView(ReplicaPushRequest req, @Nullable ObjectId acceptId, ReceiveCommand commitCmd) { if (acceptId != null) { txnAccepted = acceptId; } ObjectId committed = readId(req, commitCmd); if (committed != null) { txnCommitted = committed; } else if (acceptId != null && txnCommitted == null) { // Initialize during first conversation. Map<String, Ref> adv = req.getRefs(); if (adv != null) { Ref refs = adv.get(getSystem().getTxnCommitted()); txnCommitted = getId(refs); } } }
private void updateView(ReplicaPushRequest req, @Nullable ObjectId acceptId, ReceiveCommand commitCmd) { if (acceptId != null) { txnAccepted = acceptId; } ObjectId committed = readId(req, commitCmd); if (committed != null) { txnCommitted = committed; } else if (acceptId != null && txnCommitted == null) { // Initialize during first conversation. Map<String, Ref> adv = req.getRefs(); if (adv != null) { Ref refs = adv.get(getSystem().getTxnCommitted()); txnCommitted = getId(refs); } } }
private void retryLater(ReplicaPushRequest req) { Collection<ReceiveCommand> cmds = req.getCommands(); for (ReceiveCommand cmd : cmds) { cmd.setResult(NOT_ATTEMPTED, null); if (!waiting.containsKey(cmd.getRefName())) { waiting.put(cmd.getRefName(), cmd); } } queued.add(0, new ReplicaPushRequest(this, cmds)); if (!waitingForRetry()) { long delay = KetchSystem.delay( lastRetryMillis, minRetryMillis, maxRetryMillis); if (log.isDebugEnabled()) { log.debug("Retrying {} after {} ms", //$NON-NLS-1$ describeForLog(), Long.valueOf(delay)); } lastRetryMillis = delay; retryAtMillis = SystemReader.getInstance().getCurrentTime() + delay; retryFuture = getSystem().getExecutor() .schedule(new WeakRetryPush(this), delay, MILLISECONDS); } }
private void retryLater(ReplicaPushRequest req) { Collection<ReceiveCommand> cmds = req.getCommands(); for (ReceiveCommand cmd : cmds) { cmd.setResult(NOT_ATTEMPTED, null); if (!waiting.containsKey(cmd.getRefName())) { waiting.put(cmd.getRefName(), cmd); } } queued.add(0, new ReplicaPushRequest(this, cmds)); if (!waitingForRetry()) { long delay = KetchSystem.delay( lastRetryMillis, minRetryMillis, maxRetryMillis); if (log.isDebugEnabled()) { log.debug("Retrying {} after {} ms", //$NON-NLS-1$ describeForLog(), Long.valueOf(delay)); } lastRetryMillis = delay; retryAtMillis = SystemReader.getInstance().getCurrentTime() + delay; retryFuture = getSystem().getExecutor() .schedule(new WeakRetryPush(this), delay, MILLISECONDS); } }
/** * Schedule a proposal round with the replica. * <p> * Called with {@link KetchLeader#lock} held by caller. * * @param round * current round being run by the leader. */ void pushTxnAcceptedAsync(Round round) { List<ReceiveCommand> cmds = new ArrayList<>(); if (commitSpeed == BATCHED) { LogIndex committedIndex = leader.getCommitted(); if (equals(txnAccepted, committedIndex) && !equals(txnCommitted, committedIndex)) { prepareTxnCommitted(cmds, committedIndex); } } // TODO(sop) Lagging replicas should build accept on the fly. if (round.stageCommands != null) { for (ReceiveCommand cmd : round.stageCommands) { // TODO(sop): Do not send certain object graphs to replica. cmds.add(copy(cmd)); } } cmds.add(new ReceiveCommand( round.acceptedOldIndex, round.acceptedNewIndex, getSystem().getTxnAccepted())); pushAsync(new ReplicaPushRequest(this, cmds)); }
/** * Schedule a proposal round with the replica. * <p> * Called with {@link KetchLeader#lock} held by caller. * * @param round * current round being run by the leader. */ void pushTxnAcceptedAsync(Round round) { List<ReceiveCommand> cmds = new ArrayList<>(); if (commitSpeed == BATCHED) { LogIndex committedIndex = leader.getCommitted(); if (equals(txnAccepted, committedIndex) && !equals(txnCommitted, committedIndex)) { prepareTxnCommitted(cmds, committedIndex); } } // TODO(sop) Lagging replicas should build accept on the fly. if (round.stageCommands != null) { for (ReceiveCommand cmd : round.stageCommands) { // TODO(sop): Do not send certain object graphs to replica. cmds.add(copy(cmd)); } } cmds.add(new ReceiveCommand( round.acceptedOldIndex, round.acceptedNewIndex, getSystem().getTxnAccepted())); pushAsync(new ReplicaPushRequest(this, cmds)); }