at.borkowski.spicej.streams

Class DelayedInputStream

    • Constructor Detail

      • DelayedInputStream

        public DelayedInputStream(TickSource t,                          InputStream real,                          long delay,                          int bufferSize)
        Constructs a new DelayedInputStream with the given parameters.
        Parameters:
        t - the tick source to use
        real - the underlying InputStream to read data from
        delay - the delay (real ticks) to introduce to data
        bufferSize - the buffer size to use. The implementation has to store read bytes real an intermediate buffer. The buffer must be large enough to store the data. Note that data which cannot be stored into the buffer because of its overflow will have a higher delay, which is why the buffer should be significantly higher than the expected data arrivel rate (times the expected interval of reading from this stream).
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface Runnable
      • tick

        public void tick(long tick)
        Description copied from interface: TickListener
        Called when a tick event is fired. The tick sequence is given in the parameter and can be any numer - however, it is guaranteed that the number increases by one between two ticks. Integer overflows are handled naturally, ie. the tick Long.MAX_VALUE is followed by Long.MIN_VALUE. Furthermore, it is guaranteed that ticks do not overlap each other, ie. no two threads will enter the same object's TickListener.tick(long) at the same time.
        Specified by:
        tick in interface TickListener
        Parameters:
        tick - the tick number
      • setDelay

        public void setDelay(long delay)
        Description copied from interface: DelayShaper
        Sets a new delay in ticks. Note that bytes already waiting in queue also obey to this new delay, ie. reducing the delay will transmit all bytes waiting in queue which are due to transmission following the new delay.
        Specified by:
        setDelay in interface DelayShaper
        Parameters:
        delay - the new delay in ticks
      • getDelay

        public long getDelay()
        Description copied from interface: DelayShaper
        Returns the current delay in ticks.
        Specified by:
        getDelay in interface DelayShaper
        Returns:
        the current delay in ticks
      • getBufferSize

        public int getBufferSize()
        Returns the buffer size, real bytes
        Returns:
        the buffer size
      • getBaseStream

        public InputStream getBaseStream()
        Returns the underlying InputStream.
        Returns:
        the underlying stream
      • getTickSource

        public TickSource getTickSource()
        Returns the TickSource this stream uses.
        Returns:
        the used tick source
      • setNonBlocking

        public void setNonBlocking(boolean nonBlocking)
        Sets the non-blocking flag.
        Parameters:
        nonBlocking - whether the stream should be in non-blocking mode (see RateLimitInputStream).
      • setEofDetection

        public void setEofDetection(boolean eofDetection)
        Sets whether this DelayedInputStream should employ EOF detection. If this flag is set to true, this stream starts showing non-deterministic behavior (in general), since a new thread is spawned for continuous EOF detection which might or might not wake up before a certain tick to report a new byte. Without EOF detection, EOF is not reported to the caller at all. If this flag is set to false while an EOF detector thread is running, the thread might finish at some undefined point in future, ie. setting this flag to false only prevents new EOF detector threads from spawning.
        Parameters:
        eofDetection - if EOF detection should be employed (impllies non-deterministisc behavior)

Copyright © 2015. All rights reserved.



NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14