Class ChannelPipedInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.Channel, ChannelPipedSink

    public class ChannelPipedInputStream
    extends java.io.InputStream
    implements ChannelPipedSink
    TODO Add javadoc
    • Field Summary

      Fields 
      Modifier and Type Field 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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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)  
      • Methods inherited from class java.io.InputStream

        mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • localWindow

        private final Window localWindow
      • buffer

        private final Buffer buffer
      • b

        private final byte[] b
      • open

        private final java.util.concurrent.atomic.AtomicBoolean open
      • eofSent

        private final java.util.concurrent.atomic.AtomicBoolean eofSent
      • lock

        private final java.util.concurrent.locks.Lock lock
      • dataAvailable

        private final java.util.concurrent.locks.Condition dataAvailable
      • writerClosed

        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.
      • timeout

        private long timeout
    • Constructor Detail

      • ChannelPipedInputStream

        public ChannelPipedInputStream​(Window localWindow,
                                       java.time.Duration windowTimeout)
      • ChannelPipedInputStream

        public ChannelPipedInputStream​(Window localWindow,
                                       long windowTimeout)
    • Method Detail

      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface java.nio.channels.Channel
      • setTimeout

        public void setTimeout​(long timeout)
      • getTimeout

        public long getTimeout()
      • available

        public int available()
                      throws java.io.IOException
        Overrides:
        available in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.nio.channels.Channel
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException
      • receive

        public void receive​(byte[] bytes,
                            int off,
                            int len)
                     throws java.io.IOException
        Specified by:
        receive in interface ChannelPipedSink
        Parameters:
        bytes - Bytes to be sent to the sink
        off - Offset in buffer
        len - Number of bytes
        Throws:
        java.io.IOException - If failed to send the data