Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 18126 invoked from network); 11 Mar 2009 23:32:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Mar 2009 23:32:47 -0000 Received: (qmail 96420 invoked by uid 500); 11 Mar 2009 23:32:47 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 96390 invoked by uid 500); 11 Mar 2009 23:32:46 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 96381 invoked by uid 99); 11 Mar 2009 23:32:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Mar 2009 16:32:46 -0700 X-ASF-Spam-Status: No, hits=-1998.8 required=10.0 tests=ALL_TRUSTED,FS_REPLICA X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Mar 2009 23:32:45 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2845423888E7; Wed, 11 Mar 2009 23:32:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090311233225.2845423888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 mods = new ArrayList(); - Iterator 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 mods = new ArrayList(); + Iterator 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(); + + } }