[jboss-cvs] JBossAS SVN: r105825 - trunk/cluster/src/main/java/org/jboss/ha/jndi.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 8 19:02:28 EDT 2010


Author: bstansberry at jboss.com
Date: 2010-06-08 19:02:28 -0400 (Tue, 08 Jun 2010)
New Revision: 105825

Modified:
   trunk/cluster/src/main/java/org/jboss/ha/jndi/HAJNDI.java
Log:
[JBAS-7947] HAJNDI should not respond to cluster RPC with a NameNotFoundException

Modified: trunk/cluster/src/main/java/org/jboss/ha/jndi/HAJNDI.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/jndi/HAJNDI.java	2010-06-08 22:44:16 UTC (rev 105824)
+++ trunk/cluster/src/main/java/org/jboss/ha/jndi/HAJNDI.java	2010-06-08 23:02:28 UTC (rev 105825)
@@ -64,6 +64,7 @@
    private final DistributedTreeManager distributedTreeManager;
    private final Naming localNamingInstance;
    private boolean missingLocalNamingLogged;
+   private final RemoteLookupHandler rpcHandler;
 
    // Constructor --------------------------------------------------------
   
@@ -87,6 +88,7 @@
       this.partition = partition;
       this.distributedTreeManager = distributedTreeManager;
       this.localNamingInstance = localNamingInstance;
+      this.rpcHandler = new RemoteLookupHandler();
    }
    
    // Public --------------------------------------------------------
@@ -94,26 +96,81 @@
    public void init()
    {
       log.debug("HAJNDI registering RPC Handler with HAPartition");
-      this.partition.registerRPCHandler("HAJNDI", this);
+      this.partition.registerRPCHandler("HAJNDI", this.rpcHandler);
       this.distributedTreeManager.init();
    }
 
    public void shutdown()
    {
       log.debug("HAJNDI unregistering RPCHandler with HAPartition");
-      this.partition.unregisterRPCHandler("HAJNDI", this);
+      this.partition.unregisterRPCHandler("HAJNDI", this.rpcHandler);
       this.distributedTreeManager.shutdown();
    }
 
+   // Naming implementation -----------------------------------------
+   
+
+   public synchronized void bind(Name name, Object obj, String className) throws NamingException
+   {
+      this.distributedTreeManager.bind(name, obj, className);
+   }
+
+   public synchronized void rebind(Name name, Object obj, String className) throws NamingException
+   {
+      this.distributedTreeManager.rebind(name, obj, className);
+   }
+
+   public synchronized void unbind(Name name) throws NamingException
+   {
+      this.distributedTreeManager.unbind(name);
+   }
+
+   public Object lookup(Name name) throws NamingException
+   {
+      Object binding = this.distributedTreeManager.lookup(name);
+      if (binding == null)
+      {
+         try
+         {
+            binding = lookupLocally(name);
+         }
+         catch (NameNotFoundException nne)
+         {
+            binding = lookupRemotely(name);
+            if (binding == null)
+            {
+               throw nne;
+            }
+         }
+      }
+      return binding;
+   }
+
+   public Collection<NameClassPair> list(Name name) throws NamingException
+   {
+      return this.distributedTreeManager.list(name) ;
+   }
+    
+   public Collection<Binding> listBindings(Name name) throws NamingException
+   {
+      return this.distributedTreeManager.listBindings(name);
+   }
+   
+   public javax.naming.Context createSubcontext(Name name) throws NamingException
+   {
+      return this.distributedTreeManager.createSubcontext(name);
+   }
+   
+   // ----------------------------------------------------------------  Private
+
    /**
-    * Performs a lookup against the local Naming service. This method is only
-    * public so HAPartition can invoke on it via reflection.
+    * Performs a lookup against the local Naming service.
     * 
     * @param name the name
     * @return     the object bound locally under name
     * @throws NamingException
     */
-   public Object lookupLocally(Name name) throws NamingException
+   private Object lookupLocally(Name name) throws NamingException
    {
       boolean trace = log.isTraceEnabled();
       if (trace)
@@ -173,63 +230,7 @@
          throw e;
       }
    }
-
-   // Naming implementation -----------------------------------------
    
-
-   public synchronized void bind(Name name, Object obj, String className) throws NamingException
-   {
-      this.distributedTreeManager.bind(name, obj, className);
-   }
-
-   public synchronized void rebind(Name name, Object obj, String className) throws NamingException
-   {
-      this.distributedTreeManager.rebind(name, obj, className);
-   }
-
-   public synchronized void unbind(Name name) throws NamingException
-   {
-      this.distributedTreeManager.unbind(name);
-   }
-
-   public Object lookup(Name name) throws NamingException
-   {
-      Object binding = this.distributedTreeManager.lookup(name);
-      if (binding == null)
-      {
-         try
-         {
-            binding = lookupLocally(name);
-         }
-         catch (NameNotFoundException nne)
-         {
-            binding = lookupRemotely(name);
-            if (binding == null)
-            {
-               throw nne;
-            }
-         }
-      }
-      return binding;
-   }
-
-   public Collection<NameClassPair> list(Name name) throws NamingException
-   {
-      return this.distributedTreeManager.list(name) ;
-   }
-    
-   public Collection<Binding> listBindings(Name name) throws NamingException
-   {
-      return this.distributedTreeManager.listBindings(name);
-   }
-   
-   public javax.naming.Context createSubcontext(Name name) throws NamingException
-   {
-      return this.distributedTreeManager.createSubcontext(name);
-   }
-   
-   // ----------------------------------------------------------------  Private
-   
    private Object lookupRemotely(Name name) throws NameNotFoundException
    {
       boolean trace = log.isTraceEnabled();
@@ -245,7 +246,7 @@
          {
             log.trace("calling lookupLocally(" + name + ") on HAJNDI cluster");
          }
-         rsp = this.partition.callMethodOnCluster("HAJNDI", "lookupLocally", args, new Class[] { Name.class }, true, new LookupSucceededFilter());
+         rsp = this.partition.callMethodOnCluster("HAJNDI", "remoteLookup", args, new Class[] { Name.class }, Object.class, true, new LookupSucceededFilter(), this.partition.getMethodCallTimeout(), false);
       }
       catch (Exception ignored)
       {
@@ -304,4 +305,37 @@
       }
       return false;
    }
+   
+   /**
+    * Exposes the group RPC interface of the parent class.
+    */
+   public class RemoteLookupHandler
+   { 
+      /**
+       * Performs a lookup against the local Naming service. Will not throw a
+       * NamingException, instead returning null. See JBAS-7947.
+       * 
+       * @param name the name
+       * @return     the object bound locally under name, or null if a
+       *             NamingException is caught.
+       */
+      public Object remoteLookup(Name name)
+      {
+         Object result = null;
+         try
+         {
+            result = HAJNDI.this.lookupLocally(name);
+         }
+         catch (NamingException ne)
+         {
+            // JBAS-7947 -- don't propagate this across cluster as the
+            // remote caller is just going to ignore it
+            if (log.isTraceEnabled())
+            {
+               log.trace("Caught NamingException doing a lookup of " + name, ne);
+            }
+         }
+         return result;
+      }
+   }
 }



More information about the jboss-cvs-commits mailing list