[jboss-remoting-commits] JBoss Remoting SVN: r5080 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Apr 22 19:56:19 EDT 2009


Author: ron.sigal at jboss.com
Date: 2009-04-22 19:56:19 -0400 (Wed, 22 Apr 2009)
New Revision: 5080

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
Log:
JBREM-1120: Added writeTimeout facility.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java	2009-04-22 23:55:41 UTC (rev 5079)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java	2009-04-22 23:56:19 UTC (rev 5080)
@@ -91,6 +91,9 @@
    /** Key for setting time to wait to get permission to get a connection */
    public static final String CONNECTION_WAIT = "connectionWait";
    
+   /** Key for setting socket write timeout */
+   public static final String WRITE_TIMEOUT = "writeTimeout";
+   
    /**
     * Default value for enable TCP nodelay. Value is false.
     */
@@ -247,6 +250,8 @@
    protected boolean soLingerSet;
    protected int soLingerDuration = -1;
    protected int trafficClass = -1;
+   
+   protected int writeTimeout = -1;
 
    // Constructors ---------------------------------------------------------------------------------
 
@@ -384,6 +389,16 @@
       this.trafficClass = trafficClass;
    }
 
+   public int getWriteTimeout()
+   {
+      return writeTimeout;
+   }
+
+   public void setWriteTimeout(int writeTimeout)
+   {
+      this.writeTimeout = writeTimeout;
+   }
+
    public synchronized void disconnect()
    {
       log.debug(this + " disconnecting ...");
@@ -612,6 +627,22 @@
                      val + " to a boolean value");
          }
       }
+      
+      // look for writeTimeout param
+      val = params.get(WRITE_TIMEOUT);
+      if (val != null)
+      {
+         try
+         {
+            writeTimeout = Integer.valueOf((String)val).intValue();
+            log.debug(this + " setting writeTimeout to " + writeTimeout);
+         }
+         catch (Exception e)
+         {
+            log.warn(this + " could not convert " + WRITE_TIMEOUT + " value of " +
+                     val + " to an int value");
+         }
+      }
    }
 
    protected ServerAddress createServerAddress(InetAddress addr, int port)
@@ -1102,7 +1133,10 @@
          }
          metadata.put(SocketWrapper.MARSHALLER, marshaller);
          metadata.put(SocketWrapper.UNMARSHALLER, unmarshaller);
-
+         if (writeTimeout > 0)
+         {
+            metadata.put(SocketWrapper.WRITE_TIMEOUT, new Integer(writeTimeout));
+         }
          if (timeAllowed > 0)
          {
             timeRemaining = (int) (timeAllowed - (System.currentTimeMillis() - start));




More information about the jboss-remoting-commits mailing list