[jboss-remoting-commits] JBoss Remoting SVN: r3539 - 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
Fri Feb 29 03:23:09 EST 2008


Author: ron.sigal at jboss.com
Date: 2008-02-29 03:23:09 -0500 (Fri, 29 Feb 2008)
New Revision: 3539

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java
Log:
JBREM-703: Added configuration for remaining socket parameters.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java	2008-02-29 08:21:41 UTC (rev 3538)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java	2008-02-29 08:23:09 UTC (rev 3539)
@@ -66,7 +66,7 @@
 
    static int clientCount = 0;
 
-   private Properties props = new Properties();
+   protected Properties props = new Properties();
 
    private static int BACKLOG_DEFAULT = 200;
    protected static int MAX_POOL_SIZE_DEFAULT = 300;
@@ -98,6 +98,20 @@
    protected Object serverSocketFactoryLock = new Object();
 
    protected boolean reuseAddress = true;
+   protected int receiveBufferSize = -1;
+   
+   /**
+    * More socket configuration parameters.
+    */
+   protected boolean keepAlive;
+   protected boolean keepAliveSet;
+   protected boolean oOBInline;
+   protected boolean oOBInlineSet;
+   protected int sendBufferSize = -1;
+   protected boolean soLinger;
+   protected boolean soLingerSet;
+   protected int soLingerDuration = -1;
+   protected int trafficClass = -1;
 
    // defaults to -1 as to not have idle timeouts
    protected int idleTimeout = -1;
@@ -270,10 +284,12 @@
             log.warn("Unable to create unbound ServerSocket: cannot set reuseAddress to true",e);
  
          ss = factory.createServerSocket(serverBindPort, backlog, bindAddress);
+         configureServerSocket(ss);
          return ss;
       }
       
       ss.setReuseAddress(getReuseAddress());
+      configureServerSocket(ss);
       InetSocketAddress address = new InetSocketAddress(bindAddress, serverBindPort);
       ss.bind(address, backlog);
       return ss;
@@ -294,6 +310,7 @@
          {
             ss = factory.createServerSocket();
             ss.setReuseAddress(getReuseAddress());
+            configureServerSocket(ss);
             InetSocketAddress address = new InetSocketAddress(inetAddress, home.port);
             ss.bind(address, backlog);
             if (log.isDebugEnabled()) log.debug(this + " created " + ss);
@@ -306,6 +323,7 @@
             try
             {
                ss = factory.createServerSocket(home.port, backlog, inetAddress);
+               configureServerSocket(ss);
             }
             catch (IOException e2)
             {
@@ -326,6 +344,14 @@
          serverSockets.add(ss);
       }
    }
+   
+   protected void configureServerSocket(ServerSocket ss) throws SocketException
+   {
+      if (receiveBufferSize != -1)
+      {
+         ss.setReceiveBufferSize(receiveBufferSize);
+      }
+   }
 
    protected String getThreadName(int i)
    {
@@ -416,6 +442,17 @@
       log.debug(this + " exiting");
    }
 
+
+   public int getReceiveBufferSize()
+   {
+      return receiveBufferSize;
+   }
+
+   public void setReceiveBufferSize(int receiveBufferSize)
+   {
+      this.receiveBufferSize = receiveBufferSize;
+   }
+   
    /**
     * Indicates if SO_REUSEADDR is enabled on server sockets
     * Default is true.
@@ -436,6 +473,69 @@
       this.reuseAddress = reuse;
    }
 
+   public boolean isKeepAlive()
+   {
+      return keepAlive;
+   }
+
+   public void setKeepAlive(boolean keepAlive)
+   {
+      this.keepAlive = keepAlive;
+      keepAliveSet = true;
+   }
+
+   public boolean isOOBInline()
+   {
+      return oOBInline;
+   }
+
+   public void setOOBInline(boolean inline)
+   {
+      oOBInline = inline;
+      oOBInlineSet = true;
+   }
+
+   public int getSendBufferSize()
+   {
+      return sendBufferSize;
+   }
+
+   public void setSendBufferSize(int sendBufferSize)
+   {
+      this.sendBufferSize = sendBufferSize;
+   }
+
+   public boolean isSoLinger()
+   {
+      return soLinger;
+   }
+   
+   public int getSoLingerDuration()
+   {
+      return soLingerDuration;
+   }
+
+   public void setSoLinger(boolean soLinger)
+   {
+      this.soLinger = soLinger;
+      soLingerSet = true;
+   }
+
+   public void setSoLingerDuration(int soLingerDuration)
+   {
+      this.soLingerDuration = soLingerDuration;
+   }
+
+   public int getTrafficClass()
+   {
+      return trafficClass;
+   }
+
+   public void setTrafficClass(int trafficClass)
+   {
+      this.trafficClass = trafficClass;
+   }
+   
    /**
     * @return Value of property serverBindPort.
     * @jmx:managed-attribute
@@ -560,7 +660,19 @@
       }
    }
 
-
+   protected void configureSocket(Socket s) throws SocketException
+   {
+      s.setReuseAddress(getReuseAddress());
+      
+      if (keepAliveSet)           s.setKeepAlive(keepAlive);
+      if (oOBInlineSet)           s.setOOBInline(oOBInline);
+      if (receiveBufferSize > -1) s.setReceiveBufferSize(receiveBufferSize);
+      if (sendBufferSize > -1)    s.setSendBufferSize(sendBufferSize);
+      if (soLingerSet && 
+            soLingerDuration > 0) s.setSoLinger(soLinger, soLingerDuration);
+      if (trafficClass > -1)      s.setTrafficClass(trafficClass);
+   }
+   
    /**
     * The acceptor thread should spend as little time as possbile doing any kind of operation, and
     * under no circumstances should perform IO on the new socket, which can potentially block and
@@ -872,6 +984,7 @@
                // should grab a worker thread and delegate all subsequent work to it. This is what
                // processInvocation() does.
 
+               configureSocket(socket);
                processInvocation(socket);
             }
             catch (SSLException e)




More information about the jboss-remoting-commits mailing list