Top Description Inners Fields Constructors Methods
org.eclipse.jgit.transport

pack-priv Class WalkFetchConnection

extends BaseFetchConnection
Class Inheritance
Imports
java.io.File, .FileNotFoundException, .FileOutputStream, .IOException, java.text.MessageFormat, java.util.ArrayDeque, .ArrayList, .Collection, .Deque, .HashMap, .HashSet, .LinkedHashMap, .List, .Map, .Map.Entry, .Set, org.eclipse.jgit.errors.CompoundException, .CorruptObjectException, .MissingObjectException, .TransportException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.internal.storage.file.ObjectDirectory, .PackIndex, .UnpackedObject, org.eclipse.jgit.lib.AnyObjectId, .Constants, .FileMode, .MutableObjectId, .ObjectChecker, .ObjectId, .ObjectInserter, .ObjectLoader, .ObjectReader, .ProgressMonitor, .Ref, .Repository, org.eclipse.jgit.revwalk.DateRevQueue, .RevCommit, .RevFlag, .RevObject, .RevTag, .RevTree, .RevWalk, org.eclipse.jgit.treewalk.TreeWalk, org.eclipse.jgit.util.FileUtils

Generic fetch support for dumb transport protocols.

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
WalkRemoteObjectDatabase

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final RevFlag
COMPLETE

Objects whose direct dependents we know we have (or will have).

private final HashMap<ObjectId, List<Throwable>>
fetchErrors

Errors received while trying to obtain an object.

private final MutableObjectId
private final RevFlag
IN_WORK_QUEUE

Objects that have already entered workQueue.

pack-priv final ObjectInserter
inserter

Inserter to write objects onto local.

private int
lastRemoteIdx

Most recently used item in remotes.

pack-priv final Repository
local

The repository this transport fetches into, or pushes out of.

private final DateRevQueue
localCommitQueue

Commits already reachable from all local refs.

private final RevFlag
LOCALLY_SEEN

Commits that have already entered localCommitQueue.

pack-priv String
private final Deque<WalkRemoteObjectDatabase>
noAlternatesYet

Databases we have not yet obtained the alternates from.

private final Deque<WalkRemoteObjectDatabase>
noPacksYet

Databases we have not yet obtained the list of packs from.

pack-priv final ObjectChecker
objCheck

If not null the validator for received objects.

pack-priv final List<PackLock>
private final Set<String>
packsConsidered

Packs whose indexes we have looked at in unfetchedPacks.

private final ObjectReader
reader

Inserter to read objects from local.

private final List<WalkRemoteObjectDatabase>
remotes

List of all remote repositories we may need to get objects out of.

private final RevWalk
private final TreeWalk
private final Map<String, WalkFetchConnection.RemotePack>
unfetchedPacks

Packs we have discovered, but have not yet fetched locally.

private Deque<ObjectId>
workQueue

Objects we need to copy from the remote repository.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private boolean
public void
close()

Implements abstract org.eclipse.jgit.transport.BaseConnection.close.

Implements org.eclipse.jgit.transport.Connection.close.

Closes this resource, relinquishing any underlying resources.

public boolean
protected void
private boolean
downloadLooseObject(final AnyObjectId id, final String looseName, final WalkRemoteObjectDatabase remote)

private void
private boolean
private boolean
downloadPackedObject(final ProgressMonitor monitor, final AnyObjectId id, Set<String> brokenPacks)

private Collection<WalkRemoteObjectDatabase>
public Collection<PackLock>
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
public void
setPackLockMessage(String
message to use when holding a pack in place.
message
)

Implements org.eclipse.jgit.transport.FetchConnection.setPackLockMessage.

Set the lock message used when holding a pack out of garbage collection.

private Deque<ObjectId>
private void
verifyAndInsertLooseObject(final AnyObjectId id, final byte[] compressed)

Inherited from org.eclipse.jgit.transport.BaseFetchConnection:
didFetchIncludeTagsfetchfetch

