directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1416321 - in /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication: SyncReplConfiguration.java consumer/ReplicationConsumerImpl.java
Date Mon, 03 Dec 2012 00:32:22 GMT
Author: elecharny
Date: Mon Dec  3 00:32:21 2012
New Revision: 1416321

URL: http://svn.apache.org/viewvc?rev=1416321&view=rev
Log:
Added more logs

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java?rev=1416321&r1=1416320&r2=1416321&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java
Mon Dec  3 00:32:21 2012
@@ -68,6 +68,9 @@ public class SyncReplConfiguration imple
 
     /** port number of the syncrepl provider server, default is 389 */
     private int remotePort = 389;
+    
+    /** The producer, as <host>:<port> */
+    private String producer = remoteHost + ":" + remotePort;
 
     /** replication user's Dn */
     private String replUserDn;
@@ -155,6 +158,7 @@ public class SyncReplConfiguration imple
     public void setRemoteHost( String remoteHost )
     {
         this.remoteHost = remoteHost;
+        producer = remoteHost + ":" + remotePort;
     }
     
     
@@ -164,7 +168,7 @@ public class SyncReplConfiguration imple
      */
     public String getProducer()
     {
-        return remoteHost + ":" + remotePort;
+        return producer;
     }
 
 
@@ -183,6 +187,7 @@ public class SyncReplConfiguration imple
     public void setRemotePort( int remotePort )
     {
         this.remotePort = remotePort;
+        producer = remoteHost + ":" + remotePort;
     }
 
 
@@ -620,7 +625,7 @@ public class SyncReplConfiguration imple
             sb.append( "MS, " );
         }
         
-        sb.append( "provider:" ).append( remoteHost ).append( ":" ).append( remotePort ).append(
", " ); 
+        sb.append( "provider:" ).append( producer ).append( ", " ); 
         sb.append( "user:'" ).append( replUserDn ).append( "', " ); 
         
         if ( strictCertVerification )

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=1416321&r1=1416320&r2=1416321&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
Mon Dec  3 00:32:21 2012
@@ -297,7 +297,7 @@ public class ReplicationConsumerImpl imp
     }
 
 
-    private ResultCodeEnum handleSearchDone( SearchResultDone searchDone )
+    private ResultCodeEnum handleSearchRseultDone( SearchResultDone searchDone )
     {
         LOG.debug( "///////////////// handleSearchDone //////////////////" );
 
@@ -323,7 +323,7 @@ public class ReplicationConsumerImpl imp
     }
 
 
