public abstract class BasePackPushConnection extends BasePackConnection implements PushConnection
This is the canonical implementation for transferring objects to the remote repository from the local repository by talking to the 'git-receive-pack' service. Objects are packed on the local side into a pack file and then sent to the remote repository.
This connection requires only a bi-directional pipe or socket, and thus is easily wrapped up into a local process pipe, anonymous TCP socket, or a command executed through an SSH tunnel.
This implementation honors
Transport.isPushThin()
option.
Concrete implementations should just call
BasePackConnection.init(java.io.InputStream, java.io.OutputStream)
and
BasePackConnection.readAdvertisedRefs()
methods in constructor or before any use. They
should also handle resources releasing in BasePackConnection.close()
method if needed.
Modifier and Type | Class and Description |
---|---|
private static class |
BasePackPushConnection.CheckingSideBandOutputStream |
Modifier and Type | Field and Description |
---|---|
private boolean |
atomic |
static java.lang.String |
CAPABILITY_DELETE_REFS
The server supports deleting refs.
|
static java.lang.String |
CAPABILITY_OFS_DELTA
The server supports packs with OFS deltas.
|
static java.lang.String |
CAPABILITY_PUSH_OPTIONS
The server supports the receiving of push options.
|
static java.lang.String |
CAPABILITY_REPORT_STATUS
The client expects a status report after the server processes the pack.
|
static java.lang.String |
CAPABILITY_SIDE_BAND_64K
The client supports using the 64K side-band for progress messages.
|
private boolean |
capableAtomic |
private boolean |
capableDeleteRefs |
private boolean |
capableOfsDelta |
private boolean |
capablePushOptions |
private boolean |
capableReport |
private boolean |
capableSideBand |
private long |
packTransferTime
Time in milliseconds spent transferring the pack data.
|
private java.util.List<java.lang.String> |
pushOptions
A list of option strings associated with this push.
|
private boolean |
sentCommand |
private boolean |
thinPack |
private boolean |
writePack |
additionalHaves, in, local, out, outNeedsEnd, pckIn, pckOut, statelessRPC, timeoutIn, timeoutOut, transport, uri
Constructor and Description |
---|
BasePackPushConnection(PackTransport packTransport)
Create a new connection to push using the native git transport.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doPush(ProgressMonitor monitor,
java.util.Map<java.lang.String,RemoteRefUpdate> refUpdates,
java.io.OutputStream outputStream)
Push one or more objects and update the remote repository.
|
private java.lang.String |
enableCapabilities(ProgressMonitor monitor,
java.io.OutputStream outputStream) |
java.util.List<java.lang.String> |
getPushOptions()
Gets the list of option strings associated with this push.
|
protected TransportException |
noRepository()
Create an exception to indicate problems finding a remote repository.
|
void |
push(ProgressMonitor monitor,
java.util.Map<java.lang.String,RemoteRefUpdate> refUpdates)
Pushes to the remote repository basing on provided specification.
|
void |
push(ProgressMonitor monitor,
java.util.Map<java.lang.String,RemoteRefUpdate> refUpdates,
java.io.OutputStream outputStream)
Pushes to the remote repository basing on provided specification.
|
private void |
readStatusReport(java.util.Map<java.lang.String,RemoteRefUpdate> refUpdates) |
private java.lang.String |
readStringLongTimeout() |
private void |
transmitOptions() |
private void |
writeCommands(java.util.Collection<RemoteRefUpdate> refUpdates,
ProgressMonitor monitor,
java.io.OutputStream outputStream) |
private void |
writePack(java.util.Map<java.lang.String,RemoteRefUpdate> refUpdates,
ProgressMonitor monitor) |
addUserAgentCapability, close, endOut, getPeerUserAgent, init, isCapableOf, readAdvertisedRefs, wantCapability
available, getMessages, getMessageWriter, getRef, getRefs, getRefsMap, markStartedOperation, setMessageWriter, setPeerUserAgent
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, getMessages, getPeerUserAgent, getRef, getRefs, getRefsMap
public static final java.lang.String CAPABILITY_REPORT_STATUS
public static final java.lang.String CAPABILITY_DELETE_REFS
public static final java.lang.String CAPABILITY_OFS_DELTA
public static final java.lang.String CAPABILITY_SIDE_BAND_64K
public static final java.lang.String CAPABILITY_PUSH_OPTIONS
private final boolean thinPack
private final boolean atomic
private java.util.List<java.lang.String> pushOptions
private boolean capableAtomic
private boolean capableDeleteRefs
private boolean capableReport
private boolean capableSideBand
private boolean capableOfsDelta
private boolean capablePushOptions
private boolean sentCommand
private boolean writePack
private long packTransferTime
public BasePackPushConnection(PackTransport packTransport)
packTransport
- the transport.public void push(ProgressMonitor monitor, java.util.Map<java.lang.String,RemoteRefUpdate> refUpdates) throws TransportException
Only one call per connection is allowed. Subsequent calls will result in
TransportException
.
Implementation may use local repository to send a minimum set of objects
needed by remote repository in efficient way.
Transport.isPushThin()
should be
honored if applicable. refUpdates should be filled with information about
status of each update.
push
in interface PushConnection
monitor
- progress monitor to update the end-user about the amount of
work completed, or to indicate cancellation. Implementors
should poll the monitor at regular intervals to look for
cancellation requests from the user.refUpdates
- map of remote refnames to remote refs update
specifications/statuses. Can't be empty. This indicate what
refs caller want to update on remote side. Only refs updates
with
RemoteRefUpdate.Status.NOT_ATTEMPTED
should passed. Implementation must ensure that and appropriate
status with optional message should be set during call. No
refUpdate with
RemoteRefUpdate.Status.AWAITING_REPORT
or
RemoteRefUpdate.Status.NOT_ATTEMPTED
can be leaved by implementation after return from this call.TransportException
- objects could not be copied due to a network failure,
critical protocol error, or error on remote side, or
connection was already used for push - new connection must be
created. Non-critical errors concerning only isolated refs
should be placed in refUpdates.public void push(ProgressMonitor monitor, java.util.Map<java.lang.String,RemoteRefUpdate> refUpdates, java.io.OutputStream outputStream) throws TransportException
Only one call per connection is allowed. Subsequent calls will result in
TransportException
.
Implementation may use local repository to send a minimum set of objects
needed by remote repository in efficient way.
Transport.isPushThin()
should be
honored if applicable. refUpdates should be filled with information about
status of each update.
push
in interface PushConnection
monitor
- progress monitor to update the end-user about the amount of
work completed, or to indicate cancellation. Implementors
should poll the monitor at regular intervals to look for
cancellation requests from the user.refUpdates
- map of remote refnames to remote refs update
specifications/statuses. Can't be empty. This indicate what
refs caller want to update on remote side. Only refs updates
with
RemoteRefUpdate.Status.NOT_ATTEMPTED
should passed. Implementation must ensure that and appropriate
status with optional message should be set during call. No
refUpdate with
RemoteRefUpdate.Status.AWAITING_REPORT
or
RemoteRefUpdate.Status.NOT_ATTEMPTED
can be leaved by implementation after return from this call.outputStream
- output stream to write sideband messages toTransportException
- objects could not be copied due to a network failure,
critical protocol error, or error on remote side, or
connection was already used for push - new connection must be
created. Non-critical errors concerning only isolated refs
should be placed in refUpdates.protected TransportException noRepository()
noRepository
in class BasePackConnection
protected void doPush(ProgressMonitor monitor, java.util.Map<java.lang.String,RemoteRefUpdate> refUpdates, java.io.OutputStream outputStream) throws TransportException
monitor
- progress monitor to receive status updates.refUpdates
- update commands to be applied to the remote repository.outputStream
- output stream to write sideband messages toTransportException
- if any exception occurs.private void writeCommands(java.util.Collection<RemoteRefUpdate> refUpdates, ProgressMonitor monitor, java.io.OutputStream outputStream) throws java.io.IOException
java.io.IOException
private void transmitOptions() throws java.io.IOException
java.io.IOException
private java.lang.String enableCapabilities(ProgressMonitor monitor, java.io.OutputStream outputStream)
private void writePack(java.util.Map<java.lang.String,RemoteRefUpdate> refUpdates, ProgressMonitor monitor) throws java.io.IOException
java.io.IOException
private void readStatusReport(java.util.Map<java.lang.String,RemoteRefUpdate> refUpdates) throws java.io.IOException
java.io.IOException
private java.lang.String readStringLongTimeout() throws java.io.IOException
java.io.IOException
public java.util.List<java.lang.String> getPushOptions()