abstract class BasePackConnection extends BaseConnection
BasePackFetchConnection
,
BasePackPushConnection
Modifier and Type | Field and Description |
---|---|
protected java.util.Set<ObjectId> |
additionalHaves
Extra objects the remote has, but which aren't offered as refs.
|
protected java.io.InputStream |
in
Input stream reading from the remote.
|
protected Repository |
local
The repository this transport fetches into, or pushes out of.
|
private InterruptTimer |
myTimer
Timer to manage
timeoutIn and timeoutOut . |
protected java.io.OutputStream |
out
Output stream sending to the remote.
|
protected boolean |
outNeedsEnd
Send
PacketLineOut.end() before closing out ? |
protected PacketLineIn |
pckIn
Packet line decoder around
in . |
protected PacketLineOut |
pckOut
Packet line encoder around
out . |
private java.util.Set<java.lang.String> |
remoteCapablities
Capability tokens advertised by the remote side.
|
protected boolean |
statelessRPC
True if this is a stateless RPC connection.
|
protected TimeoutInputStream |
timeoutIn
Low-level input stream, if a timeout was configured.
|
protected TimeoutOutputStream |
timeoutOut
Low-level output stream, if a timeout was configured.
|
protected Transport |
transport
A transport connected to
uri . |
protected URIish |
uri
Remote repository location.
|
Constructor and Description |
---|
BasePackConnection(PackTransport packTransport) |
Modifier and Type | Method and Description |
---|---|
protected void |
addUserAgentCapability(java.lang.StringBuilder b)
Add user agent capability
|
void |
close() |
private PackProtocolException |
duplicateAdvertisement(java.lang.String name) |
protected void |
endOut()
Tell the peer we are disconnecting, if it cares to know.
|
java.lang.String |
getPeerUserAgent()
User agent advertised by the remote server.
|
protected void |
init(java.io.InputStream myIn,
java.io.OutputStream myOut)
Configure this connection with the directional pipes.
|
private PackProtocolException |
invalidRefAdvertisementLine(java.lang.String line) |
protected boolean |
isCapableOf(java.lang.String option)
Whether this option is supported
|
protected TransportException |
noRepository()
Create an exception to indicate problems finding a remote repository.
|
protected void |
readAdvertisedRefs()
Reads the advertised references through the initialized stream.
|
private void |
readAdvertisedRefsImpl() |
protected boolean |
wantCapability(java.lang.StringBuilder b,
java.lang.String option)
Request capability
|
available, getMessages, getMessageWriter, getRef, getRefs, getRefsMap, markStartedOperation, setMessageWriter, setPeerUserAgent
protected final Repository local
protected final URIish uri
protected TimeoutInputStream timeoutIn
protected TimeoutOutputStream timeoutOut
private InterruptTimer myTimer
timeoutIn
and timeoutOut
.protected java.io.InputStream in
protected java.io.OutputStream out
protected PacketLineIn pckIn
in
.protected PacketLineOut pckOut
out
.protected boolean outNeedsEnd
PacketLineOut.end()
before closing out
?protected boolean statelessRPC
private final java.util.Set<java.lang.String> remoteCapablities
protected final java.util.Set<ObjectId> additionalHaves
BasePackConnection(PackTransport packTransport)
protected final void init(java.io.InputStream myIn, java.io.OutputStream myOut)
myIn
- input stream to receive data from the peer. Caller must ensure
the input is buffered, otherwise read performance may suffer.myOut
- output stream to transmit data to the peer. Caller must ensure
the output is buffered, otherwise write performance may
suffer.protected void readAdvertisedRefs() throws TransportException
Subclass implementations may call this method only after setting up the
input and output streams with init(InputStream, OutputStream)
.
If any errors occur, this connection is automatically closed by invoking
close()
and the exception is wrapped (if necessary) and thrown
as a TransportException
.
TransportException
- the reference list could not be scanned.private void readAdvertisedRefsImpl() throws java.io.IOException
java.io.IOException
protected TransportException noRepository()
protected boolean isCapableOf(java.lang.String option)
option
- option stringprotected boolean wantCapability(java.lang.StringBuilder b, java.lang.String option)
b
- bufferoption
- option we wanttrue
if the requested option is supportedprotected void addUserAgentCapability(java.lang.StringBuilder b)
b
- a StringBuilder
object.public java.lang.String getPeerUserAgent()
getPeerUserAgent
in interface Connection
getPeerUserAgent
in class BaseConnection
private PackProtocolException duplicateAdvertisement(java.lang.String name)
private PackProtocolException invalidRefAdvertisementLine(java.lang.String line)
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
protected void endOut()