Class TimedWriter


  • public class TimedWriter
    extends java.lang.Object
    Waits until the buffer has been written to the output stream, or until timeout msecs have elapsed, whichever comes first. TODO: make it more generic, so all sorts of timed commands should be executable. Including return values, exceptions and Timeout exception. Also use ReusableThread instead of creating a new threa each time.
    Author:
    Bela Ban
    • Constructor Summary

      Constructors 
      Constructor Description
      TimedWriter()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.net.Socket createSocket​(java.net.InetAddress local, java.net.InetAddress remote, int port, long timeout)
      Tries to create a socket to remote_peer:remote_port.
      static void main​(java.lang.String[] args)  
      void write​(java.io.OutputStream out, byte[] buf, long timeout)
      Writes data to an output stream.
      void write​(java.io.OutputStream out, int i, long timeout)  
      • Methods inherited from class java.lang.Object

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

      • TimedWriter

        public TimedWriter()
    • Method Detail

      • write

        public void write​(java.io.OutputStream out,
                          byte[] buf,
                          long timeout)
                   throws java.lang.Exception,
                          org.jgroups.util.TimedWriter.Timeout,
                          java.lang.InterruptedException
        Writes data to an output stream. If the method does not return within timeout milliseconds, a Timeout exception will be thrown.
        Throws:
        java.lang.Exception
        org.jgroups.util.TimedWriter.Timeout
        java.lang.InterruptedException
      • write

        public void write​(java.io.OutputStream out,
                          int i,
                          long timeout)
                   throws java.lang.Exception,
                          org.jgroups.util.TimedWriter.Timeout,
                          java.lang.InterruptedException
        Throws:
        java.lang.Exception
        org.jgroups.util.TimedWriter.Timeout
        java.lang.InterruptedException
      • createSocket

        public java.net.Socket createSocket​(java.net.InetAddress local,
                                            java.net.InetAddress remote,
                                            int port,
                                            long timeout)
                                     throws java.lang.Exception,
                                            org.jgroups.util.TimedWriter.Timeout,
                                            java.lang.InterruptedException
        Tries to create a socket to remote_peer:remote_port. If not sucessful within timeout milliseconds, throws the Timeout exception. Otherwise, returns the socket or throws an IOException.
        Throws:
        java.lang.Exception
        org.jgroups.util.TimedWriter.Timeout
        java.lang.InterruptedException
      • main

        public static void main​(java.lang.String[] args)