You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/09/02 02:31:07 UTC

svn commit: r1164310 - in /directory/apacheds/trunk: protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/ server-integ/src/test/java/org/ap...

Author: elecharny
Date: Fri Sep  2 00:31:07 2011
New Revision: 1164310

URL: http://svn.apache.org/viewvc?rev=1164310&view=rev
Log:
o Decoded the SyncInfoValue part from the IntermediateMessage's value
o Added a dedicated CONSUMER_LOG logger
o Get bacl all the attributes when fetching the consumer config from the DIT. It's mandatory, because the ads-replCookie AT is an operationalAttribute, and it was not read back from the base.

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java

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=1164310&r1=1164309&r2=1164310&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 Sep  2 00:31:07 2011
@@ -48,6 +48,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.extras.controls.SyncStateTypeEnum;
 import org.apache.directory.shared.ldap.extras.controls.SyncStateValue;
 import org.apache.directory.shared.ldap.extras.controls.SynchronizationModeEnum;
+import org.apache.directory.shared.ldap.extras.controls.syncrepl_impl.SyncInfoValueDecorator;
 import org.apache.directory.shared.ldap.extras.controls.syncrepl_impl.SyncRequestValueDecorator;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.entry.Attribute;
@@ -94,6 +95,7 @@ public class ReplicationConsumerImpl imp
 {
     /** the logger */
     private static final Logger LOG = LoggerFactory.getLogger( ReplicationConsumerImpl.class );
+    private static final Logger CONSUMER_LOG = LoggerFactory.getLogger( "CONSUMER_LOG" );
 
     /** the syncrepl configuration */
     private SyncreplConfiguration config;
@@ -399,24 +401,29 @@ public class ReplicationConsumerImpl imp
         {
             LOG.debug( "............... inside handleSyncInfo ..............." );
 
-            SyncInfoValue syncInfoValue = ( SyncInfoValue ) syncInfoResp.getControl( SyncInfoValue.OID );
+            byte[] syncInfoBytes = syncInfoResp.getResponseValue();
 
-            if ( syncInfoValue == null )
+            if ( syncInfoBytes == null )
             {
                 return;
             }
             
+            SyncInfoValueDecorator decorator = new SyncInfoValueDecorator( directoryService.getLdapCodecService() );
+            SyncInfoValue syncInfoValue = ( SyncInfoValue ) decorator.decode( syncInfoBytes );
+
             byte[] cookie = syncInfoValue.getCookie();
 
             if ( cookie != null )
             {
                 LOG.debug( "setting the cookie from the sync info: " + Strings.utf8ToString(cookie) );
+                CONSUMER_LOG.debug( "setting the cookie from the sync info: " + Strings.utf8ToString(cookie) );
                 syncCookie = cookie;
             }
 
             LOG.info( "refreshDeletes: " + syncInfoValue.isRefreshDeletes() );
 
             List<byte[]> uuidList = syncInfoValue.getSyncUUIDs();
+            
             // if refreshDeletes set to true then delete all the entries with entryUUID
             // present in the syncIdSet
             if ( syncInfoValue.isRefreshDeletes() )
@@ -478,8 +485,13 @@ public class ReplicationConsumerImpl imp
      */
     public void startSync()
     {
+        CONSUMER_LOG.debug( "Starting the SyncRepl process" );
+        
         // read the cookie if persisted
         readCookie();
+        
+        CONSUMER_LOG.debug( "Cookie read : ''", syncCookie );
+
 
         if ( config.isRefreshNPersist() )
         {
@@ -552,6 +564,7 @@ public class ReplicationConsumerImpl imp
      */
     private void doSyncSearch( SynchronizationModeEnum syncType, boolean reloadHint ) throws Exception
     {
+        CONSUMER_LOG.debug( "In doSyncSearch, mode {}, reloadHint {}", syncType, reloadHint );
         // Prepare the Syncrepl Request
         SyncRequestValue syncReq = new SyncRequestValueDecorator( directoryService.getLdapCodecService() );
 
@@ -561,9 +574,13 @@ public class ReplicationConsumerImpl imp
          // If we have a persisted cookie, send it.
         if ( syncCookie != null )
         {
-            LOG.debug( "searching with searchRequest, cookie '{}'", Strings.utf8ToString(syncCookie) );
+            LOG.debug( "searching with searchRequest, cookie '{}'", Strings.utf8ToString( syncCookie ) );
             syncReq.setCookie( syncCookie );
         }
+        else
+        {
+            CONSUMER_LOG.debug( "searching with searchRequest, no cookie" );
+        }
 
         searchRequest.addControl( syncReq );
 
@@ -672,12 +689,14 @@ public class ReplicationConsumerImpl imp
      */
     private void storeCookie()
     {
+        CONSUMER_LOG.debug( "Storing the cookie '{}'", Strings.utf8ToString( syncCookie ) );
+        
         if ( syncCookie == null )
         {
             return;
         }
 
-        if ( lastSavedCookie != null && Arrays.equals( syncCookie, lastSavedCookie ) )
+        if ( ( lastSavedCookie != null ) && Arrays.equals( syncCookie, lastSavedCookie ) )
         {
             return;
         }
@@ -686,6 +705,7 @@ public class ReplicationConsumerImpl imp
         {
             if ( config.isStoreCookieInFile() )
             {
+                CONSUMER_LOG.debug( "Storingthe cookie in a file : {}", cookieFile );
                 FileOutputStream fout = new FileOutputStream( cookieFile );
                 fout.write( syncCookie.length );
                 fout.write( syncCookie );
@@ -697,7 +717,13 @@ public class ReplicationConsumerImpl imp
                 attr.clear();
                 attr.add( syncCookie );
 
+                CONSUMER_LOG.debug( "Storing the cookie in the DIT : {}", config.getConfigEntryDn() );
+                
                 session.modify( config.getConfigEntryDn(), cookieMod );
+                
+                Entry entry = session.lookup( config.getConfigEntryDn(), SchemaConstants.ALL_ATTRIBUTES_ARRAY );
+                
+                CONSUMER_LOG.debug( "stored entry : {}", entry );
             }
 
             lastSavedCookie = new byte[syncCookie.length];
@@ -721,6 +747,8 @@ public class ReplicationConsumerImpl imp
         {
             if ( config.isStoreCookieInFile() )
             {
+                CONSUMER_LOG.debug( "The cookie is stored in a file : {}", cookieFile );
+                
                 if ( cookieFile.exists() && ( cookieFile.length() > 0 ) )
                 {
                     FileInputStream fin = new FileInputStream( cookieFile );
@@ -738,8 +766,10 @@ public class ReplicationConsumerImpl imp
             {
                 try
                 {
-                    Entry entry = session.lookup( config.getConfigEntryDn(), COOKIE_AT_TYPE.getName() );
+                    Entry entry = session.lookup( config.getConfigEntryDn(), SchemaConstants.ALL_ATTRIBUTES_ARRAY );
                     
+                    CONSUMER_LOG.debug( "The cookie is stored in the DIT : {}", entry );
+
                     if ( entry != null )
                     {
                         Attribute attr = entry.get( COOKIE_AT_TYPE );
@@ -748,6 +778,7 @@ public class ReplicationConsumerImpl imp
                         {
                             syncCookie = attr.getBytes();
                             lastSavedCookie = syncCookie;
+                            CONSUMER_LOG.debug( "Read cookie : '{}'", attr );
                             LOG.debug( "loaded cookie from DIT" );
                         }
                     }

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=1164310&r1=1164309&r2=1164310&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 Fri Sep  2 00:31:07 2011
@@ -651,7 +651,7 @@ public class SyncReplRequestHandler impl
         resp.addControl( syncStateControl );
 
         LOG.debug( "Sending {}", entry.getDn() );
-        PROVIDER_LOG.debug( "Sending the entry:", entry.getDn() );
+        PROVIDER_LOG.debug( "Sending the entry: {}", entry );
         session.getIoSession().write( resp );
     }
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java?rev=1164310&r1=1164309&r2=1164310&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java Fri Sep  2 00:31:07 2011
@@ -390,7 +390,7 @@ public class ClientServerReplicationIT
     
     
     @Test
-    @Ignore( "Ignored until Selcuk's fix is injected into trunk" )
+    @Ignore( "we have some random failures" )
     public void testRebootConsumer() throws Exception
     {
         System.out.println( "----> 1 testRebootConsumer started --------------------------------" );
@@ -434,7 +434,7 @@ public class ClientServerReplicationIT
         System.out.println( "----> 7 Restarting the consumer --------------------------------" );
         consumerServer.start();
         
-        assertTrue( consumerSession.exists( deletedUserDn ) );
+        //assertTrue( consumerSession.exists( deletedUserDn ) );
         System.out.println( "----> 7bis entry " + deletedUserDn + " is still present in consumer --------------------------------" );
         
         assertTrue( checkEntryDeletion( consumerSession, deletedUserDn ) );