Package org.eclipse.jgit.transport
Class SideBandOutputStream
java.lang.Object
java.io.OutputStream
org.eclipse.jgit.transport.SideBandOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Multiplexes data and progress messages.
This stream is buffered at packet sizes, so the caller doesn't need to wrap it in yet another buffered stream.
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
static final int
Channel used for pack data.static final int
Channel used for error messages.static final int
Channel used for progress messages.private int
Number of bytes inbuffer
that are valid data.(package private) static final int
static final int
Maximum buffer size for a single packet of sideband data.private final OutputStream
static final int
Default buffer size for a small amount of data. -
Constructor Summary
ConstructorsConstructorDescriptionSideBandOutputStream
(int chan, int sz, OutputStream os) Create a new stream to write side band packets. -
Method Summary
Methods inherited from class java.io.OutputStream
close, nullOutputStream, write
-
Field Details
-
CH_DATA
public static final int CH_DATAChannel used for pack data.- See Also:
-
CH_PROGRESS
public static final int CH_PROGRESSChannel used for progress messages.- See Also:
-
CH_ERROR
public static final int CH_ERRORChannel used for error messages.- See Also:
-
SMALL_BUF
public static final int SMALL_BUFDefault buffer size for a small amount of data.- See Also:
-
MAX_BUF
public static final int MAX_BUFMaximum buffer size for a single packet of sideband data.- See Also:
-
HDR_SIZE
static final int HDR_SIZE- See Also:
-
out
-
buffer
private final byte[] buffer -
cnt
private int cnt
-
-
Constructor Details
-
SideBandOutputStream
Create a new stream to write side band packets.- Parameters:
chan
- channel number to prefix all packets with, so the remote side can demultiplex the stream and get back the original data. Must be in the range [1, 255].sz
- maximum size of a data packet within the stream. The remote side needs to agree to the packet size to prevent buffer overflows. Must be in the range [HDR_SIZE + 1, MAX_BUF).os
- stream that the packets are written onto. This stream should be attached to a SideBandInputStream on the remote side.
-
-
Method Details
-
flushBuffer
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
writeBuffer
- Throws:
IOException
-