public class ChannelPipedInputStream extends java.io.InputStream implements ChannelPipedSink
Modifier and Type | Field and Description |
---|---|
private byte[] |
b |
private Buffer |
buffer |
private java.util.concurrent.locks.Condition |
dataAvailable |
private java.util.concurrent.atomic.AtomicBoolean |
eofSent |
private Window |
localWindow |
private java.util.concurrent.locks.Lock |
lock |
private java.util.concurrent.atomic.AtomicBoolean |
open |
private long |
timeout |
private java.util.concurrent.atomic.AtomicBoolean |
writerClosed
ChannelPipedOutputStream is already closed and so we will not receive additional data. |
Constructor and Description |
---|
ChannelPipedInputStream(PropertyResolver resolver,
Window localWindow) |
ChannelPipedInputStream(Window localWindow,
java.time.Duration windowTimeout) |
ChannelPipedInputStream(Window localWindow,
long windowTimeout) |
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close() |
void |
eof()
Signal end of writing to the sink
|
long |
getTimeout() |
boolean |
isOpen() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
void |
receive(byte[] bytes,
int off,
int len) |
void |
setTimeout(long timeout) |
private final Window localWindow
private final Buffer buffer
private final byte[] b
private final java.util.concurrent.atomic.AtomicBoolean open
private final java.util.concurrent.atomic.AtomicBoolean eofSent
private final java.util.concurrent.locks.Lock lock
private final java.util.concurrent.locks.Condition dataAvailable
private final java.util.concurrent.atomic.AtomicBoolean writerClosed
ChannelPipedOutputStream
is already closed and so we will not receive additional data. This is different
from the isOpen()
, which indicates that the reader of this InputStream
will not be reading data
any more.private long timeout
public ChannelPipedInputStream(PropertyResolver resolver, Window localWindow)
public ChannelPipedInputStream(Window localWindow, java.time.Duration windowTimeout)
public ChannelPipedInputStream(Window localWindow, long windowTimeout)
public boolean isOpen()
isOpen
in interface java.nio.channels.Channel
public void setTimeout(long timeout)
public long getTimeout()
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public void eof()
ChannelPipedSink
eof
in interface ChannelPipedSink
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface java.nio.channels.Channel
close
in class java.io.InputStream
java.io.IOException
public void receive(byte[] bytes, int off, int len) throws java.io.IOException
receive
in interface ChannelPipedSink
bytes
- Bytes to be sent to the sinkoff
- Offset in bufferlen
- Number of bytesjava.io.IOException
- If failed to send the data