You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2015/07/13 09:25:57 UTC

svn commit: r1690575 - /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java

Author: kayyagari
Date: Mon Jul 13 07:25:57 2015
New Revision: 1690575

URL: http://svn.apache.org/r1690575
Log:
interrupt the sleeping thread to prevent delay at the time of server shutdown (DIRSERVER-2081)

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java?rev=1690575&r1=1690574&r2=1690575&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java Mon Jul 13 07:25:57 2015
@@ -151,6 +151,8 @@ public class SyncReplRequestHandler impl
 
     private AttributeType REPL_LOG_PURGE_THRESHOLD_COUNT_AT;
 
+    /** thread used for updating consumer infor */
+    private Thread consumerInfoUpdateThread;
 
     /**
      * Create a SyncReplRequestHandler empty instance
@@ -222,7 +224,7 @@ public class SyncReplRequestHandler impl
 
             CountDownLatch latch = new CountDownLatch( 1 );
 
-            Thread consumerInfoUpdateThread = new Thread( createConsumerInfoUpdateTask( latch ) );
+            consumerInfoUpdateThread = new Thread( createConsumerInfoUpdateTask( latch ) );
             consumerInfoUpdateThread.setDaemon( true );
             consumerInfoUpdateThread.start();
 
@@ -261,6 +263,9 @@ public class SyncReplRequestHandler impl
         //then interrupt the janitor
         logJanitor.interrupt();
 
+        //then stop the consumerInfoUpdateThread
+        consumerInfoUpdateThread.interrupt();
+        
         for ( ReplicaEventLog log : replicaLogMap.values() )
         {
             try
@@ -275,6 +280,9 @@ public class SyncReplRequestHandler impl
             }
         }
 
+        // flush the dirty repos
+        storeReplicaInfo();
+
         initialized = false;
     }
 
@@ -1089,19 +1097,20 @@ public class SyncReplRequestHandler impl
         {
             public void run()
             {
-                while ( true )
+                try
                 {
-                    storeReplicaInfo();
-
-                    try
+                    while ( true )
                     {
+                        storeReplicaInfo();
+                        
                         latch.countDown();
                         Thread.sleep( 10000 );
                     }
-                    catch ( InterruptedException e )
-                    {
-                        PROVIDER_LOG.warn( "thread storing the replica information was interrupted", e );
-                    }
+                }
+                catch ( InterruptedException e )
+                {
+                    // log at debug level, this will be interrupted during stop
+                    PROVIDER_LOG.debug( "thread storing the replica information was interrupted", e );
                 }
             }
         };