Field Detail

COMPLETEback to summary
private final RevFlag COMPLETE

Objects whose direct dependents we know we have (or will have).

fetchErrorsback to summary
private final HashMap<ObjectId, List<Throwable>> 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.

idBufferback to summary
private final MutableObjectId idBuffer
IN_WORK_QUEUEback to summary
private final RevFlag IN_WORK_QUEUE

Objects that have already entered workQueue.

inserterback to summary
pack-priv final ObjectInserter inserter

Inserter to write objects onto local.

lastRemoteIdxback to summary
private int lastRemoteIdx

Most recently used item in remotes.

localback to summary
pack-priv final Repository local

The repository this transport fetches into, or pushes out of.

localCommitQueueback to summary
private final DateRevQueue localCommitQueue

Commits already reachable from all local refs.

LOCALLY_SEENback to summary
private final RevFlag LOCALLY_SEEN

Commits that have already entered localCommitQueue.

lockMessageback to summary
pack-priv String lockMessage
noAlternatesYetback to summary
private final Deque<WalkRemoteObjectDatabase> noAlternatesYet

Databases we have not yet obtained the alternates from.

noPacksYetback to summary
private final Deque<WalkRemoteObjectDatabase> noPacksYet

Databases we have not yet obtained the list of packs from.

objCheckback to summary
pack-priv final ObjectChecker objCheck

If not null the validator for received objects.

packLocksback to summary
pack-priv final List<PackLock> packLocks
packsConsideredback to summary
private final Set<String> packsConsidered

Packs whose indexes we have looked at in 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.

readerback to summary
private final ObjectReader reader

Inserter to read objects from local.

remotesback to summary
private final List<WalkRemoteObjectDatabase> 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.

revWalkback to summary
private final RevWalk revWalk
treeWalkback to summary
private final TreeWalk treeWalk
unfetchedPacksback to summary
private final Map<String, WalkFetchConnection.RemotePack> unfetchedPacks

Packs we have discovered, but have not yet fetched locally.

workQueueback to summary
private Deque<ObjectId> workQueue

Objects we need to copy from the remote repository.

Constructor Detail

WalkFetchConnectionback to summary
pack-priv WalkFetchConnection(WalkTransport t, WalkRemoteObjectDatabase w)

Method Detail

alreadyHaveback to summary
private boolean alreadyHave(AnyObjectId id) throws TransportException
closeback to summary
public void close()

Implements abstract org.eclipse.jgit.transport.BaseConnection.close.

Implements org.eclipse.jgit.transport.Connection.close.

Doc from org.eclipse.jgit.transport.Connection.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

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 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.

Annotations
@Override
didFetchTestConnectivityback to summary
public boolean didFetchTestConnectivity()

Implements org.eclipse.jgit.transport.FetchConnection.didFetchTestConnectivity.

Doc from org.eclipse.jgit.transport.FetchConnection.didFetchTestConnectivity.

Did the last 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:boolean

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.

Annotations
@Override
doFetchback to summary
protected void doFetch(final ProgressMonitor monitor, final Collection<Ref> want, final Set<ObjectId> have) throws TransportException

Implements abstract org.eclipse.jgit.transport.BaseFetchConnection.doFetch.

Doc from org.eclipse.jgit.transport.BaseFetchConnection.doFetch.

Implementation of fetch(ProgressMonitor, Collection, Set) without checking for multiple fetch.

Parameters
monitor:ProgressMonitor

as in fetch(ProgressMonitor, Collection, Set)

want:Collection<Ref>

as in fetch(ProgressMonitor, Collection, Set)

have:Set<ObjectId>

as in fetch(ProgressMonitor, Collection, Set)

