replicas.add(new RemoteGitReplica(leader, n, uri, kc, rc));
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 void push(Repository repo, ReplicaPushRequest req) throws NotSupportedException, TransportException, IOException { Map<String, Ref> adv; List<RemoteCommand> cmds = asUpdateList(req.getCommands()); try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } transport.setPushAtomic(true); adv = push(repo, transport, cmds); } for (RemoteCommand c : cmds) { c.copyStatusToResult(); } req.setRefs(adv); }
/** {@inheritDoc} */ @Override protected void blockingFetch(Repository repo, ReplicaFetchRequest req) throws NotSupportedException, TransportException { try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } fetch(transport, req); } }
private static boolean isExpectedValue(Map<String, Ref> adv, RemoteRefUpdate u) { Ref r = adv.get(u.getRemoteName()); if (!AnyObjectId.equals(getId(r), u.getExpectedOldObjectId())) { ((RemoteCommand) u).cmd.setResult(LOCK_FAILURE); return false; } return true; }
@Override public void run() { try (Repository git = getLeader().openRepository()) { try { push(git, req); req.done(git); } catch (Throwable err) { req.setException(git, err); } } catch (IOException err) { req.setException(null, err); } } });
protected void blockingFetch(Repository repo, ReplicaFetchRequest req) throws NotSupportedException, TransportException { try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } fetch(transport, req); } }
private static boolean isExpectedValue(Map<String, Ref> adv, RemoteRefUpdate u) { Ref r = adv.get(u.getRemoteName()); if (!AnyObjectId.equals(getId(r), u.getExpectedOldObjectId())) { ((RemoteCommand) u).cmd.setResult(LOCK_FAILURE); return false; } return true; }
@Override public void run() { try (Repository git = getLeader().openRepository()) { try { push(git, req); req.done(git); } catch (Throwable err) { req.setException(git, err); } } catch (IOException err) { req.setException(null, err); } } });
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 void push(Repository repo, ReplicaPushRequest req) throws NotSupportedException, TransportException, IOException { Map<String, Ref> adv; List<RemoteCommand> cmds = asUpdateList(req.getCommands()); try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } transport.setPushAtomic(true); adv = push(repo, transport, cmds); } for (RemoteCommand c : cmds) { c.copyStatusToResult(); } req.setRefs(adv); }
/** {@inheritDoc} */ @Override protected void blockingFetch(Repository repo, ReplicaFetchRequest req) throws NotSupportedException, TransportException { try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } fetch(transport, req); } }
private static boolean isExpectedValue(Map<String, Ref> adv, RemoteRefUpdate u) { Ref r = adv.get(u.getRemoteName()); if (!AnyObjectId.equals(getId(r), u.getExpectedOldObjectId())) { ((RemoteCommand) u).cmd.setResult(LOCK_FAILURE); return false; } return true; }
@Override public void run() { try (Repository git = getLeader().openRepository()) { try { push(git, req); req.done(git); } catch (Throwable err) { req.setException(git, err); } } catch (IOException err) { req.setException(null, err); } } });
replicas.add(new RemoteGitReplica(leader, n, uri, kc, rc));
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 void push(Repository repo, ReplicaPushRequest req) throws NotSupportedException, TransportException, IOException { Map<String, Ref> adv; List<RemoteCommand> cmds = asUpdateList(req.getCommands()); try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } transport.setPushAtomic(true); adv = push(repo, transport, cmds); } for (RemoteCommand c : cmds) { c.copyStatusToResult(); } req.setRefs(adv); }