Class DelayOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable
    Direct Known Subclasses:
    WiretapOutputStream

    public class DelayOutputStream
    extends java.io.OutputStream
    OutputStream, der die Daten an einen weiteren OutputStream weitergibt und dabei die Übertragungsrate begrenzt.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean DISABLE_DELAY
      Mit diesem Flag kann das Ausbremsen temporär deaktiviert werden (z.
    • Constructor Summary

      Constructors 
      Constructor Description
      DelayOutputStream​(java.io.OutputStream outputStream, long transmissionDelayNanos, double maxFlowRate)
      Erstellt eine neue Instanz
    • Method Summary

      Modifier and Type Method Description
      void close()  
      protected void enqueue​(byte[] bytes)  
      void write​(byte[] b)  
      void write​(byte[] b, int off, int len)  
      void write​(int b)  
      • Methods inherited from class java.io.OutputStream

        flush, nullOutputStream
      • Methods inherited from class java.lang.Object

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

      • DISABLE_DELAY

        public static volatile boolean DISABLE_DELAY
        Mit diesem Flag kann das Ausbremsen temporär deaktiviert werden (z. B. während des Setup-Vorgang eines Tests)
    • Constructor Detail

      • DelayOutputStream

        public DelayOutputStream​(java.io.OutputStream outputStream,
                                 long transmissionDelayNanos,
                                 double maxFlowRate)
        Erstellt eine neue Instanz
        Parameters:
        outputStream - Gekapselter OutputStream
        transmissionDelayNanos - Feste minimale Verzögerung zwischen Senden und Empfang in Nanosekunden (Ping)
        maxFlowRate - Maximaler Durchsatz in Bytes/Sekunde
    • Method Detail

      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
      • write

        public void write​(int b)
                   throws java.io.IOException
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • enqueue

        protected void enqueue​(byte[] bytes)
                        throws java.io.IOException
        Throws:
        java.io.IOException