[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/bisocket ...

Ron Sigal ron_sigal at yahoo.com
Thu Aug 30 13:10:56 EDT 2007


  User: rsigal  
  Date: 07/08/30 13:10:56

  Modified:    src/main/org/jboss/remoting/transport/bisocket  Tag:
                        remoting_2_x BisocketServerInvoker.java
  Log:
  JBREM-761:  Rearranged destroyControlConnection(); JBREM-778:  start() creates a new Timer only when necessary; JBREM-784: Uses new RECREATE_CONTROL_SOCKET and uses new version of BisocketClientInvoker.transferSocket().  Added some logging.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.24  +51 -21    JBossRemoting/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BisocketServerInvoker.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java,v
  retrieving revision 1.1.2.23
  retrieving revision 1.1.2.24
  diff -u -b -r1.1.2.23 -r1.1.2.24
  --- BisocketServerInvoker.java	2 Jun 2007 05:48:38 -0000	1.1.2.23
  +++ BisocketServerInvoker.java	30 Aug 2007 17:10:56 -0000	1.1.2.24
  @@ -58,7 +58,7 @@
   /**
    *
    * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
  - * @version $Revision: 1.1.2.23 $
  + * @version $Revision: 1.1.2.24 $
    * <p>
    * Copyright Nov 23, 2006
    * </p>
  @@ -69,6 +69,7 @@
   
      private static Map listenerIdToServerInvokerMap = Collections.synchronizedMap(new HashMap());
      private static Timer timer;
  +   private static Object timerLock = new Object();
   
      private Map listenerIdToInvokerLocatorMap = Collections.synchronizedMap(new HashMap());
      private ServerSocket secondaryServerSocket;
  @@ -148,9 +149,24 @@
            threadpool = new LinkedList();
            checkSocketFactoryWrapper();
            
  -         timer = new Timer(true);
            controlMonitorTimerTask = new ControlMonitorTimerTask(this);
  +         synchronized (timerLock)
  +         {
  +            if (timer == null)
  +            {
  +               timer = new Timer(true);
  +            }
  +            try
  +            {
            timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
  +            }
  +            catch (IllegalStateException e)
  +            {
  +               log.debug("Unable to schedule TimerTask on existing Timer", e);
  +               timer = new Timer(true);
  +               timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency);
  +            }
  +         }
            
            running = true;
            started = true;
  @@ -263,13 +279,14 @@
         DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
         if (firstConnection)
         {
  -         dos.write(Bisocket.CREATE_ORDINARY_SOCKET);
  +         dos.write(Bisocket.CREATE_CONTROL_SOCKET);
         }
         else
         {
  -         dos.write(Bisocket.CREATE_CONTROL_SOCKET);
  +         dos.write(Bisocket.RECREATE_CONTROL_SOCKET);
         }
         dos.writeUTF(listenerId);
  +      
         Thread thread = new ControlConnectionThread(socket, listenerId);
         thread.setName("control: " + socket.toString());
         thread.setDaemon(true);
  @@ -292,14 +309,12 @@
         }
   
         thread.start();
  -      log.debug("created control connection: " + socket.toString());
  +      log.debug(this + " created control connection (" + listenerId + "): " + socket.toString());
      }
   
   
  -   public void destroyControlConnection(String listenerId) throws IOException
  +   public void destroyControlConnection(String listenerId)
      {
  -      listenerIdToInvokerLocatorMap.remove(listenerId);
  -      controlConnectionRestartsMap.remove(listenerId);
         Thread t = null;
         
         synchronized (controlConnectionThreadMap)
  @@ -310,11 +325,15 @@
         if (t != null)
         {
            ((ControlConnectionThread)t).shutdown();
  +         log.debug(this + " shutting down control connection: " + listenerId);
         }
         else
         {
            log.debug("unrecognized listener ID: " + listenerId);
         }
  +      
  +      listenerIdToInvokerLocatorMap.remove(listenerId);
  +      controlConnectionRestartsMap.remove(listenerId);
      }
      
      
  @@ -389,6 +408,7 @@
               try
               {
                  pingFrequency = Integer.valueOf(((String) o)).intValue();
  +               log.debug(this + " setting pingFrequency to " + pingFrequency);
               }
               catch (NumberFormatException e)
               {
  @@ -406,6 +426,7 @@
               try
               {
                  pingWindowFactor = Integer.valueOf(((String) o)).intValue();
  +               log.debug(this + " setting pingWindowFactor to " + pingWindowFactor);
               }
               catch (NumberFormatException e)
               {
  @@ -715,7 +736,8 @@
                        return;
   
                     default:
  -                     log.error("unrecognized action: " + action);
  +                     log.error("unrecognized action on ControlConnectionThread (" +
  +                               listenerId + "): " +  action);
                        continue;
                  }
               }
  @@ -797,7 +819,7 @@
               try
               {
                  Socket socket = secondaryServerSocket.accept();
  -               log.debug("accepted: " + socket);
  +               if (log.isTraceEnabled()) log.trace("accepted: " + socket);
                  DataInputStream dis = new DataInputStream(socket.getInputStream());
                  int action = dis.read();
                  String listenerId = dis.readUTF();
  @@ -805,27 +827,33 @@
                  switch (action)
                  {
                     case Bisocket.CREATE_CONTROL_SOCKET:
  -                     BisocketClientInvoker invoker;
  -                     invoker =  BisocketClientInvoker.getBisocketCallbackClientInvoker(listenerId);
  +                     BisocketClientInvoker.transferSocket(listenerId, socket, true);
  +                     if (log.isTraceEnabled()) 
  +                        log.trace("SecondaryServerSocketThread: created control socket: (" + socket + ")"+ listenerId);
  +                     break;
  +                     
  +                  case Bisocket.RECREATE_CONTROL_SOCKET:
  +                     BisocketClientInvoker invoker =  BisocketClientInvoker.getBisocketCallbackClientInvoker(listenerId);
                        if (invoker == null)
                        {
  -                        log.debug("SecondaryServerSocketThread: transferring socket: " + listenerId);
  -                        BisocketClientInvoker.transferSocket(listenerId, socket);
  +                        log.error("received new control socket for unrecognized listenerId: " + listenerId);
                        }
                        else
                        {
                           invoker.replaceControlSocket(socket);
  -                        log.debug("SecondaryServerSocketThread: created secondary socket: " + listenerId);
  +                        if (log.isTraceEnabled())
  +                           log.trace("SecondaryServerSocketThread: recreated control socket: " + listenerId);
                        }
                        break;
   
                     case Bisocket.CREATE_ORDINARY_SOCKET:
  -                     BisocketClientInvoker.transferSocket(listenerId, socket);
  -                     log.debug("SecondaryServerSocketThread: transferred socket: " + listenerId);
  +                     BisocketClientInvoker.transferSocket(listenerId, socket, false);
  +                     if (log.isTraceEnabled())
  +                        log.trace("SecondaryServerSocketThread: transferred socket: " + listenerId);
                        break;
   
                     default:
  -                     log.error("unrecognized action: " + action);
  +                     log.error("unrecognized action on SecondaryServerSocketThread: " + action);
                  }
               }
               catch (IOException e)
  @@ -933,7 +961,9 @@
                        continue;
                     }
                     
  -                  log.warn(this + ": detected failure on control connection " + t + ": requesting new control connection");
  +                  log.warn(this + ": detected failure on control connection " + t + 
  +                                  " (" + listenerId + 
  +                                  ": requesting new control connection");
                  }
                  
                  Thread t2 = new Thread()
  
  
  



More information about the jboss-cvs-commits mailing list