[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/multiplex ...
Ron Sigal
ron_sigal at yahoo.com
Sat Jul 22 23:35:01 EDT 2006
User: rsigal
Date: 06/07/22 23:35:01
Modified: src/main/org/jboss/remoting/transport/multiplex
MultiplexServerInvoker.java
Log:
JBREM-534:
1. Made ServerSocketRefresh thread a daemon thread.
2. Catch "Socket is closed" or "Socket closed" SocketExceptions in run() and call stop().
3. Added a toString() method.
4. Added a resetLocator() method to be used by MultiplexClientInvoker.createSocket() when it finds connection is broken and binds virtual socket group to new bind port.
5. Added a refreshServerSocket() method for use by MultiplexClientInvoker.createSocket().
Revision Changes Path
1.53 +72 -2 JBossRemoting/src/main/org/jboss/remoting/transport/multiplex/MultiplexServerInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MultiplexServerInvoker.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/multiplex/MultiplexServerInvoker.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- MultiplexServerInvoker.java 20 Jul 2006 07:24:36 -0000 1.52
+++ MultiplexServerInvoker.java 23 Jul 2006 03:35:01 -0000 1.53
@@ -28,6 +28,7 @@
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.util.Collection;
import java.util.Collections;
@@ -271,6 +272,7 @@
log.trace("Started execution of method run");
}
ServerSocketRefresh thread=new ServerSocketRefresh();
+ thread.setDaemon(true);
thread.start();
while(running)
{
@@ -288,6 +290,24 @@
}
processInvocation(socket);
}
+ catch (SocketException e)
+ {
+ if ("Socket is closed".equals(e.getMessage())
+ || "Socket closed".equals(e.getMessage()))
+ {
+ log.debug("socket is closed: stopping");
+ stop();
+ return;
+ }
+ else if (++errorCount > maxAcceptErrors)
+ {
+ log.error("maximum accept errors exceeded: stopping");
+ stop();
+ return;
+ }
+ else
+ log.debug(e);
+ }
catch (SocketTimeoutException e)
{
if(running)
@@ -363,6 +383,30 @@
}
+ public String toString()
+ {
+ if (isVirtual)
+ {
+ VirtualServerSocket vss = (VirtualServerSocket) serverSocket;
+ if (vss != null)
+ return "MultiplexServerInvoker[virtual:"
+ + vss.getInetAddress() + ":" + vss.getLocalPort()
+ + "->"
+ + vss.getRemoteAddress() + ":" + vss.getRemotePort()
+ + "]";
+ else
+ return "MultiplexServerInvoker[virtual]";
+ }
+ else
+ if (serverSocket != null)
+ return "MultiplexServerInvoker[master:"
+ + serverSocket.getInetAddress() + ":" + serverSocket.getLocalPort()
+ + "]";
+ else
+ return "MultiplexServerInvoker[master]";
+ }
+
+
protected void setup() throws Exception
{
originalBindPort = this.getLocator().getPort();
@@ -433,6 +477,27 @@
}
+
+ /**
+ * Called by MultiplexClientInvoker.createSocket() when it finds connection is
+ * broken and binds virtual socket group to new bind port.
+ * <p>
+ * @param bindPort
+ */
+ protected void resetLocator(int bindPort)
+ {
+ this.bindPort = bindPort;
+ InvokerLocator newLocator = new InvokerLocator(locator.getProtocol(),
+ locator.getHost(),
+ bindPort,
+ locator.getPath(),
+ locator.getParameters());
+
+ InvokerRegistry.updateServerInvokerLocator(locator, newLocator);
+ locator = newLocator;
+ }
+
+
protected void configureSocketGroupParameters(Map parameters) throws IOException
{
log.debug("entering configureSocketGroupParameters()");
@@ -965,6 +1030,11 @@
}
+ protected void refreshServerSocket() throws IOException
+ {
+ super.refreshServerSocket();
+ }
+
/**
* Returns <code>ServerSocket</code> used to accept invocation requests.
* It is added to facilitate unit tests.
More information about the jboss-cvs-commits
mailing list