class WalkFetchConnection extends BaseFetchConnection
Since there are no Git-specific smarts on the remote side of the connection the client side must determine which objects it needs to copy in order to completely fetch the requested refs and their history. The generic walk support in this class parses each individual object (once it has been copied to the local repository) and examines the list of objects that must also be copied to create a complete history. Objects which are already available locally are retained (and not copied), saving bandwidth for incremental fetches. Pack files are copied from the remote repository only as a last resort, as the entire pack must be copied locally in order to access any single object.
This fetch connection does not actually perform the object data transfer.
Instead it delegates the transfer to a WalkRemoteObjectDatabase
,
which knows how to read individual files from the remote repository and
supply the data as a standard Java InputStream.
WalkRemoteObjectDatabase
Modifier and Type | Class and Description |
---|---|
private class |
WalkFetchConnection.RemotePack |
Modifier and Type | Field and Description |
---|---|
private RevFlag |
COMPLETE
Objects whose direct dependents we know we have (or will have).
|
private java.util.HashMap<ObjectId,java.util.List<java.lang.Throwable>> |
fetchErrors
Errors received while trying to obtain an object.
|
private MutableObjectId |
idBuffer |
private RevFlag |
IN_WORK_QUEUE
Objects that have already entered
workQueue . |
(package private) ObjectInserter |
inserter
Inserter to write objects onto
local . |
private int |
lastRemoteIdx
Most recently used item in
remotes . |
(package private) Repository |
local
The repository this transport fetches into, or pushes out of.
|
private DateRevQueue |
localCommitQueue
Commits already reachable from all local refs.
|
private RevFlag |
LOCALLY_SEEN
Commits that have already entered
localCommitQueue . |
(package private) java.lang.String |
lockMessage |
private java.util.LinkedList<WalkRemoteObjectDatabase> |
noAlternatesYet
Databases we have not yet obtained the alternates from.
|
private java.util.LinkedList<WalkRemoteObjectDatabase> |
noPacksYet
Databases we have not yet obtained the list of packs from.
|
(package private) ObjectChecker |
objCheck
If not null the validator for received objects.
|
(package private) java.util.List<PackLock> |
packLocks |
private java.util.Set<java.lang.String> |
packsConsidered
Packs whose indexes we have looked at in
unfetchedPacks . |
private ObjectReader |
reader
Inserter to read objects from
local . |
private java.util.List<WalkRemoteObjectDatabase> |
remotes
List of all remote repositories we may need to get objects out of.
|
private RevWalk |
revWalk |
private TreeWalk |
treeWalk |
private java.util.LinkedList<WalkFetchConnection.RemotePack> |
unfetchedPacks
Packs we have discovered, but have not yet fetched locally.
|
private java.util.LinkedList<ObjectId> |
workQueue
Objects we need to copy from the remote repository.
|
Constructor and Description |
---|
WalkFetchConnection(WalkTransport t,
WalkRemoteObjectDatabase w) |
Modifier and Type | Method and Description |
---|---|
private boolean |
alreadyHave(AnyObjectId id) |
void |
close() |
boolean |
didFetchTestConnectivity()
Did the last
FetchConnection.fetch(ProgressMonitor, Collection, Set) validate
graph? |
protected void |
doFetch(ProgressMonitor monitor,
java.util.Collection<Ref> want,
java.util.Set<ObjectId> have)
Implementation of
BaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
without checking for multiple fetch. |
private boolean |
downloadLooseObject(AnyObjectId id,
java.lang.String looseName,
WalkRemoteObjectDatabase remote) |
private void |
downloadObject(ProgressMonitor pm,
AnyObjectId id) |
private boolean |
downloadPackedObject(ProgressMonitor monitor,
AnyObjectId id) |
private java.util.Collection<WalkRemoteObjectDatabase> |
expandOneAlternate(AnyObjectId id,
ProgressMonitor pm) |
java.util.Collection<PackLock> |
getPackLocks()
All locks created by the last
FetchConnection.fetch(ProgressMonitor, Collection, Set) call. |
private void |
markLocalCommitsComplete(int until) |
private void |
markLocalObjComplete(RevObject obj) |
private void |
markLocalRefsComplete(java.util.Set<ObjectId> have) |
private void |
markTreeComplete(RevTree tree) |
private void |
needs(RevObject obj) |
private void |
process(ObjectId id) |
private void |
processBlob(RevObject obj) |
private void |
processCommit(RevObject obj) |
private void |
processTag(RevObject obj) |
private void |
processTree(RevObject obj) |
private void |
pushLocalCommit(RevCommit p) |
private void |
queueWants(java.util.Collection<Ref> want) |
private void |
recordError(AnyObjectId id,
java.lang.Throwable what) |
void |
setPackLockMessage(java.lang.String message)
Set the lock message used when holding a pack out of garbage collection.
|
private java.util.Iterator<ObjectId> |
swapFetchQueue() |
private void |
verifyAndInsertLooseObject(AnyObjectId id,
byte[] compressed) |
didFetchIncludeTags, fetch, fetch
available, getMessages, getMessageWriter, getPeerUserAgent, getRef, getRefs, getRefsMap, markStartedOperation, setMessageWriter, setPeerUserAgent
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMessages, getPeerUserAgent, getRef, getRefs, getRefsMap
final Repository local
final ObjectChecker objCheck
private final java.util.List<WalkRemoteObjectDatabase> remotes
The first repository in the list is the one we were asked to fetch from; the remaining repositories point to the alternate locations we can fetch objects through.
private int lastRemoteIdx
remotes
.private final RevWalk revWalk
private final TreeWalk treeWalk
private final RevFlag COMPLETE
private final RevFlag LOCALLY_SEEN
localCommitQueue
.private final DateRevQueue localCommitQueue
private java.util.LinkedList<ObjectId> workQueue
private final java.util.LinkedList<WalkRemoteObjectDatabase> noPacksYet
private final java.util.LinkedList<WalkRemoteObjectDatabase> noAlternatesYet
private final java.util.LinkedList<WalkFetchConnection.RemotePack> unfetchedPacks
private final java.util.Set<java.lang.String> packsConsidered
unfetchedPacks
.
We try to avoid getting duplicate copies of the same pack through multiple alternates by only looking at packs whose names are not yet in this collection.
private final MutableObjectId idBuffer
private final java.util.HashMap<ObjectId,java.util.List<java.lang.Throwable>> fetchErrors
If the fetch winds up failing because we cannot locate a specific object then we need to report all errors related to that object back to the caller as there may be cascading failures.
java.lang.String lockMessage
final java.util.List<PackLock> packLocks
final ObjectInserter inserter
local
.private final ObjectReader reader
local
.WalkFetchConnection(WalkTransport t, WalkRemoteObjectDatabase w)
public boolean didFetchTestConnectivity()
FetchConnection.fetch(ProgressMonitor, Collection, Set)
validate
graph?
Some transports walk the object graph on the client side, with the client looking for what objects it is missing and requesting them individually from the remote peer. By virtue of completing the fetch call the client implicitly tested the object connectivity, as every object in the graph was either already local or was requested successfully from the peer. In such transports this method returns true.
Some transports assume the remote peer knows the Git object graph and is able to supply a fully connected graph to the client (although it may only be transferring the parts the client does not yet have). Its faster to assume such remote peers are well behaved and send the correct response to the client. In such transports this method returns false.
protected void doFetch(ProgressMonitor monitor, java.util.Collection<Ref> want, java.util.Set<ObjectId> have) throws TransportException
BaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
without checking for multiple fetch.doFetch
in class BaseFetchConnection
monitor
- as in BaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
want
- as in BaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
have
- as in BaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
TransportException
- as in BaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
, but
implementation doesn't have to care about multiple
BaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
calls, as it
is checked in this class.public java.util.Collection<PackLock> getPackLocks()
FetchConnection.fetch(ProgressMonitor, Collection, Set)
call.public void setPackLockMessage(java.lang.String message)
Callers that set a lock message must ensure they call
FetchConnection.getPackLocks()
after
FetchConnection.fetch(ProgressMonitor, Collection, Set)
, even if an exception
was thrown, and release the locks that are held.
message
- message to use when holding a pack in place.public void close()
Close any resources used by this connection.
If the remote repository is contacted by a network socket this method must close that network socket, disconnecting the two peers. If the remote repository is actually local (same system) this method must close any open file handles used to read the "remote" repository.
If additional messages were produced by the remote peer, these should
still be retained in the connection instance for Connection.getMessages()
.
AutoClosable.close()
declares that it throws Exception
.
Implementers shouldn't throw checked exceptions. This override narrows
the signature to prevent them from doing so.
close
in interface java.lang.AutoCloseable
close
in interface Connection
close
in class BaseConnection
private void queueWants(java.util.Collection<Ref> want) throws TransportException
TransportException
private void process(ObjectId id) throws TransportException
TransportException
private void processBlob(RevObject obj) throws TransportException
TransportException
private void processTree(RevObject obj) throws TransportException
TransportException
private void processCommit(RevObject obj) throws TransportException
TransportException
private void processTag(RevObject obj)
private void needs(RevObject obj)
private void downloadObject(ProgressMonitor pm, AnyObjectId id) throws TransportException
TransportException
private boolean alreadyHave(AnyObjectId id) throws TransportException
TransportException
private boolean downloadPackedObject(ProgressMonitor monitor, AnyObjectId id) throws TransportException
TransportException
private java.util.Iterator<ObjectId> swapFetchQueue()
private boolean downloadLooseObject(AnyObjectId id, java.lang.String looseName, WalkRemoteObjectDatabase remote) throws TransportException
TransportException
private void verifyAndInsertLooseObject(AnyObjectId id, byte[] compressed) throws java.io.IOException
java.io.IOException
private java.util.Collection<WalkRemoteObjectDatabase> expandOneAlternate(AnyObjectId id, ProgressMonitor pm)
private void markLocalRefsComplete(java.util.Set<ObjectId> have) throws TransportException
TransportException
private void markLocalObjComplete(RevObject obj) throws java.io.IOException
java.io.IOException
private void markLocalCommitsComplete(int until) throws TransportException
TransportException
private void pushLocalCommit(RevCommit p) throws MissingObjectException, java.io.IOException
MissingObjectException
java.io.IOException
private void markTreeComplete(RevTree tree) throws java.io.IOException
java.io.IOException
private void recordError(AnyObjectId id, java.lang.Throwable what)