/** * 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())); } }
/** * 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)); }
/** * Initializes local replica by reading accepted and committed references. * <p> * Loads accepted and committed references from the reference database of * the local replica and stores their current ObjectIds in memory. * * @param repo * repository to initialize state from. * @throws IOException * cannot read repository state. */ void initialize(Repository repo) throws IOException { RefDatabase refdb = repo.getRefDatabase(); if (refdb instanceof RefTreeDatabase) { RefTreeDatabase treeDb = (RefTreeDatabase) refdb; String txnNamespace = getSystem().getTxnNamespace(); if (!txnNamespace.equals(treeDb.getTxnNamespace())) { throw new IOException(MessageFormat.format( KetchText.get().mismatchedTxnNamespace, txnNamespace, treeDb.getTxnNamespace())); } refdb = treeDb.getBootstrap(); } initialize(refdb.exactRef( getSystem().getTxnAccepted(), getSystem().getTxnCommitted())); }
private Map<String, Ref> push(Repository git, Transport transport, List<RemoteCommand> cmds) throws IOException { Map<String, RemoteRefUpdate> updates = asUpdateMap(cmds); try (PushConnection connection = transport.openPush()) { Map<String, Ref> adv = connection.getRefsMap(); RemoteRefUpdate accepted = updates.get(getSystem().getTxnAccepted()); if (accepted != null && !isExpectedValue(adv, accepted)) { abort(cmds); return adv; } RemoteRefUpdate committed = updates.get(getSystem().getTxnCommitted()); if (committed != null && !isExpectedValue(adv, committed)) { abort(cmds); return adv; } if (committed != null && getCommitMethod() == ALL_REFS) { prepareCommit(git, cmds, updates, adv, committed.getNewObjectId()); } connection.push(NullProgressMonitor.INSTANCE, updates); return adv; } }
if (name.equals(getSystem().getTxnAccepted())) { acceptCmd = cmd; } else if (name.equals(getSystem().getTxnCommitted())) {
for (ReceiveCommand cmd : req.getCommands()) { String name = cmd.getRefName(); if (name.equals(getSystem().getTxnAccepted())) { accepted = cmd; } else if (name.equals(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())); } }
/** * 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())); } }
/** * 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)); }
/** * Initializes local replica by reading accepted and committed references. * <p> * Loads accepted and committed references from the reference database of * the local replica and stores their current ObjectIds in memory. * * @param repo * repository to initialize state from. * @throws IOException * cannot read repository state. */ void initialize(Repository repo) throws IOException { RefDatabase refdb = repo.getRefDatabase(); if (refdb instanceof RefTreeDatabase) { RefTreeDatabase treeDb = (RefTreeDatabase) refdb; String txnNamespace = getSystem().getTxnNamespace(); if (!txnNamespace.equals(treeDb.getTxnNamespace())) { throw new IOException(MessageFormat.format( KetchText.get().mismatchedTxnNamespace, txnNamespace, treeDb.getTxnNamespace())); } refdb = treeDb.getBootstrap(); } initialize(refdb.exactRef( getSystem().getTxnAccepted(), getSystem().getTxnCommitted())); }
/** * Initializes local replica by reading accepted and committed references. * <p> * Loads accepted and committed references from the reference database of * the local replica and stores their current ObjectIds in memory. * * @param repo * repository to initialize state from. * @throws IOException * cannot read repository state. */ void initialize(Repository repo) throws IOException { RefDatabase refdb = repo.getRefDatabase(); if (refdb instanceof RefTreeDatabase) { RefTreeDatabase treeDb = (RefTreeDatabase) refdb; String txnNamespace = getSystem().getTxnNamespace(); if (!txnNamespace.equals(treeDb.getTxnNamespace())) { throw new IOException(MessageFormat.format( KetchText.get().mismatchedTxnNamespace, txnNamespace, treeDb.getTxnNamespace())); } refdb = treeDb.getBootstrap(); } initialize(refdb.exactRef( getSystem().getTxnAccepted(), getSystem().getTxnCommitted())); }
private Map<String, Ref> push(Repository git, Transport transport, List<RemoteCommand> cmds) throws IOException { Map<String, RemoteRefUpdate> updates = asUpdateMap(cmds); try (PushConnection connection = transport.openPush()) { Map<String, Ref> adv = connection.getRefsMap(); RemoteRefUpdate accepted = updates.get(getSystem().getTxnAccepted()); if (accepted != null && !isExpectedValue(adv, accepted)) { abort(cmds); return adv; } RemoteRefUpdate committed = updates.get(getSystem().getTxnCommitted()); if (committed != null && !isExpectedValue(adv, committed)) { abort(cmds); return adv; } if (committed != null && getCommitMethod() == ALL_REFS) { prepareCommit(git, cmds, updates, adv, committed.getNewObjectId()); } connection.push(NullProgressMonitor.INSTANCE, updates); return adv; } }
private Map<String, Ref> push(Repository git, Transport transport, List<RemoteCommand> cmds) throws IOException { Map<String, RemoteRefUpdate> updates = asUpdateMap(cmds); try (PushConnection connection = transport.openPush()) { Map<String, Ref> adv = connection.getRefsMap(); RemoteRefUpdate accepted = updates.get(getSystem().getTxnAccepted()); if (accepted != null && !isExpectedValue(adv, accepted)) { abort(cmds); return adv; } RemoteRefUpdate committed = updates.get(getSystem().getTxnCommitted()); if (committed != null && !isExpectedValue(adv, committed)) { abort(cmds); return adv; } if (committed != null && getCommitMethod() == ALL_REFS) { prepareCommit(git, cmds, updates, adv, committed.getNewObjectId()); } connection.push(NullProgressMonitor.INSTANCE, updates); return adv; } }
if (name.equals(getSystem().getTxnAccepted())) { acceptCmd = cmd; } else if (name.equals(getSystem().getTxnCommitted())) {
if (name.equals(getSystem().getTxnAccepted())) { acceptCmd = cmd; } else if (name.equals(getSystem().getTxnCommitted())) {
for (ReceiveCommand cmd : req.getCommands()) { String name = cmd.getRefName(); if (name.equals(getSystem().getTxnAccepted())) { accepted = cmd; } else if (name.equals(getSystem().getTxnCommitted())) {
for (ReceiveCommand cmd : req.getCommands()) { String name = cmd.getRefName(); if (name.equals(getSystem().getTxnAccepted())) { accepted = cmd; } else if (name.equals(getSystem().getTxnCommitted())) {