public class RemoteGitReplica extends KetchReplica
KetchLeader
will contact the replica
using the Git wire protocol.
The remote replica may be fully Ketch-aware, or a standard Git server.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
RemoteGitReplica.RemoteCommand |
KetchReplica.CommitMethod, KetchReplica.CommitSpeed, KetchReplica.Participation, KetchReplica.State, KetchReplica.WeakRetryPush
Modifier and Type | Field and Description |
---|---|
private RemoteConfig |
remoteConfig |
private URIish |
uri |
log
Constructor and Description |
---|
RemoteGitReplica(KetchLeader leader,
java.lang.String name,
URIish uri,
ReplicaConfig cfg,
RemoteConfig rc)
Configure a new remote.
|
Modifier and Type | Method and Description |
---|---|
private static void |
abort(java.util.List<RemoteGitReplica.RemoteCommand> cmds) |
private static java.util.List<RemoteGitReplica.RemoteCommand> |
asUpdateList(java.util.Collection<ReceiveCommand> cmds) |
private static java.util.Map<java.lang.String,RemoteRefUpdate> |
asUpdateMap(java.util.List<RemoteGitReplica.RemoteCommand> cmds) |
protected void |
blockingFetch(Repository repo,
ReplicaFetchRequest req)
Fetch objects from the remote using the calling thread.
|
protected java.lang.String |
describeForLog()
Get description of this replica for error/debug logging purposes.
|
private void |
fetch(Transport transport,
ReplicaFetchRequest req) |
protected RemoteConfig |
getRemoteConfig()
Get optional configuration describing how to contact the peer.
|
URIish |
getURI()
Get URI to contact the remote peer repository.
|
private static boolean |
isExpectedValue(java.util.Map<java.lang.String,Ref> adv,
RemoteRefUpdate u) |
private void |
prepareCommit(Repository git,
java.util.List<RemoteGitReplica.RemoteCommand> cmds,
java.util.Map<java.lang.String,RemoteRefUpdate> updates,
java.util.Map<java.lang.String,Ref> adv,
ObjectId committed) |
private void |
push(Repository repo,
ReplicaPushRequest req) |
private java.util.Map<java.lang.String,Ref> |
push(Repository git,
Transport transport,
java.util.List<RemoteGitReplica.RemoteCommand> cmds) |
protected void |
startPush(ReplicaPushRequest req)
Begin executing a single push.
|
afterPush, canDelete, getCommitMethod, getCommitSpeed, getId, getLeader, getName, getParticipation, getSystem, getTxnAccepted, hasAccepted, initialize, prepareCommit, pushCommitAsync, pushTxnAcceptedAsync, shouldPushUnbatchedCommit, shutdown, snapshot
private final URIish uri
private final RemoteConfig remoteConfig
public RemoteGitReplica(KetchLeader leader, java.lang.String name, URIish uri, ReplicaConfig cfg, @Nullable RemoteConfig rc)
leader
- instance this replica follows.name
- unique-ish name identifying this remote for debugging.uri
- URI to connect to the follower's repository.cfg
- how Ketch should treat the remote system.rc
- optional remote configuration describing how to contact the
peer repository.public URIish getURI()
@Nullable protected RemoteConfig getRemoteConfig()
protected java.lang.String describeForLog()
describeForLog
in class KetchReplica
protected void startPush(ReplicaPushRequest req)
This method must move processing onto another thread. Called with
KetchLeader.lock
held by caller.
startPush
in class KetchReplica
req
- the request to send to the replica.private void push(Repository repo, ReplicaPushRequest req) throws NotSupportedException, TransportException, java.io.IOException
NotSupportedException
TransportException
java.io.IOException
private java.util.Map<java.lang.String,Ref> push(Repository git, Transport transport, java.util.List<RemoteGitReplica.RemoteCommand> cmds) throws java.io.IOException
java.io.IOException
private static boolean isExpectedValue(java.util.Map<java.lang.String,Ref> adv, RemoteRefUpdate u)
private void prepareCommit(Repository git, java.util.List<RemoteGitReplica.RemoteCommand> cmds, java.util.Map<java.lang.String,RemoteRefUpdate> updates, java.util.Map<java.lang.String,Ref> adv, ObjectId committed) throws java.io.IOException
java.io.IOException
private static java.util.List<RemoteGitReplica.RemoteCommand> asUpdateList(java.util.Collection<ReceiveCommand> cmds)
private static java.util.Map<java.lang.String,RemoteRefUpdate> asUpdateMap(java.util.List<RemoteGitReplica.RemoteCommand> cmds)
private static void abort(java.util.List<RemoteGitReplica.RemoteCommand> cmds)
protected void blockingFetch(Repository repo, ReplicaFetchRequest req) throws NotSupportedException, TransportException
Called without KetchLeader.lock
.
blockingFetch
in class KetchReplica
repo
- local repository to fetch objects into.req
- the request to fetch from a replica.NotSupportedException
TransportException
private void fetch(Transport transport, ReplicaFetchRequest req) throws NotSupportedException, TransportException