directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r752692 - in /directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl: LdapConnection.java LdapConnectionImpl.java LdapProtocolDecoder.java SyncreplConsumer.java
Date Wed, 11 Mar 2009 23:32:24 GMT
Author: elecharny
Date: Wed Mar 11 23:32:24 2009
New Revision: 752692

URL: http://svn.apache.org/viewvc?rev=752692&view=rev
Log:
Some cleanup, less logs, minor refactoring

Modified:
    directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnection.java
    directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnectionImpl.java
    directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapProtocolDecoder.java
    directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplConsumer.java

Modified: directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnection.java?rev=752692&r1=752691&r2=752692&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnection.java
(original)
+++ directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnection.java
Wed Mar 11 23:32:24 2009
@@ -20,12 +20,10 @@
 package org.apache.directory.mitosis.syncrepl;
 
 import java.io.IOException;
-import java.util.List;
 
 import org.apache.directory.shared.ldap.codec.LdapMessage;
 import org.apache.directory.shared.ldap.codec.LdapResponse;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
-import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
 
 
 /**

Modified: directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnectionImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnectionImpl.java?rev=752692&r1=752691&r2=752692&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnectionImpl.java
(original)
+++ directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapConnectionImpl.java
Wed Mar 11 23:32:24 2009
@@ -23,8 +23,6 @@
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.Semaphore;
@@ -41,7 +39,6 @@
 import org.apache.directory.shared.ldap.codec.TwixTransformer;
 import org.apache.directory.shared.ldap.codec.bind.BindRequest;
 import org.apache.directory.shared.ldap.codec.bind.SimpleAuthentication;
-import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponse;
 import org.apache.directory.shared.ldap.codec.search.Filter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
 import org.apache.directory.shared.ldap.codec.search.SearchResultDone;
@@ -52,7 +49,6 @@
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.filter.SearchScope;
-import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.StringTools;

Modified: directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapProtocolDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapProtocolDecoder.java?rev=752692&r1=752691&r2=752692&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapProtocolDecoder.java
(original)
+++ directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/LdapProtocolDecoder.java
Wed Mar 11 23:32:24 2009
@@ -76,7 +76,6 @@
                 if ( IS_DEBUG )
                 {
                     LOG.debug( "Decoding the PDU : " );
-                	int size = buf.capacity();
                 	int pos = buf.position();
                 	
                 	byte[] b = new byte[pos-currentPos];

Modified: directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplConsumer.java?rev=752692&r1=752691&r2=752692&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplConsumer.java
(original)
+++ directory/apacheds/branches/apacheds-replication/mitosis/src/main/java/org/apache/directory/mitosis/syncrepl/SyncreplConsumer.java
Wed Mar 11 23:32:24 2009
@@ -25,6 +25,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.UUID;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.core.CoreSession;
@@ -46,7 +47,6 @@
 import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControlCodec;
 import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControlDecoder;
 import org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue.SyncStateValueControlCodec;
-import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponse;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
 import org.apache.directory.shared.ldap.codec.search.SearchResultDone;
 import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
@@ -310,7 +310,9 @@
 
         if ( !config.isRefreshPersist() )
         {
+        	// Now, switch to refreshAndPresist
             config.setRefreshPersist( true );
+            LOG.debug( "Swithing to RefreshAndPersist" );
         }
 
         if ( syncDoneCtrl.getCookie() != null )
@@ -355,63 +357,65 @@
             SyncStateTypeEnum state = syncStateCtrl.getSyncStateType();
 
             LOG.debug( "state name {}" + state.name() );
-            LOG.debug( "entryUUID = " + StringTools.utf8ToString( syncStateCtrl.getEntryUUID()
) );
+            LOG.debug( "entryUUID = " + UUID.nameUUIDFromBytes( syncStateCtrl.getEntryUUID()
) );
             CoreSession session = directoryService.getAdminSession();
 
-            if ( state == SyncStateTypeEnum.ADD )
+            switch ( state )
             {
-
-                if ( !session.exists( remoteEntry.getDn() ) )
-                {
-                    LOG.debug( "adding entry with dn {}", remoteEntry.getDn().getUpName()
);
-                    LOG.debug( remoteEntry.toString() );
-                    session.add( new DefaultServerEntry( directoryService.getRegistries(),
remoteEntry ) );
-                }
-            }
-            else if ( state == SyncStateTypeEnum.MODIFY )
-            {
-                
-                Entry localEntry = session.lookup( remoteEntry.getDn() );
-                LOG.debug( "modifying entry with dn {}", remoteEntry.getDn().getUpName()
);
-
-                List<Modification> mods = new ArrayList<Modification>();
-                Iterator<EntryAttribute> itr = localEntry.iterator();
-             
-                while ( itr.hasNext() )
-                {
-                    EntryAttribute localAttr = itr.next();
-                    String attrId = localAttr.getId();
-                    Modification mod;
-                    EntryAttribute remoteAttr = remoteEntry.get( attrId );
-                    
-                    if (  remoteAttr != null ) // would be better if we compare the values
also? or will it consume more time?
-                    {
-                        mod = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE,
remoteAttr );
-                    }
-                    else
-                    {
-                        mod = new ServerModification( ModificationOperation.REMOVE_ATTRIBUTE,
localAttr );
-                    }
-                
-                    remoteEntry.remove( remoteAttr );
-                    mods.add( mod );
-                }
-
-                if( remoteEntry.size() > 0 )
-                {
-                    itr = remoteEntry.iterator();
-                    while( itr.hasNext() )
-                    {
-                        mods.add( new ServerModification( ModificationOperation.ADD_ATTRIBUTE,
itr.next() ) );
-                    }
-                }
-                
-                session.modify( remoteEntry.getDn(), mods );
-            }
-            else if ( state == SyncStateTypeEnum.DELETE )
-            {
-                LOG.debug( "deleting entry with dn {}", remoteEntry.getDn().getUpName() );
-                directoryService.getAdminSession().delete( remoteEntry.getDn() );
+            	case ADD :
+	                if ( !session.exists( remoteEntry.getDn() ) )
+	                {
+	                    LOG.debug( "adding entry with dn {}", remoteEntry.getDn().getUpName()
);
+	                    LOG.debug( remoteEntry.toString() );
+	                    session.add( new DefaultServerEntry( directoryService.getRegistries(),
remoteEntry ) );
+	                }
+	                
+	                break;
+            
+            	case MODIFY :
+	                Entry localEntry = session.lookup( remoteEntry.getDn() );
+	                LOG.debug( "modifying entry with dn {}", remoteEntry.getDn().getUpName()
);
+	
+	                List<Modification> mods = new ArrayList<Modification>();
+	                Iterator<EntryAttribute> itr = localEntry.iterator();
+	             
+	                while ( itr.hasNext() )
+	                {
+	                    EntryAttribute localAttr = itr.next();
+	                    String attrId = localAttr.getId();
+	                    Modification mod;
+	                    EntryAttribute remoteAttr = remoteEntry.get( attrId );
+	                    
+	                    if (  remoteAttr != null ) // would be better if we compare the values
also? or will it consume more time?
+	                    {
+	                        mod = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE,
remoteAttr );
+	                    }
+	                    else
+	                    {
+	                        mod = new ServerModification( ModificationOperation.REMOVE_ATTRIBUTE,
localAttr );
+	                    }
+	                
+	                    remoteEntry.remove( remoteAttr );
+	                    mods.add( mod );
+	                }
+	
+	                if( remoteEntry.size() > 0 )
+	                {
+	                    itr = remoteEntry.iterator();
+	                    while( itr.hasNext() )
+	                    {
+	                        mods.add( new ServerModification( ModificationOperation.ADD_ATTRIBUTE,
itr.next() ) );
+	                    }
+	                }
+	                
+	                session.modify( remoteEntry.getDn(), mods );
+	                
+	                break;
+
+            	case DELETE :
+	                LOG.debug( "deleting entry with dn {}", remoteEntry.getDn().getUpName()
);
+	                directoryService.getAdminSession().delete( remoteEntry.getDn() );
+	                break;
             }
         }
         catch ( Exception e )
@@ -419,7 +423,7 @@
             LOG.error( e.getMessage(), e );
         }
 
-        LOG.debug( "------------- starting handleSearchResult ------------" );
+        LOG.debug( "------------- Ending handleSearchResult ------------" );
     }
 
 
@@ -492,8 +496,14 @@
                 
                 try
                 {
-                    LOG.debug( "========================================================
Pass #" + pass + "==========" );
-                    pass++;
+                	if ( config.isRefreshPersist() )
+                	{
+                		LOG.debug( "==================== Refresh And Persist ==========" );
+                	}
+                	else
+                	{
+                		LOG.debug( "==================== Initial Content ==========" );
+                	}
                     
                     if ( ( syncReq.getCookie() == null ) || ( syncReq.getCookie().length
== 0 ) )
                     {
@@ -521,7 +531,7 @@
             }
             while( syncReq.getMode() != SynchronizationModeEnum.REFRESH_AND_PERSIST );//
end of while loop
             
-            LOG.debug( "**************** exiting the while loop ***************" );
+            LOG.debug( "**************** Done with the sync ***************" );
         }
         catch ( Exception e )
         {
@@ -619,6 +629,10 @@
         agent.connect();
         agent.bind();
         agent.prepareSyncSearchRequest();
+        
+        // Do the initial content sync
         agent.startSync();
+        
+        
     }
 }



Mime
View raw message