User: user57  
  Date: 02/02/16 19:34:28

  Modified:    src/main/org/jboss/ha/jndi HAJNDI.java HANamingService.java
  Log:
   o logging changes, still needs work garuding debugs and dropping
     printStackTrace() usage
   o using ServiceMBeanSupport features where it is a subclass, should
     use it as a delegate for those that don't sc it.
  
  Revision  Changes    Path
  1.11      +20 -20    jbossmx/src/main/org/jboss/ha/jndi/HAJNDI.java
  
  Index: HAJNDI.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/jndi/HAJNDI.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- HAJNDI.java       26 Nov 2001 17:11:56 -0000      1.10
  +++ HAJNDI.java       17 Feb 2002 03:34:28 -0000      1.11
  @@ -30,7 +30,7 @@
    *   lookups will look for Names in HAJNDI then delegate to the local InitialContext
    *
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Bill Burke</a>
  - *   @version $Revision: 1.10 $
  + *   @version $Revision: 1.11 $
    *
    * <p><b>Revisions:</b><br>
    */
  @@ -48,7 +48,7 @@
         throws NamingException
      {
         super();
  -      log = org.jboss.logging.Logger.getLogger("HAJNDI");
  +      log = org.jboss.logging.Logger.getLogger(HAJNDI.class);
         this.partition = partition;
      }
      
  @@ -56,9 +56,9 @@
   
      public void init() throws Exception
      {
  -      log.info("subscribeToStateTransferEvents");
  +      log.debug("subscribeToStateTransferEvents");
         partition.subscribeToStateTransferEvents("HAJNDI", this);
  -      log.info("registerRPCHandler");
  +      log.debug("registerRPCHandler");
         partition.registerRPCHandler("HAJNDI", this);
      }
   
  @@ -66,13 +66,13 @@
      
      public Serializable getCurrentState()
      {
  -      log.info("getCurrentState called");
  +      log.debug("getCurrentState called");
         return table;
      }
   
      public void setCurrentState(Serializable newState)
      {
  -      log.info("setCurrentState called");
  +      log.debug("setCurrentState called");
         table.clear();
         table.putAll((java.util.Hashtable)newState);
      }
  @@ -83,13 +83,13 @@
      public synchronized void _bind(Name name, Object obj, String className)
         throws NamingException
      {
  -      log.info("_bind");
  +      log.debug("_bind");
         super.bind(name, obj, className);
      }
      public synchronized void bind(Name name, Object obj, String className)
         throws NamingException
      {
  -      log.info("bind");
  +      log.debug("bind");
         super.bind(name, obj, className);
         // if we get here, this means we can do it on every node.
         Object[] args = new Object[3];
  @@ -108,13 +108,13 @@
      public synchronized void _rebind(Name name, Object obj, String className)
         throws NamingException
      {
  -      log.info("_rebind");
  +      log.debug("_rebind");
         super.rebind(name, obj, className);
      }
      public synchronized void rebind(Name name, Object obj, String className)
         throws NamingException
      {
  -      log.info("rebind");
  +      log.debug("rebind");
         super.rebind(name, obj, className);
         
         // if we get here, this means we can do it on every node.
  @@ -135,13 +135,13 @@
      public synchronized void _unbind(Name name)
         throws NamingException
      {
  -      log.info("_unbind");
  +      log.debug("_unbind");
         super.unbind(name);
      }
      public synchronized void unbind(Name name)
         throws NamingException
      {
  -      log.info("unbind");
  +      log.debug("unbind");
         super.unbind(name);
         
         // if we get here, this means we can do it on every node.
  @@ -160,7 +160,7 @@
      public Object lookup(Name name)
         throws NamingException
      {
  -      log.info("lookup");
  +      log.debug("lookup");
         Object result = null;
         try
         {
  @@ -181,7 +181,7 @@
               ArrayList rsp = null;
               try
               {
  -               log.info("calling lookupLocally");
  +               log.debug("calling lookupLocally");
                  rsp = partition.callMethodOnCluster("HAJNDI", "lookupLocally", args, 
true);
               }
               catch (Exception ignored) {}
  @@ -189,7 +189,7 @@
               for (int i = 0; i < rsp.size(); i++)
               {
                  result = rsp.get(i);
  -               log.info("_lookupLocally returned: " + result.getClass().getName());
  +               log.debug("_lookupLocally returned: " + result.getClass().getName());
                  if (!(result instanceof Exception))
                     return result;
               }
  @@ -201,14 +201,14 @@
   
      public Object _lookupLocally(Name name)
      {
  -      log.info("_lookupLocally");
  +      log.debug("_lookupLocally");
         try
         {
            return lookupLocally(name);
         }
         catch (NamingException ex)
         {
  -         log.info("_lookupLocally returning NameNotFoundException");
  +         log.debug("_lookupLocally returning NameNotFoundException");
            return ex;
         }
         catch (Exception rex)
  @@ -218,7 +218,7 @@
      }
      public Object lookupLocally(Name name) throws NamingException
      {
  -      log.info("lookupLocally");
  +      log.debug("lookupLocally");
         // FIXME: This is a really big hack here
         // We cannot do InitialContext().lookup(name) because
         // we get ClassNotFound errors and ClassLinkage errors.
  @@ -269,7 +269,7 @@
      public Collection list(Name name)
         throws NamingException
      {
  -      log.info("list");
  +      log.debug("list");
         Collection result = null;
         try
         {
  @@ -286,7 +286,7 @@
      public Collection listBindings(Name name)
         throws NamingException
      {
  -      log.info("listBindings");
  +      log.debug("listBindings");
         Collection result = null;
         try
         {
  
  
  
  1.22      +52 -50    jbossmx/src/main/org/jboss/ha/jndi/HANamingService.java
  
  Index: HANamingService.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/jndi/HANamingService.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- HANamingService.java      15 Feb 2002 00:46:51 -0000      1.21
  +++ HANamingService.java      17 Feb 2002 03:34:28 -0000      1.22
  @@ -38,7 +38,7 @@
    *
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Bill Burke</a>
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Sacha Labourey</a>
  - *   @version $Revision: 1.21 $
  + *   @version $Revision: 1.22 $
    *
    * <p><b>Revisions:</b><br>
    * <p><b>2001/11/19 bill burke:</b>
  @@ -48,7 +48,9 @@
    * </ul>
    */
   
  -public class HANamingService extends ServiceMBeanSupport implements Runnable, 
HANamingServiceMBean
  +public class HANamingService
  +   extends ServiceMBeanSupport
  +   implements Runnable, HANamingServiceMBean
   {
      // Constants -----------------------------------------------------
      
  @@ -77,8 +79,7 @@
      /** The RMI port on which the Naming implementation will be exported. The
       default is 0 which means use any available port. */
      protected int rmiPort = 0;
  -   protected org.jboss.logging.Logger log;
  -
  +   
      protected HARMIServerImpl rmiserver;
      protected Naming stub;
      protected HAPartition partition;
  @@ -92,17 +93,13 @@
   
      public HANamingService()
      {
  -      log = org.jboss.logging.Logger.getLogger("HANamingService");
  +      // for JMX
      }
      
  -   public String getName()
  -   {
  -      return "HAJNDI";
  -   }
  -
  -   public ObjectName getObjectName (MBeanServer server, ObjectName name) throws 
MalformedObjectNameException
  +   protected ObjectName getObjectName(MBeanServer server, ObjectName name)
  +      throws MalformedObjectNameException
      {
  -      return OBJECT_NAME;
  +      return name == null ? OBJECT_NAME : name;
      }
      
      public String getPartitionName()
  @@ -110,7 +107,7 @@
         return partitionName;
      }
   
  -   public void setPartitionName(String partitionName)
  +   public void setPartitionName(final String partitionName)
      {
         this.partitionName = partitionName;
      }
  @@ -190,25 +187,23 @@
         this.startService ();
      }
      
  -   public void startService()
  +   protected void startService()
         throws Exception
      {
  -      log.info("Starting HAJNDI server");
  -      log.info("Create HARMIServer proxy");
  +      log.debug("Create HARMIServer proxy");
         this.rmiserver = new HARMIServerImpl(partition, "HAJNDI", Naming.class, 
theServer, rmiPort, this.clientSocketFactory, this.serverSocketFactory);
         this.stub = (Naming)rmiserver.createHAStub(new RoundRobin());
   
  -      log.info("Start listener");
  +      log.debug("Starting listener");
         try
         {
  -         serverSocket = null;
            serverSocket = new ServerSocket(port, backlog, bindAddress);
            // If an anonymous port was specified get the actual port used
            if( port == 0 )
               port = serverSocket.getLocalPort();
  -         String msg = "Started hajndiPort=" + port;
  -         log.info(msg);
            listen();
  +         log.info("Listening on " + serverSocket.getInetAddress() + ":" + 
serverSocket.getLocalPort());
  +
         } catch (IOException e)
         {
            log.error("Could not start on port " + port, e);
  @@ -220,41 +215,41 @@
         autoDiscovery.listen ();
      }
   
  -   public void createService()
  +   protected void createService()
         throws Exception
      {
  -      log.info("Initializing HAJNDI server");
  -      log.info("jndi lookup of " + "/HAPartition/" + partitionName);
  +      boolean debug = log.isDebugEnabled();
  +      
  +      if (debug) {
  +         log.debug("Initializing HAJNDI server");
  +         log.debug("jndi lookup of " + "/HAPartition/" + partitionName);
  +      }
         partition = (HAPartition)new InitialContext().lookup("/HAPartition/" + 
partitionName);
  -      log.info("Create remote object");
  +      log.debug("Create remote object");
         theServer = new HAJNDI(partition);
  -      log.info("initialize HAJNDI");
  +      log.debug("initialize HAJNDI");
         theServer.init();
      }
   
  -   public void stopService() 
  +   protected void stopService() throws Exception
      {
  -      try
  -      {
  -         log.info("HA-JNDI is stopping");
  -         
  -         // Unexport server
  -         log.info("destroy ha rmiserver");
  -         this.rmiserver.destroy ();         
  -         
  -         // Stop listener
  -         ServerSocket s = serverSocket;
  -         serverSocket = null;
  -         log.info("closing socket");
  -         s.close();
  -         log.info("Stopping AutomaticDiscovery");
  -         autoDiscovery.stop();
  -         log.info("Stopped");
  -      } 
  -      catch (Exception e)
  -      {
  -         log.error("Exception during shutdown", e);
  -      }
  +      boolean debug = log.isDebugEnabled();
  +      
  +      // Unexport server
  +      if (debug)
  +         log.debug("destroy ha rmiserver");
  +      this.rmiserver.destroy ();         
  +      
  +      // Stop listener
  +      ServerSocket s = serverSocket;
  +      serverSocket = null;
  +      if (debug)
  +         log.debug("closing socket");
  +      
  +      s.close();
  +      if (debug)
  +         log.debug("Stopping AutomaticDiscovery");
  +      autoDiscovery.stop();
      }
      
      // Runnable implementation ---------------------------------------
  @@ -312,7 +307,7 @@
      
      protected void listen()
      {
  -      Thread t = new Thread(this, "HAJNDI Server");
  +      Thread t = new Thread(this, "HAJNDI-Listener");
         t.start();
      }
      
  @@ -320,8 +315,12 @@
      
      // Inner classes -------------------------------------------------
      
  -   protected class AutomaticDiscovery implements Runnable
  +   protected class AutomaticDiscovery
  +      implements Runnable
      {
  +      protected org.jboss.logging.Logger log =
  +         org.jboss.logging.Logger.getLogger(AutomaticDiscovery.class);
  +      
         protected java.net.MulticastSocket socket = null;
         protected byte[] ipAddress = null;
         protected InetAddress group = null;
  @@ -338,6 +337,9 @@
               ipAddress = (java.net.InetAddress.getLocalHost().getHostAddress() + ":" 
+ port).getBytes();
            else
               ipAddress = (address + ":" + port).getBytes();
  +
  +
  +         log.info("Listening on " + socket.getInterface() + ":" + 
socket.getLocalPort());
         }
         
         public void stop()
  @@ -394,7 +396,7 @@
         
         protected void listen ()
         {
  -         Thread t = new Thread (this, "HAJNDI - AutomaticDiscovery");
  +         Thread t = new Thread (this, "HAJNDI-AutomaticDiscovery");
            t.start ();
         }
      }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to