public class MessageInputStream extends java.io.InputStream implements MessageAppender
An InputStream that can access a queue of ByteBuffer payloads, along with expected InputStream blocking behavior.
Modifier and Type | Field and Description |
---|---|
private java.nio.ByteBuffer |
activeBuffer |
private java.util.concurrent.BlockingDeque<java.nio.ByteBuffer> |
buffers |
private java.util.concurrent.atomic.AtomicBoolean |
closed |
private static java.nio.ByteBuffer |
EOF |
private static Logger |
LOG |
private long |
timeoutMs |
Constructor and Description |
---|
MessageInputStream() |
MessageInputStream(int timeoutMs) |
Modifier and Type | Method and Description |
---|---|
void |
appendFrame(java.nio.ByteBuffer framePayload,
boolean fin)
Append the frame payload to the message.
|
void |
close() |
private static boolean |
isTheEofBuffer(java.nio.ByteBuffer buf) |
void |
mark(int readlimit) |
boolean |
markSupported() |
void |
messageComplete()
Notification that message is to be considered complete.
|
int |
read() |
void |
reset() |
private static final Logger LOG
private static final java.nio.ByteBuffer EOF
private final java.util.concurrent.BlockingDeque<java.nio.ByteBuffer> buffers
private java.util.concurrent.atomic.AtomicBoolean closed
private final long timeoutMs
private java.nio.ByteBuffer activeBuffer
public MessageInputStream()
public MessageInputStream(int timeoutMs)
private static boolean isTheEofBuffer(java.nio.ByteBuffer buf)
public void appendFrame(java.nio.ByteBuffer framePayload, boolean fin) throws java.io.IOException
MessageAppender
appendFrame
in interface MessageAppender
framePayload
- the frame payload to append.fin
- flag indicating if this is the last part of the message or not.java.io.IOException
- if unable to append the frame payloadpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
public void mark(int readlimit)
mark
in class java.io.InputStream
public boolean markSupported()
markSupported
in class java.io.InputStream
public void messageComplete()
MessageAppender
Any cleanup or final actions should be taken here.
messageComplete
in interface MessageAppender
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public void reset() throws java.io.IOException
reset
in class java.io.InputStream
java.io.IOException