/** {@inheritDoc} */ @Override protected void startPush(ReplicaPushRequest req) { getSystem().getExecutor().execute(new Runnable() { @Override public void run() { MonotonicClock clk = getSystem().getClock(); try (Repository git = getLeader().openRepository(); ProposedTimestamp ts = clk.propose()) { try { update(git, req, ts); req.done(git); } catch (Throwable err) { req.setException(git, err); } } catch (IOException err) { req.setException(null, err); } } }); }
/** * 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 boolean isOnlyTxnNamespace(Collection<ReceiveCommand> cmdList) { // Be paranoid and reject non txnNamespace names, this // is a programming error in Ketch that should not occur. String txnNamespace = getSystem().getTxnNamespace(); for (ReceiveCommand cmd : cmdList) { if (!cmd.getRefName().startsWith(txnNamespace)) { cmd.setResult(REJECTED_OTHER_REASON, MessageFormat.format( KetchText.get().outsideTxnNamespace, cmd.getRefName(), txnNamespace)); ReceiveCommand.abort(cmdList); return false; } } return true; } }
@Override public void run() { MonotonicClock clk = getSystem().getClock(); try (Repository git = getLeader().openRepository(); ProposedTimestamp ts = clk.propose()) { try { update(git, req, ts); req.done(git); } catch (Throwable err) { req.setException(git, err); } } catch (IOException err) { req.setException(null, err); } } });
batch.setRefLogIdent(getSystem().newCommitter(ts)); batch.setRefLogMessage("ketch", false); //$NON-NLS-1$ batch.setAllowNonFastForwards(true); for (ReceiveCommand cmd : req.getCommands()) { String name = cmd.getRefName(); if (name.equals(getSystem().getTxnAccepted())) { accepted = cmd; } else if (name.equals(getSystem().getTxnCommitted())) { committed = cmd; } else {
@Override protected void startPush(final ReplicaPushRequest req) { getSystem().getExecutor().execute(new Runnable() { @Override public void run() { try (Repository git = getLeader().openRepository()) { try { update(git, req); req.done(git); } catch (Throwable err) { req.setException(git, err); } } catch (IOException err) { req.setException(null, err); } } }); }
/** {@inheritDoc} */ @Override protected void startPush(ReplicaPushRequest req) { getSystem().getExecutor().execute(new Runnable() { @Override public void run() { MonotonicClock clk = getSystem().getClock(); try (Repository git = getLeader().openRepository(); ProposedTimestamp ts = clk.propose()) { try { update(git, req, ts); req.done(git); } catch (Throwable err) { req.setException(git, err); } } catch (IOException err) { req.setException(null, err); } } }); }
/** * 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 boolean isOnlyTxnNamespace(Collection<ReceiveCommand> cmdList) { // Be paranoid and reject non txnNamespace names, this // is a programming error in Ketch that should not occur. String txnNamespace = getSystem().getTxnNamespace(); for (ReceiveCommand cmd : cmdList) { if (!cmd.getRefName().startsWith(txnNamespace)) { cmd.setResult(REJECTED_OTHER_REASON, MessageFormat.format( KetchText.get().outsideTxnNamespace, cmd.getRefName(), txnNamespace)); ReceiveCommand.abort(cmdList); return false; } } return true; } }
private boolean isOnlyTxnNamespace(Collection<ReceiveCommand> cmdList) { // Be paranoid and reject non txnNamespace names, this // is a programming error in Ketch that should not occur. String txnNamespace = getSystem().getTxnNamespace(); for (ReceiveCommand cmd : cmdList) { if (!cmd.getRefName().startsWith(txnNamespace)) { cmd.setResult(REJECTED_OTHER_REASON, MessageFormat.format( KetchText.get().outsideTxnNamespace, cmd.getRefName(), txnNamespace)); ReceiveCommand.abort(cmdList); return false; } } return true; } }
@Override public void run() { MonotonicClock clk = getSystem().getClock(); try (Repository git = getLeader().openRepository(); ProposedTimestamp ts = clk.propose()) { try { update(git, req, ts); req.done(git); } catch (Throwable err) { req.setException(git, err); } } catch (IOException err) { req.setException(null, err); } } });
batch.setRefLogIdent(getSystem().newCommitter()); batch.setRefLogMessage("ketch", false); //$NON-NLS-1$ batch.setAllowNonFastForwards(true); for (ReceiveCommand cmd : req.getCommands()) { String name = cmd.getRefName(); if (name.equals(getSystem().getTxnAccepted())) { accepted = cmd; } else if (name.equals(getSystem().getTxnCommitted())) { committed = cmd; } else {
batch.setRefLogIdent(getSystem().newCommitter(ts)); batch.setRefLogMessage("ketch", false); //$NON-NLS-1$ batch.setAllowNonFastForwards(true); for (ReceiveCommand cmd : req.getCommands()) { String name = cmd.getRefName(); if (name.equals(getSystem().getTxnAccepted())) { accepted = cmd; } else if (name.equals(getSystem().getTxnCommitted())) { committed = cmd; } else {