-    private void handleSearchResult( SearchResultEntry syncResult )
+    private void handleSearchResultEntry( SearchResultEntry syncResult )
     {
 
         LOG.debug( "------------- starting handleSearchResult ------------" );
@@ -624,11 +624,13 @@ public class ReplicationConsumerImpl imp
      * receiving modifications' notifications on the consumer, and never exit the loop, unless
      * some communication error occurs.
      *
+     * @param syncType The synchornization type, either REFRESH_ONLY or REFRESH_AND_PERSIST
+     * @param reloadHint A flag used to tell the server that we want a reload
      * @throws Exception in case of any problems encountered while searching
      */
     private void doSyncSearch( SynchronizationModeEnum syncType, boolean reloadHint ) throws
Exception
     {
-        CONSUMER_LOG.debug( "In doSyncSearch, mode {}, reloadHint {}", syncType, reloadHint
);
+        CONSUMER_LOG.debug( "Starting synchronization mode {}, reloadHint {}", syncType,
reloadHint );
         // Prepare the Syncrepl Request
         SyncRequestValue syncReq = new SyncRequestValueDecorator( directoryService.getLdapCodecService()
);
 
@@ -638,20 +640,22 @@ public class ReplicationConsumerImpl imp
         // If we have a persisted cookie, send it.
         if ( syncCookie != null )
         {
-            LOG.debug( "searching with searchRequest, cookie '{}'", Strings.utf8ToString(
syncCookie ) );
+            CONSUMER_LOG.debug( "searching on {} with searchRequest, cookie '{}'", config.getProducer(),
Strings.utf8ToString( syncCookie ) );
             syncReq.setCookie( syncCookie );
         }
         else
         {
-            CONSUMER_LOG.debug( "searching with searchRequest, no cookie" );
+            CONSUMER_LOG.debug( "searching on {} with searchRequest, no cookie", config.getProducer()
);
         }
 
         searchRequest.addControl( syncReq );
 
-        // Do the search
+        // Do the search. We use a searchAsync because we want to get SearchResultDone responses
         SearchFuture sf = connection.searchAsync( searchRequest );
 
         Response resp = sf.get();
+        
+        CONSUMER_LOG.debug( "Response from {} : {}", config.getProducer(), resp );
 
         // Now, process the responses. We loop until we have a connection termination or
         // a SearchResultDone (RefreshOnly mode)
@@ -660,9 +664,8 @@ public class ReplicationConsumerImpl imp
             if ( resp instanceof SearchResultEntry )
             {
                 SearchResultEntry result = ( SearchResultEntry ) resp;
-                //System.out.println( "++++++++++++>  Consumer has received : " + result.getEntry().getDn()
);
 
-                handleSearchResult( result );
+                handleSearchResultEntry( result );
             }
             else if ( resp instanceof SearchResultReference )
             {
@@ -675,42 +678,71 @@ public class ReplicationConsumerImpl imp
 
             // Next entry
             resp = sf.get();
+            CONSUMER_LOG.debug( "Response from {} : {}", config.getProducer(), resp );
         }
-
-        ResultCodeEnum resultCode = handleSearchDone( ( SearchResultDone ) resp );
-
-        LOG.debug( "sync operation returned result code {}", resultCode );
-
-        if ( resultCode == ResultCodeEnum.NO_SUCH_OBJECT )
+        
+        if ( sf.isCancelled()  )
         {
-            // log the error and handle it appropriately
-            LOG.warn( "given replication base Dn {} is not found on provider", config.getBaseDn()
);
-
-            if ( syncType == SynchronizationModeEnum.REFRESH_AND_PERSIST )
-            {
-                LOG.warn( "disconnecting the consumer running in refreshAndPersist mode from
the provider" );
-                disconnect();
-            }
+            
+            CONSUMER_LOG.debug( "Search sync on {} has been canceled ", config.getProducer(),
sf.getCause() );
+            return;
         }
-        else if ( resultCode == ResultCodeEnum.E_SYNC_REFRESH_REQUIRED )
+        else if ( disconnected )
         {
-            LOG.info( "unable to perform the content synchronization cause E_SYNC_REFRESH_REQUIRED"
);
-
-            try
+            CONSUMER_LOG.debug( "Disconnected from {}", config.getProducer() );
+            return;
+        }
+        else
+        {
+            ResultCodeEnum resultCode = handleSearchRseultDone( ( SearchResultDone ) resp
);
+    
+            CONSUMER_LOG.debug( "Response from {} : {}", config.getProducer(), resultCode
);
+            LOG.debug( "sync operation returned result code {}", resultCode );
+    
+            if ( resultCode == ResultCodeEnum.NO_SUCH_OBJECT )
             {
-                deleteRecursive( new Dn( config.getBaseDn() ), null );
+                // log the error and handle it appropriately
+                CONSUMER_LOG.warn( "The base Dn {} is not found on provider {}", config.getBaseDn(),
config.getProducer() );
+                LOG.warn( "The base Dn {} is not found on provider {}", config.getBaseDn(),
config.getProducer() );
+    
+                if ( syncType == SynchronizationModeEnum.REFRESH_AND_PERSIST )
+                {
+                    CONSUMER_LOG.warn( "Disconnecting the Refresh&Persist consumer from
provider {}", config.getProducer() );
+                    LOG.warn( "Disconnecting the Refresh&Persist consumer from provider
{}", config.getProducer() );
+                    disconnect();
+                    
+                    return;
+                }
             }
-            catch ( Exception e )
+            else if ( resultCode == ResultCodeEnum.E_SYNC_REFRESH_REQUIRED )
+            {
+                CONSUMER_LOG.info( "Full SYNC_REFRESH required from {}", config.getProducer()
);
+                LOG.info( "Full SYNC_REFRESH required from {}", config.getProducer() );
+    
+                try
+                {
+                    CONSUMER_LOG.debug( "Deleting baseDN {}", config.getBaseDn() );
+                    deleteRecursive( new Dn( config.getBaseDn() ), null );
+                }
+                catch ( Exception e )
+                {
+                    LOG
+                        .error(
+                            "Failed to delete the replica base as part of handling E_SYNC_REFRESH_REQUIRED,
disconnecting the consumer",
+                            e );
+                }
+    
+                // Do a full update.
+                removeCookie();
+                
+                CONSUMER_LOG.debug( "Re-doing a syncRefresh from producer {}", config.getProducer()
);
+                // Remove this recursive call...
+                doSyncSearch( syncType, true );
+            }
+            else
             {
-                LOG
-                    .error(
-                        "Failed to delete the replica base as part of handling E_SYNC_REFRESH_REQUIRED,
disconnecting the consumer",
-                        e );
+                CONSUMER_LOG.debug( "Got result code {} from producer {}. Replication stopped",
resultCode, config.getProducer() );
             }
-
-            // Do a full update.
-            removeCookie();
-            doSyncSearch( syncType, true );
         }
     }
 



Mime
View raw message