Class BundleFetchConnection
- java.lang.Object
-
- org.eclipse.jgit.transport.BaseConnection
-
- org.eclipse.jgit.transport.BaseFetchConnection
-
- org.eclipse.jgit.transport.BundleFetchConnection
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,Connection
,FetchConnection
class BundleFetchConnection extends BaseFetchConnection
Fetch connection for bundle based classes. It used by instances ofTransportBundle
-
-
Constructor Summary
Constructors Constructor Description BundleFetchConnection(Transport transportBundle, java.io.InputStream src)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
didFetchTestConnectivity()
Did the lastFetchConnection.fetch(ProgressMonitor, Collection, Set)
validate graph?protected void
doFetch(ProgressMonitor monitor, java.util.Collection<Ref> want, java.util.Set<ObjectId> have)
Implementation ofBaseFetchConnection.fetch(ProgressMonitor, Collection, Set)
without checking for multiple fetch.private PackProtocolException
duplicateAdvertisement(java.lang.String name)
java.util.Collection<PackLock>
getPackLocks()
All locks created by the lastFetchConnection.fetch(ProgressMonitor, Collection, Set)
call.private void
readBundleV2()
private java.lang.String
readLine(byte[] hdrbuf)
private int
readSignature()
void
setPackLockMessage(java.lang.String message)
Set the lock message used when holding a pack out of garbage collection.private void
verifyPrerequisites()
-
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
-
-
-
-
Constructor Detail
-
BundleFetchConnection
BundleFetchConnection(Transport transportBundle, java.io.InputStream src) throws TransportException
- Throws:
TransportException
-
-
Method Detail
-
readSignature
private int readSignature() throws java.io.IOException
- Throws:
java.io.IOException
-
readBundleV2
private void readBundleV2() throws java.io.IOException
- Throws:
java.io.IOException
-
duplicateAdvertisement
private PackProtocolException duplicateAdvertisement(java.lang.String name)
-
readLine
private java.lang.String readLine(byte[] hdrbuf) throws java.io.IOException
- Throws:
java.io.IOException
-
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, java.util.Collection<Ref> want, java.util.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.
-
setPackLockMessage
public void setPackLockMessage(java.lang.String message)
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.
-
getPackLocks
public java.util.Collection<PackLock> 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.
-
verifyPrerequisites
private void verifyPrerequisites() throws TransportException
- Throws:
TransportException
-
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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceConnection
- Specified by:
close
in classBaseConnection
-
-