directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1486411 - /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java
Date Sun, 26 May 2013 12:05:27 GMT
Author: elecharny
Date: Sun May 26 12:05:27 2013
New Revision: 1486411

URL: http://svn.apache.org/r1486411
Log:
Added some synchronization between the thread that initialize the replica store and the init
method. We should now not be able to sstore any modification before the store is ready (which
may fix the DIRSERVER-1810 issue, hopefully)

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=1486411&r1=1486410&r2=1486411&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
Sun May 26 12:05:27 2013
@@ -34,6 +34,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -220,10 +221,23 @@ public class SyncReplRequestHandler impl
 
             dirService.getEventService().addListener( cledListener, criteria );
 
-            Thread consumerInfoUpdateThread = new Thread( createConsumerInfoUpdateTask()
);
+            CountDownLatch latch = new CountDownLatch( 1 );
+
+            Thread consumerInfoUpdateThread = new Thread( createConsumerInfoUpdateTask( latch
) );
             consumerInfoUpdateThread.setDaemon( true );
             consumerInfoUpdateThread.start();
 
+            // Wait for the thread to be ready. We wait 5 minutes, it should be way more
+            // than necessary
+            boolean threadInitDone = latch.await( 5, TimeUnit.MINUTES );
+
+            if ( !threadInitDone )
+            {
+                // We have had a time out : just get out
+                PROVIDER_LOG.error( "The consumer replica thread has not been initialized
in time" );
+                throw new RuntimeException( "Cannot initialize the Provider replica listener"
);
+            }
+
             initialized = true;
             LOG.info( "syncrepl provider initialized successfully" );
             PROVIDER_LOG.debug( "syncrepl provider initialized successfully" );
@@ -1068,7 +1082,7 @@ public class SyncReplRequestHandler impl
     /**
      * Create a thread to process replication communication with a consumer
      */
-    private Runnable createConsumerInfoUpdateTask()
+    private Runnable createConsumerInfoUpdateTask( final CountDownLatch latch )
     {
         Runnable task = new Runnable()
         {
@@ -1080,6 +1094,7 @@ public class SyncReplRequestHandler impl
 
                     try
                     {
+                        latch.countDown();
                         Thread.sleep( 10000 );
                     }
                     catch ( InterruptedException e )



Mime
View raw message