Annotations
@Override
Exceptions
TransportException:
as in fetch(ProgressMonitor, Collection, Set), but implementation doesn't have to care about multiple fetch(ProgressMonitor, Collection, Set) calls, as it is checked in this class.
downloadLooseObjectback to summary
private boolean downloadLooseObject(final AnyObjectId id, final String looseName, final WalkRemoteObjectDatabase remote) throws TransportException
downloadObjectback to summary
private void downloadObject(ProgressMonitor pm, AnyObjectId id) throws TransportException
downloadPackedObjectback to summary
private boolean downloadPackedObject(ProgressMonitor monitor, AnyObjectId id) throws TransportException
downloadPackedObjectback to summary
private boolean downloadPackedObject(final ProgressMonitor monitor, final AnyObjectId id, Set<String> brokenPacks) throws TransportException
Annotations
@SuppressWarnings:Finally
expandOneAlternateback to summary
private Collection<WalkRemoteObjectDatabase> expandOneAlternate(final AnyObjectId id, final ProgressMonitor pm)
getPackLocksback to summary
public Collection<PackLock> getPackLocks()

Implements org.eclipse.jgit.transport.FetchConnection.getPackLocks.

Doc from org.eclipse.jgit.transport.FetchConnection.getPackLocks.

All locks created by the last fetch(ProgressMonitor, Collection, Set) call.

Returns:Collection<PackLock>

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.

Annotations
@Override
markLocalCommitsCompleteback to summary
private void markLocalCommitsComplete(int until) throws TransportException
markLocalObjCompleteback to summary
private void markLocalObjComplete(RevObject obj) throws IOException
markLocalRefsCompleteback to summary
private void markLocalRefsComplete(Set<ObjectId> have) throws TransportException
markTreeCompleteback to summary
private void markTreeComplete(RevTree tree) throws IOException
needsback to summary
private void needs(RevObject obj)
processback to summary
private void process(ObjectId id) throws TransportException
processBlobback to summary
private void processBlob(RevObject obj) throws TransportException
processCommitback to summary
private void processCommit(RevObject obj) throws TransportException
processTagback to summary
private void processTag(RevObject obj)
processTreeback to summary
private void processTree(RevObject obj) throws TransportException
pushLocalCommitback to summary
private void pushLocalCommit(RevCommit p) throws MissingObjectException, IOException
queueWantsback to summary
private void queueWants(Collection<Ref> want) throws TransportException
recordErrorback to summary
private void recordError(AnyObjectId id, Throwable what)
setPackLockMessageback to summary
public void setPackLockMessage(String message)

Implements org.eclipse.jgit.transport.FetchConnection.setPackLockMessage.

Doc from org.eclipse.jgit.transport.FetchConnection.setPackLockMessage.

Set the lock message used when holding a pack out of garbage collection.

Callers that set a lock message must ensure they call getPackLocks() after fetch(ProgressMonitor, Collection, Set), even if an exception was thrown, and release the locks that are held.

Parameters
message:String

message to use when holding a pack in place.

Annotations
@Override
swapFetchQueueback to summary
private Deque<ObjectId> swapFetchQueue()
verifyAndInsertLooseObjectback to summary
private void verifyAndInsertLooseObject(final AnyObjectId id, final byte[] compressed) throws IOException
org.eclipse.jgit.transport back to summary

private Class WalkFetchConnection.RemotePack

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final WalkRemoteObjectDatabase
pack-priv final String
pack-priv PackIndex
pack-priv final String
pack-priv File

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionback to summary
pack-priv final WalkRemoteObjectDatabase connection
idxNameback to summary
pack-priv final String idxName
indexback to summary
pack-priv PackIndex index
packNameback to summary
pack-priv final String packName
tmpIdxback to summary
pack-priv File tmpIdx

Constructor Detail

RemotePackback to summary
pack-priv RemotePack(WalkRemoteObjectDatabase c, String pn)

Method Detail

downloadPackback to summary
pack-priv void downloadPack(ProgressMonitor monitor) throws IOException
openIndexback to summary
pack-priv void openIndex(ProgressMonitor pm) throws IOException