[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/multiplex ...
Ron Sigal
ron_sigal at yahoo.com
Sat Jul 22 18:00:42 EDT 2006
User: rsigal
Date: 06/07/22 18:00:41
Modified: src/main/org/jboss/remoting/transport/multiplex
MultiplexClientInvoker.java
Log:
JBREM-534: If createSocket() discovers that the connection to the server has failed, it will try to recreate the priming socket, in case the server has been restarted. If there is a virtual MultiplexServerInvoker in the same virtual socket group, it will restart its VirtualServerSocket, although it will pick a new anonymous port to bind it too, to avoid getting a bind exception.
Revision Changes Path
1.39 +59 -1 JBossRemoting/src/main/org/jboss/remoting/transport/multiplex/MultiplexClientInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MultiplexClientInvoker.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/multiplex/MultiplexClientInvoker.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- MultiplexClientInvoker.java 19 Jul 2006 23:22:28 -0000 1.38
+++ MultiplexClientInvoker.java 22 Jul 2006 22:00:41 -0000 1.39
@@ -411,7 +411,7 @@
try
{
// When the remote virtual MultiplexServerInvoker learns that the
- // priming socket has closed, it will class its VirtualServerSocket,
+ // priming socket has closed, it will close its VirtualServerSocket,
// rendering unshareable the MultiplexingManager that underlies this
// socket group. We mark it as unshareable immediately so that it will
// not be reused by any other socket group.
@@ -479,6 +479,64 @@
protected Socket createSocket(String address, int port) throws IOException
{
log.debug("MultiplexClientInvoker.createSocket()");
+
+ // If connection has been broken, try to connect to new server.
+ if (socketGroupInfo != null && socketGroupInfo.getPrimingSocket() != null)
+ {
+ VirtualSocket primingSocket = socketGroupInfo.getPrimingSocket();
+ if (!primingSocket.isFunctional() || primingSocket.hasReceivedDisconnectMessage())
+ {
+ log.info("Current server is inaccessible. Will try to connect to new server");
+ primingSocket.close();
+
+ // Get new priming socket.
+ if (bindSocketAddress != null)
+ {
+ InetAddress bindAddress = bindSocketAddress.getAddress();
+ int bindPort = PortUtil.findFreePort(bindSocketAddress.getHostName());
+ System.out.println("new bindPort: " + bindPort);
+ bindSocketAddress = new InetSocketAddress(bindAddress, bindPort);
+ MultiplexServerInvoker.createPrimingSocket(socketGroupInfo,
+ connectHost, connectPort,
+ bindAddress, bindPort,
+ configuration, timeout);
+ }
+ else
+ MultiplexServerInvoker.createPrimingSocket(socketGroupInfo,
+ connectHost, connectPort,
+ configuration, port);
+
+ // Create new server socket for callback server invoker, if it exists.
+ MultiplexServerInvoker serverInvoker = socketGroupInfo.getServerInvoker();
+ if (serverInvoker != null)
+ {
+ serverInvoker.setBindPort(bindSocketAddress.getPort());
+ System.out.println("*******calling refreshServerSocket()");
+ serverInvoker.refreshServerSocket();
+ }
+
+ VirtualSocket socket = new VirtualSocket(configuration);
+ for (int i = 0; i < 3; i++)
+ {
+ try
+ {
+ socket.connect(connectSocketAddress, bindSocketAddress, timeout);
+ return socket;
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ Thread.sleep(500);
+ }
+ catch (InterruptedException e1)
+ {
+ }
+ }
+ }
+ }
+ }
+
VirtualSocket socket = new VirtualSocket(configuration);
socket.connect(connectSocketAddress, bindSocketAddress, timeout);
return socket;
More information about the jboss-cvs-commits
mailing list