directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1415868 - in /directory/apacheds/trunk: protocol-ldap/src/main/java/org/apache/directory/server/ldap/ protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ server-integ/src/test/java/org/apache/directory/server...
Date Fri, 30 Nov 2012 21:57:41 GMT
Author: elecharny
Date: Fri Nov 30 21:57:40 2012
New Revision: 1415868

URL: http://svn.apache.org/viewvc?rev=1415868&view=rev
Log:
o Added some more explicit logs for the consumer connection
o Simplified the reconnection code : we now call the start( now ) method instead of having
the (almost) same code in two places
o Logged some trace when the baseDN does not exist, instead of throwing an exception

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumer.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/MockSyncReplConsumer.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java?rev=1415868&r1=1415867&r2=1415868&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
Fri Nov 30 21:57:40 2012
@@ -127,6 +127,9 @@ public class LdapServer extends Director
 
     /** logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( LdapServer.class.getName()
);
+    
+    /** Logger for the replication consumer */
+    private static final Logger CONSUMER_LOG = LoggerFactory.getLogger( "CONSUMER_LOG" );
 
     /** Value (0) for configuration where size limit is unlimited. */
     public static final long NO_SIZE_LIMIT = 0;
@@ -690,13 +693,15 @@ public class LdapServer extends Director
                     {
                         try
                         {
-                            LOG.info( "starting the replication consumer with config {}",
consumer );
+                            LOG.info( "starting the replication consumer with {}", consumer
);
+                            CONSUMER_LOG.info( "starting the replication consumer with {}",
consumer );
                             consumer.init( getDirectoryService() );
-                            consumer.start();
+                            consumer.start( true );
                         }
                         catch ( Exception e )
                         {
-                            LOG.error( "Failed to start the consumer with config {}", consumer
);
+                            LOG.error( "Failed to start consumer {}", consumer );
+                            CONSUMER_LOG.error( "Failed to start consumer  {}", consumer
);
                             throw new RuntimeException( e );
                         }
                     }

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumer.java?rev=1415868&r1=1415867&r2=1415868&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumer.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumer.java
Fri Nov 30 21:57:40 2012
@@ -59,8 +59,10 @@ public interface ReplicationConsumer
 
     /**
      * starts the consumer
+     * 
+     * @param now A param that tells the consumer to connect immediately or not
      */
-    void start();
+    void start( boolean now );
 
 
     /**

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java?rev=1415868&r1=1415867&r2=1415868&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
Fri Nov 30 21:57:40 2012
@@ -66,6 +66,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.entry.Modification;
 import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapNoSuchObjectException;
 import org.apache.directory.shared.ldap.model.filter.AndNode;
 import org.apache.directory.shared.ldap.model.filter.EqualityNode;
 import org.apache.directory.shared.ldap.model.filter.ExprNode;
@@ -102,6 +103,8 @@ public class ReplicationConsumerImpl imp
 {
     /** the logger */
     private static final Logger LOG = LoggerFactory.getLogger( ReplicationConsumerImpl.class
);
+    
+    /** A dedicated logger for the consumer */
     private static final Logger CONSUMER_LOG = LoggerFactory.getLogger( "CONSUMER_LOG" );
 
     /** the syncrepl configuration */
@@ -346,8 +349,18 @@ public class ReplicationConsumerImpl imp
             switch ( state )
             {
                 case ADD:
-
-                    if ( !session.exists( remoteDn ) )
+                    boolean remoteDnExist = false;
+                    
+                    try
+                    {
+                        remoteDnExist = session.exists( remoteDn );
+                    }
+                    catch ( LdapNoSuchObjectException lnsoe )
+                    {
+                        CONSUMER_LOG.error( lnsoe.getMessage() );
+                    }
+                    
+                    if ( !remoteDnExist)
                     {
                         LOG.debug( "adding entry with dn {}", remoteDn );
                         LOG.debug( remoteEntry.toString() );
@@ -481,29 +494,15 @@ public class ReplicationConsumerImpl imp
      */
     public void connectionClosed()
     {
+        String producer = config.getRemoteHost() + ":" + config.getRemotePort();
+        CONSUMER_LOG.debug( "Consumer {} session with {} has been closed ", config.getReplicaId(),
producer );
+        
         if ( disconnected )
         {
             return;
         }
 
-        boolean connected = false;
-
-        while ( !connected )
-        {
-            try
-            {
-                Thread.sleep( config.getRefreshInterval() );
-            }
-            catch ( InterruptedException e )
-            {
-                LOG.error( "Interrupted while sleeping before trying to reconnect", e );
-            }
-
-            LOG.debug( "Trying to reconnect" );
-            connected = connect();
-        }
-
-        startSync();
+        start( false );
     }
 
 
@@ -551,22 +550,38 @@ public class ReplicationConsumerImpl imp
     /**
      * {@inheritDoc}
      */
-    public void start()
+    public void start( boolean now )
     {
-        while ( !connect() )
+        String producer = config.getRemoteHost() + ":" + config.getRemotePort();
+        
+        boolean connected = false;
+
+        if ( now )
+        {
+            connected = connect();
+        }
+        
+        while ( !connected )
         {
             try
             {
+                CONSUMER_LOG.debug( "Consumer {} cannot connect to {}, wait 5 seconds.",
config.getReplicaId(),
+                    producer );
+                
                 // try to establish a connection for every 5 seconds
                 Thread.sleep( 5000 );
             }
             catch ( InterruptedException e )
             {
-                LOG.warn( "Interrupted while trying to reconnect to the provider {} with
user DN",
-                    config.getRemoteHost(), config.getReplUserDn() );
+                LOG.warn( "Consumer {} Interrupted while trying to reconnect to the provider
{}",
+                    config.getReplicaId(), producer );
             }
+
+            connected = connect();
         }
 
+        CONSUMER_LOG.debug( "Consumer {} connected to {}", config.getReplicaId(), producer
);
+
         startSync();
     }
 
@@ -1295,4 +1310,13 @@ public class ReplicationConsumerImpl imp
         }
     }
 
+    
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append( "Consumer " ).append( config );
+
+        return sb.toString();
+    }
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java?rev=1415868&r1=1415867&r2=1415868&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
Fri Nov 30 21:57:40 2012
@@ -304,7 +304,7 @@ public class ClientInitialRefreshIT
                     DirectoryService directoryService = new MockDirectoryService();
                     directoryService.setSchemaManager( schemaManager );
                     ( ( MockSyncReplConsumer ) syncreplClient ).init( directoryService );
-                    syncreplClient.start();
+                    syncreplClient.start( true );
                 }
                 catch ( Exception e )
                 {
@@ -332,7 +332,7 @@ public class ClientInitialRefreshIT
             {
                 try
                 {
-                    consumer.start();
+                    consumer.start( true );
                 }
                 catch ( Exception e )
                 {

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/MockSyncReplConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/MockSyncReplConsumer.java?rev=1415868&r1=1415867&r2=1415868&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/MockSyncReplConsumer.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/MockSyncReplConsumer.java
Fri Nov 30 21:57:40 2012
@@ -497,7 +497,7 @@ public class MockSyncReplConsumer implem
     /**
      * {@inheritDoc}
      */
-    public void start()
+    public void start( boolean now )
     {
         connect();
         startSync();



Mime
View raw message