directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r109696 - /incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java
Date Fri, 03 Dec 2004 16:40:41 GMT
Author: akarasulu
Date: Fri Dec  3 08:40:40 2004
New Revision: 109696

URL: http://svn.apache.org/viewcvs?view=rev&rev=109696
Log:
Changes ...

 o added shutdown hook to runtime that closes the nexus which in turn closes
   all backing stores - this prevents us from having to register a thread per
   registered context partition
 o added some code to make sure the sync() and close() ops performed their
   repective operation on each backing store even if ones before it throw
   exceptions

Notes ...

 o adding fail fast protection to sync() and close() methods brought some 
   exceptions to our attention that we were not catching on sync() calls
 o this causes a lot of noice on all test cases but does not seem to 
   produce any negative affects - sync ops still seem to work
 o regardless we need to get to the bottom of this
 o these changes fix this issue in JIRA:

      http://nagoya.apache.org/jira/browse/DIREVE-92


Modified:
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java

Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java?view=diff&rev=109696&p1=incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java&r1=109695&p2=incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java&r2=109696
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java	(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java	Fri
Dec  3 08:40:40 2004
@@ -29,6 +29,7 @@
 import org.apache.ldap.common.filter.ExprNode;
 import org.apache.ldap.common.filter.PresenceNode;
 import org.apache.ldap.common.NotImplementedException;
+import org.apache.ldap.common.MultiException;
 import org.apache.ldap.common.exception.LdapNameNotFoundException;
 import org.apache.ldap.common.util.SingletonEnumeration;
 import org.apache.ldap.common.message.LockableAttributeImpl;
@@ -94,8 +95,24 @@
 
         // register will add to the list of namingContexts as well
         register( this.system );
+
+        Runtime.getRuntime().addShutdownHook( new Thread( new Runnable() {
+            public void run()
+            {
+                try
+                {
+                    RootNexus.this.close();
+                }
+                catch ( NamingException e )
+                {
+                    e.printStackTrace();
+                    // @todo again we need to monitor this failure and report
+                    // that it occured on shutdown specifically
+                }
+            }
+        }, "RootNexusShutdownHook" ) );
     }
-    
+
 
     // ------------------------------------------------------------------------
     // BackendNexus Interface Method Implementations
@@ -372,11 +389,35 @@
      */
     public void sync() throws NamingException
     {
+        MultiException error = null;
         Iterator list = this.backends.values().iterator();
         while ( list.hasNext() )
         {
             BackingStore store = ( BackingStore ) list.next();
-            store.sync();
+
+            try
+            {
+                store.sync();
+            }
+            catch ( NamingException e )
+            {
+                e.printStackTrace();
+
+                if ( error == null )
+                {
+                    error = new MultiException( "Grouping many exceptions on root nexus sync()"
);
+                }
+
+                // @todo really need to send this info to a monitor
+                error.addThrowable( e );
+            }
+        }
+
+        if ( error != null )
+        {
+            NamingException total = new NamingException( "Encountered failures "
+                    + "while performing a sync() operation on backing stores" );
+            total.setRootCause( error );
         }
     }
 
@@ -386,15 +427,43 @@
      */
     public void close() throws NamingException
     {
+        MultiException error = null;
         Iterator list = this.backends.values().iterator();
+
+        // make sure this loop is not fail fast so all backing stores can
+        // have an attempt at closing down and synching their cached entries
         while ( list.hasNext() )
         {
             BackingStore store = ( BackingStore ) list.next();
-            store.sync();
-            store.close();
+
+            try
+            {
+                store.sync();
+                store.close();
+            }
+            catch ( NamingException e )
+            {
+                e.printStackTrace();
+
+                if ( error == null )
+                {
+                    error = new MultiException( "Grouping many exceptions on root nexus close()"
);
+                }
+
+                // @todo really need to send this info to a monitor
+                error.addThrowable( e );
+            }
         }
 
         s_singleton = null;
+
+
+        if ( error != null )
+        {
+            NamingException total = new NamingException( "Encountered failures " 
+                    + "while performing a close() operation on backing stores" );
+            total.setRootCause( error );
+        }
     }
 
 

Mime
View raw message