public class TransmissionBuffer extends Object implements Buffer
BufferColor
,
BufferFilter
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SEGMENT_SIZE |
static long |
STARTING_SEQUENCE |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the current buffer.
|
static TransmissionBuffer |
create()
Creates a transmission buffer with the default segment and buffer size, using a regular heap allocated buffer.
|
static TransmissionBuffer |
create(int segmentSize,
int segments)
Creates a heap allocated transmission buffer with a specified segment size and segments.
|
static TransmissionBuffer |
createDirect()
Creates a transmission buffer with the default segment and buffer size, using a direct memory buffer.
|
static TransmissionBuffer |
createDirect(int segmentSize,
int segments)
Creates a direct allocated transmission buffer with a custom segment size and segments.
|
void |
dumpSegments(PrintWriter writer) |
List<String> |
dumpSegmentsAsList() |
int |
getBufferSize() |
int |
getHeadPositionBytes() |
long |
getHeadSequence() |
int |
getSegmentSize() |
int |
getTotalSegments() |
boolean |
read(ByteWriteAdapter outputStream,
BufferColor bufferColor)
Reads all the available data of the specified color from the buffer into the provided OutputStream
|
boolean |
read(ByteWriteAdapter outputStream,
BufferColor bufferColor,
BufferFilter callback)
Reads all the available data of the specified color from the buffer into the provided OutputStream
with a provided
BufferFilter . |
boolean |
read(ByteWriteAdapter outputStream,
BufferColor bufferColor,
BufferFilter callback,
long sequence)
Reads all the available data of the specified color from the buffer into the provided OutputStream
with a provided
BufferFilter . |
boolean |
readWait(ByteWriteAdapter outputStream,
BufferColor bufferColor)
Reads from the buffer into the provided OutputStream, waiting indefinitely for data to arrive that is
relavent to the specified
BufferColor |
boolean |
readWait(ByteWriteAdapter outputStream,
BufferColor bufferColor,
BufferFilter callback)
Reads from the buffer into the provided OutputStream, waiting indefinitely for data
of the specified color to become available.
|
boolean |
readWait(TimeUnit unit,
long time,
ByteWriteAdapter outputStream,
BufferColor bufferColor)
Reads from the buffer into the provided OutputStream, waiting up to the specified wait time for data
of the specified color to become available.
|
boolean |
readWait(TimeUnit unit,
long time,
ByteWriteAdapter outputStream,
BufferColor bufferColor,
BufferFilter callback)
Reads from the buffer into the provided OutputStream, waiting indefinitely for data
of the specified color to become available with the provided callback.
|
void |
write(InputStream inputStream,
BufferColor bufferColor)
Writes from the
InputStream into the buffer. |
void |
write(int writeSize,
InputStream inputStream,
BufferColor bufferColor)
Writes from an
InputStream into the buffer using the specified to allocate space
in the buffer. |
public static final long STARTING_SEQUENCE
public static final int DEFAULT_SEGMENT_SIZE
public static TransmissionBuffer create()
public static TransmissionBuffer createDirect()
public static TransmissionBuffer create(int segmentSize, int segments)
segmentSize
- the size of individual segmentssegments
- the total number of segmentspublic static TransmissionBuffer createDirect(int segmentSize, int segments)
segmentSize
- the size of the individual segmentssegments
- the total number of segmentspublic void write(InputStream inputStream, BufferColor bufferColor) throws IOException
InputStream
into the buffer. Space is allocated and the data expected to be written
by checking the InputStream.available()
value.write
in interface Buffer
inputStream
- the input stream to read into the buffer.bufferColor
- the color of the data to be inserted.IOException
public void write(int writeSize, InputStream inputStream, BufferColor bufferColor) throws IOException
InputStream
into the buffer using the specified to allocate space
in the buffer.write
in interface Buffer
writeSize
- the size in bytes to be allocated.inputStream
- the input stream to read into the buffer.bufferColor
- the color of the data to be inserted.IOException
public boolean read(ByteWriteAdapter outputStream, BufferColor bufferColor) throws IOException
read
in interface Buffer
outputStream
- the OutputStream to read into.bufferColor
- the buffer colorIOException
public boolean read(ByteWriteAdapter outputStream, BufferColor bufferColor, BufferFilter callback) throws IOException
BufferFilter
.read
in interface Buffer
outputStream
- the OutputStream to read into.bufferColor
- the buffer colorcallback
- a callback to be used during the read operation.IOException
public boolean read(ByteWriteAdapter outputStream, BufferColor bufferColor, BufferFilter callback, long sequence) throws IOException
BufferFilter
.read
in interface Buffer
outputStream
- the OutputStream to read into.bufferColor
- the buffer color.callback
- a callback to be used during the read operation.sequence
- the sequence number to seek from in the buffer.IOException
public boolean readWait(ByteWriteAdapter outputStream, BufferColor bufferColor) throws InterruptedException, IOException
BufferColor
readWait
in interface Buffer
outputStream
- the OutputStream to read into.bufferColor
- the buffer colorIOException
- an IOException is thrown if there is an inability to read from the buffer or write to
the specified OuputStreamInterruptedException
- thrown if the monitor is interrupted while waiting to receive dta.public boolean readWait(TimeUnit unit, long time, ByteWriteAdapter outputStream, BufferColor bufferColor) throws IOException, InterruptedException
readWait
in interface Buffer
unit
- the unit of time that will be used as the basis for waitingtime
- the amount of time to wait in the specified unitsoutputStream
- the OutputStream to write to.bufferColor
- the buffer colorIOException
- an IOException is thrown if there is an inability to read from the buffer or write to
the specified OuputStreamInterruptedException
- thrown if the monitor is interrupted while waiting to receive dta.public boolean readWait(ByteWriteAdapter outputStream, BufferColor bufferColor, BufferFilter callback) throws IOException, InterruptedException
readWait
in interface Buffer
outputStream
- the OutputStream to write to.bufferColor
- the buffer colorIOException
- an IOException is thrown if there is an inability to read from the buffer or write to
the specified OutputStreamInterruptedException
- thrown if the monitor is interrupted while waiting to receive dta.public boolean readWait(TimeUnit unit, long time, ByteWriteAdapter outputStream, BufferColor bufferColor, BufferFilter callback) throws IOException, InterruptedException
readWait
in interface Buffer
outputStream
- the OutputStream to write to.bufferColor
- the buffer colorIOException
- an IOException is thrown if there is an inability to read from the buffer or write to
the specified OutputStreamInterruptedException
- thrown if the monitor is interrupted while waiting to receive dta.public long getHeadSequence()
getHeadSequence
in interface Buffer
public int getHeadPositionBytes()
getHeadPositionBytes
in interface Buffer
public int getBufferSize()
getBufferSize
in interface Buffer
public int getTotalSegments()
getTotalSegments
in interface Buffer
public int getSegmentSize()
getSegmentSize
in interface Buffer
public void clear()
public void dumpSegments(PrintWriter writer)
Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.