Class WalkFetchConnection
- All Implemented Interfaces:
AutoCloseable
,Connection
,FetchConnection
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.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RevFlag
Objects whose direct dependents we know we have (or will have).Errors received while trying to obtain an object.private final MutableObjectId
private final RevFlag
Objects that have already enteredworkQueue
.(package private) final ObjectInserter
Inserter to write objects ontolocal
.private int
Most recently used item inremotes
.(package private) final Repository
The repository this transport fetches into, or pushes out of.private final DateRevQueue
Commits already reachable from all local refs.private final RevFlag
Commits that have already enteredlocalCommitQueue
.(package private) String
private final LinkedList
<WalkRemoteObjectDatabase> Databases we have not yet obtained the alternates from.private final LinkedList
<WalkRemoteObjectDatabase> Databases we have not yet obtained the list of packs from.(package private) final ObjectChecker
If not null the validator for received objects.Packs whose indexes we have looked at inunfetchedPacks
.private final ObjectReader
Inserter to read objects fromlocal
.private final List
<WalkRemoteObjectDatabase> List of all remote repositories we may need to get objects out of.private final RevWalk
private final TreeWalk
private final LinkedList
<WalkFetchConnection.RemotePack> Packs we have discovered, but have not yet fetched locally.private LinkedList
<ObjectId> Objects we need to copy from the remote repository. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
void
close()
boolean
Did the lastFetchConnection.fetch(ProgressMonitor, Collection, Set)
validate graph?protected void
doFetch
(ProgressMonitor monitor, Collection<Ref> want, Set<ObjectId> have) Implementation ofBaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
without checking for multiple fetch.private boolean
downloadLooseObject
(AnyObjectId id, String looseName, WalkRemoteObjectDatabase remote) private void
downloadObject
(ProgressMonitor pm, AnyObjectId id) private boolean
downloadPackedObject
(ProgressMonitor monitor, AnyObjectId id) private Collection
<WalkRemoteObjectDatabase> All locks created by the lastFetchConnection.fetch(ProgressMonitor, Collection, Set)
call.private void
markLocalCommitsComplete
(int until) private void
private void
markLocalRefsComplete
(Set<ObjectId> have) private void
markTreeComplete
(RevTree tree) private void
private void
private void
processBlob
(RevObject obj) private void
processCommit
(RevObject obj) private void
processTag
(RevObject obj) private void
processTree
(RevObject obj) private void
private void
queueWants
(Collection<Ref> want) private void
recordError
(AnyObjectId id, Throwable what) void
setPackLockMessage
(String message) Set the lock message used when holding a pack out of garbage collection.private void
verifyAndInsertLooseObject
(AnyObjectId id, byte[] compressed) Methods inherited from class org.eclipse.jgit.transport.BaseFetchConnection
didFetchIncludeTags, fetch, fetch
Methods inherited from class org.eclipse.jgit.transport.BaseConnection
available, getMessages, getMessageWriter, getPeerUserAgent, getRef, getRefs, getRefsMap, markStartedOperation, setMessageWriter, setPeerUserAgent
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.jgit.transport.Connection
getMessages, getPeerUserAgent, getRef, getRefs, getRefsMap
-
Field Details
-
local
The repository this transport fetches into, or pushes out of. -
objCheck
If not null the validator for received objects. -
remotes
List of all remote repositories we may need to get objects out of.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.
-
lastRemoteIdx
private int lastRemoteIdxMost recently used item inremotes
. -
revWalk
-
treeWalk
-
COMPLETE
Objects whose direct dependents we know we have (or will have). -
IN_WORK_QUEUE
Objects that have already enteredworkQueue
. -
LOCALLY_SEEN
Commits that have already enteredlocalCommitQueue
. -
localCommitQueue
Commits already reachable from all local refs. -
workQueue
Objects we need to copy from the remote repository. -
noPacksYet
Databases we have not yet obtained the list of packs from. -
noAlternatesYet
Databases we have not yet obtained the alternates from. -
unfetchedPacks
Packs we have discovered, but have not yet fetched locally. -
packsConsidered
Packs whose indexes we have looked at inunfetchedPacks
.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.
-
idBuffer
-
fetchErrors
Errors received while trying to obtain an object.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.
-
lockMessage
String lockMessage -
packLocks
-
inserter
Inserter to write objects ontolocal
. -
reader
Inserter to read objects fromlocal
.
-
-
Constructor Details
-
WalkFetchConnection
WalkFetchConnection(WalkTransport t, WalkRemoteObjectDatabase w)
-
-
Method Details
-
didFetchTestConnectivity
public boolean didFetchTestConnectivity()Did the lastFetchConnection.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.
- Returns:
- true if the last fetch had to perform a connectivity check on the client side in order to succeed; false if the last fetch assumed the remote peer supplied a complete graph.
-
doFetch
protected void doFetch(ProgressMonitor monitor, Collection<Ref> want, Set<ObjectId> have) throws TransportException Implementation ofBaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
without checking for multiple fetch.- Specified by:
doFetch
in classBaseFetchConnection
- Parameters:
monitor
- as inBaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
want
- as inBaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
have
- as inBaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
- Throws:
TransportException
- as inBaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
, but implementation doesn't have to care about multipleBaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
calls, as it is checked in this class.
-
getPackLocks
All locks created by the lastFetchConnection.fetch(ProgressMonitor, Collection, Set)
call.- Returns:
- collection (possibly empty) of locks created by the last call to fetch. The caller must release these after refs are updated in order to safely permit garbage collection.
-
setPackLockMessage
Set the lock message used when holding a pack out of garbage collection.Callers that set a lock message must ensure they call
FetchConnection.getPackLocks()
afterFetchConnection.fetch(ProgressMonitor, Collection, Set)
, even if an exception was thrown, and release the locks that are held.- Parameters:
message
- message to use when holding a pack in place.
-
close
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 throwsException
. Implementers shouldn't throw checked exceptions. This override narrows the signature to prevent them from doing so.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnection
- Specified by:
close
in classBaseConnection
-
queueWants
- Throws:
TransportException
-
process
- Throws:
TransportException
-
processBlob
- Throws:
TransportException
-
processTree
- Throws:
TransportException
-
processCommit
- Throws:
TransportException
-
processTag
-
needs
-
downloadObject
- Throws:
TransportException
-
alreadyHave
- Throws:
TransportException
-
downloadPackedObject
private boolean downloadPackedObject(ProgressMonitor monitor, AnyObjectId id) throws TransportException - Throws:
TransportException
-
swapFetchQueue
-
downloadLooseObject
private boolean downloadLooseObject(AnyObjectId id, String looseName, WalkRemoteObjectDatabase remote) throws TransportException - Throws:
TransportException
-
verifyAndInsertLooseObject
- Throws:
IOException
-
expandOneAlternate
-
markLocalRefsComplete
- Throws:
TransportException
-
markLocalObjComplete
- Throws:
IOException
-
markLocalCommitsComplete
- Throws:
TransportException
-
pushLocalCommit
- Throws:
MissingObjectException
IOException
-
markTreeComplete
- Throws:
IOException
-
recordError
-