You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2013/12/29 15:35:59 UTC

svn commit: r1554028 - in /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication: consumer/ReplicationConsumerImpl.java provider/SyncReplRequestHandler.java

Author: kayyagari
Date: Sun Dec 29 14:35:59 2013
New Revision: 1554028

URL: http://svn.apache.org/r1554028
Log:
merged loggers and modified some log statements for better understanding

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

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=1554028&r1=1554027&r2=1554028&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 Sun Dec 29 14:35:59 2013
@@ -101,9 +101,6 @@ import org.slf4j.MDC;
  */
 public class ReplicationConsumerImpl implements ConnectionClosedEventListener, ReplicationConsumer
 {
-    /** 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( Loggers.CONSUMER_LOG.getName() );
 
@@ -240,8 +237,7 @@ public class ReplicationConsumerImpl imp
                 {
                     CONSUMER_LOG.warn( "Failed to bind to the producer {} with the given bind Dn {}",
                         config.getProducer(), config.getReplUserDn() );
-                    LOG.warn( "Failed to bind to the server with the given bind Dn {}", config.getReplUserDn() );
-                    LOG.warn( "", le );
+                    CONSUMER_LOG.warn( "", le );
                     disconnected = true;
                 }
             }
@@ -256,8 +252,7 @@ public class ReplicationConsumerImpl imp
         }
         catch ( Exception e )
         {
-            CONSUMER_LOG.error( "Failed to connect to the server {}, cause : {}", config.getProducer(), e.getMessage() );
-            LOG.error( "Failed to connect to the server {}, cause : {}", config.getProducer(), e.getMessage() );
+            CONSUMER_LOG.error( "Failed to connect to the producer {}, cause : {}", config.getProducer(), e.getMessage() );
             disconnected = true;
         }
 
@@ -302,18 +297,18 @@ public class ReplicationConsumerImpl imp
 
     private ResultCodeEnum handleSearchResultDone( SearchResultDone searchDone )
     {
-        LOG.debug( "///////////////// handleSearchDone //////////////////" );
+        CONSUMER_LOG.debug( "///////////////// handleSearchDone //////////////////" );
 
         SyncDoneValue ctrl = ( SyncDoneValue ) searchDone.getControls().get( SyncDoneValue.OID );
 
         if ( ( ctrl != null ) && ( ctrl.getCookie() != null ) )
         {
             syncCookie = ctrl.getCookie();
-            LOG.debug( "assigning cookie from sync done value control: " + Strings.utf8ToString( syncCookie ) );
+            CONSUMER_LOG.debug( "assigning cookie from sync done value control: " + Strings.utf8ToString( syncCookie ) );
             storeCookie();
         }
 
-        LOG.debug( "//////////////// END handleSearchDone//////////////////////" );
+        CONSUMER_LOG.debug( "//////////////// END handleSearchDone//////////////////////" );
 
         return searchDone.getLdapResult().getResultCode();
     }
@@ -338,7 +333,7 @@ public class ReplicationConsumerImpl imp
      */
     private void handleSearchResultEntry( SearchResultEntry syncResult )
     {
-        LOG.debug( "------------- starting handleSearchResult ------------" );
+        CONSUMER_LOG.debug( "------------- starting handleSearchResult ------------" );
 
         SyncStateValue syncStateCtrl = ( SyncStateValue ) syncResult.getControl( SyncStateValue.OID );
 
@@ -358,18 +353,18 @@ public class ReplicationConsumerImpl imp
                 {
                     syncCookie = syncStateCtrl.getCookie();
                     rid = LdapProtocolUtils.getReplicaId( Strings.utf8ToString( syncCookie ) );
-                    LOG.debug( "assigning the cookie from sync state value control: {}",
+                    CONSUMER_LOG.debug( "assigning the cookie from sync state value control: {}",
                         Strings.utf8ToString( syncCookie ) );
                 }
 
                 SyncStateTypeEnum state = syncStateCtrl.getSyncStateType();
 
-                LOG.debug( "state name {}", state.name() );
 
                 // check to avoid conversion of UUID from byte[] to String
-                if ( LOG.isDebugEnabled() )
+                if ( CONSUMER_LOG.isDebugEnabled() )
                 {
-                    LOG.debug( "entryUUID = {}", Strings.uuidToString( syncStateCtrl.getEntryUUID() ) );
+                    CONSUMER_LOG.debug( "state name {}", state.name() );
+                    CONSUMER_LOG.debug( "entryUUID = {}", Strings.uuidToString( syncStateCtrl.getEntryUUID() ) );
                 }
 
                 Dn remoteDn = remoteEntry.getDn();
@@ -390,8 +385,8 @@ public class ReplicationConsumerImpl imp
 
                         if ( !remoteDnExist )
                         {
-                            LOG.debug( "adding entry with dn {}", remoteDn );
-                            LOG.debug( remoteEntry.toString() );
+                            CONSUMER_LOG.debug( "adding entry with dn {}", remoteDn );
+                            CONSUMER_LOG.debug( remoteEntry.toString() );
                             AddOperationContext addContext = new AddOperationContext( session, remoteEntry );
                             addContext.setReplEvent( true );
                             addContext.setRid( rid );
@@ -401,14 +396,14 @@ public class ReplicationConsumerImpl imp
                         }
                         else
                         {
-                            LOG.debug( "updating entry in refreshOnly mode {}", remoteDn );
+                            CONSUMER_LOG.debug( "updating entry in refreshOnly mode {}", remoteDn );
                             modify( remoteEntry, rid );
                         }
 
                         break;
 
                     case MODIFY:
-                        LOG.debug( "modifying entry with dn {}", remoteEntry.getDn().getName() );
+                        CONSUMER_LOG.debug( "modifying entry with dn {}", remoteEntry.getDn().getName() );
                         modify( remoteEntry, rid );
 
                         break;
@@ -420,11 +415,11 @@ public class ReplicationConsumerImpl imp
                         break;
 
                     case DELETE:
-                        LOG.debug( "deleting entry with dn {}", remoteEntry.getDn().getName() );
+                        CONSUMER_LOG.debug( "deleting entry with dn {}", remoteEntry.getDn().getName() );
 
                         if ( !session.exists( remoteDn ) )
                         {
-                            LOG.debug(
+                            CONSUMER_LOG.debug(
                                 "looks like entry {} was already deleted in a prior update (possibly from another provider), skipping delete",
                                 remoteDn );
                         }
@@ -439,7 +434,7 @@ public class ReplicationConsumerImpl imp
                         break;
 
                     case PRESENT:
-                        LOG.debug( "entry present {}", remoteEntry );
+                        CONSUMER_LOG.debug( "entry present {}", remoteEntry );
                         break;
                 }
 
@@ -452,10 +447,10 @@ public class ReplicationConsumerImpl imp
         }
         catch ( Exception e )
         {
-            LOG.error( e.getMessage(), e );
+            CONSUMER_LOG.error( e.getMessage(), e );
         }
 
-        LOG.debug( "------------- Ending handleSearchResult ------------" );
+        CONSUMER_LOG.debug( "------------- Ending handleSearchResult ------------" );
     }
 
 
@@ -466,7 +461,7 @@ public class ReplicationConsumerImpl imp
     {
         try
         {
-            LOG.debug( "............... inside handleSyncInfo ..............." );
+            CONSUMER_LOG.debug( "............... inside handleSyncInfo ..............." );
 
             byte[] syncInfoBytes = syncInfoResp.getResponseValue();
 
@@ -490,7 +485,7 @@ public class ReplicationConsumerImpl imp
 
             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 ) );
                 CONSUMER_LOG.debug( "setting the cookie from the sync info: " + Strings.utf8ToString( cookie ) );
                 syncCookie = cookie;
 
@@ -498,7 +493,7 @@ public class ReplicationConsumerImpl imp
                 replicaId = LdapProtocolUtils.getReplicaId( cookieString );
             }
 
-            LOG.info( "refreshDeletes: " + syncInfoValue.isRefreshDeletes() );
+            CONSUMER_LOG.info( "refreshDeletes: " + syncInfoValue.isRefreshDeletes() );
 
             List<byte[]> uuidList = syncInfoValue.getSyncUUIDs();
 
@@ -513,17 +508,16 @@ public class ReplicationConsumerImpl imp
                 deleteEntries( uuidList, true, replicaId );
             }
 
-            LOG.info( "refreshDone: " + syncInfoValue.isRefreshDone() );
+            CONSUMER_LOG.info( "refreshDone: " + syncInfoValue.isRefreshDone() );
 
             storeCookie();
         }
         catch ( Exception de )
         {
-            LOG.error( "Failed to handle syncinfo message", de );
             CONSUMER_LOG.error( "Failed to handle syncinfo message", de );
         }
 
-        LOG.debug( ".................... END handleSyncInfo ..............." );
+        CONSUMER_LOG.debug( ".................... END handleSyncInfo ..............." );
     }
 
 
@@ -557,13 +551,13 @@ public class ReplicationConsumerImpl imp
         {
             try
             {
-                LOG.debug( "==================== Refresh And Persist ==========" );
+                CONSUMER_LOG.debug( "==================== Refresh And Persist ==========" );
 
                 return doSyncSearch( SynchronizationModeEnum.REFRESH_AND_PERSIST, false );
             }
             catch ( Exception e )
             {
-                LOG.error( "Failed to sync with refreshAndPersist mode", e );
+                CONSUMER_LOG.error( "Failed to sync with refreshAndPersist mode", e );
                 return ReplicationStatusEnum.DISCONNECTED;
             }
         }
@@ -578,26 +572,26 @@ public class ReplicationConsumerImpl imp
     {
         while ( !disconnected )
         {
-            LOG.debug( "==================== Refresh Only ==========" );
+            CONSUMER_LOG.debug( "==================== Refresh Only ==========" );
 
             try
             {
                 doSyncSearch( SynchronizationModeEnum.REFRESH_ONLY, false );
 
-                LOG.info( "--------------------- Sleep for a little while ------------------" );
+                CONSUMER_LOG.debug( "--------------------- Sleep for a little while ------------------" );
                 Thread.sleep( config.getRefreshInterval() );
-                LOG.debug( "--------------------- syncing again ------------------" );
+                CONSUMER_LOG.debug( "--------------------- syncing again ------------------" );
 
             }
             catch ( InterruptedException ie )
             {
-                LOG.warn( "refresher thread interrupted" );
+                CONSUMER_LOG.warn( "refresher thread interrupted" );
 
                 return ReplicationStatusEnum.DISCONNECTED;
             }
             catch ( Exception e )
             {
-                LOG.error( "Failed to sync with refresh only mode", e );
+                CONSUMER_LOG.error( "Failed to sync with refresh only mode", e );
                 return ReplicationStatusEnum.DISCONNECTED;
             }
         }
@@ -639,7 +633,7 @@ public class ReplicationConsumerImpl imp
             }
             catch ( InterruptedException e )
             {
-                LOG.warn( "Consumer {} Interrupted while trying to reconnect to the provider {}",
+                CONSUMER_LOG.warn( "Consumer {} Interrupted while trying to reconnect to the provider {}",
                     config.getReplicaId(), config.getProducer() );
             }
 
@@ -805,26 +799,22 @@ public class ReplicationConsumerImpl imp
         {
             ResultCodeEnum resultCode = handleSearchResultDone( ( SearchResultDone ) resp );
 
-            CONSUMER_LOG.debug( "Response from {} : {}", config.getProducer(), resultCode );
-            LOG.debug( "sync operation returned result code {}", resultCode );
+            CONSUMER_LOG.debug( "Rsultcode of Sync operation from {} : {}", config.getProducer(), resultCode );
 
             if ( resultCode == ResultCodeEnum.NO_SUCH_OBJECT )
             {
                 // 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() );
 
                 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 ReplicationStatusEnum.DISCONNECTED;
             }
             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() );
+                CONSUMER_LOG.warn( "Full SYNC_REFRESH required from {}", config.getProducer() );
 
                 try
                 {
@@ -833,7 +823,7 @@ public class ReplicationConsumerImpl imp
                 }
                 catch ( Exception e )
                 {
-                    LOG
+                    CONSUMER_LOG
                         .error(
                             "Failed to delete the replica base as part of handling E_SYNC_REFRESH_REQUIRED, disconnecting the consumer",
                             e );
@@ -868,7 +858,7 @@ public class ReplicationConsumerImpl imp
             if ( ( connection != null ) && connection.isConnected() )
             {
                 connection.unBind();
-                LOG.info( "Unbound from the server {}", config.getProducer() );
+                CONSUMER_LOG.info( "Unbound from the server {}", config.getProducer() );
 
                 if ( CONSUMER_LOG.isDebugEnabled() )
                 {
@@ -877,7 +867,6 @@ public class ReplicationConsumerImpl imp
                 }
 
                 connection.close();
-                LOG.info( "Connection closed for the server {}", config.getProducer() );
                 CONSUMER_LOG.info( "Connection closed for the server {}", config.getProducer() );
 
                 connection = null;
@@ -885,7 +874,7 @@ public class ReplicationConsumerImpl imp
         }
         catch ( Exception e )
         {
-            LOG.error( "Failed to close the connection", e );
+            CONSUMER_LOG.error( "Failed to close the connection", e );
         }
         finally
         {
@@ -937,11 +926,11 @@ public class ReplicationConsumerImpl imp
             lastSavedCookie = new byte[syncCookie.length];
             System.arraycopy( syncCookie, 0, lastSavedCookie, 0, syncCookie.length );
 
-            LOG.debug( "stored the cookie" );
+            CONSUMER_LOG.debug( "stored the cookie" );
         }
         catch ( Exception e )
         {
-            LOG.error( "Failed to store the cookie in consumer entry {}", config.getConfigEntryDn(), e );
+            CONSUMER_LOG.error( "Failed to store the cookie in consumer entry {}", config.getConfigEntryDn(), e );
         }
     }
 
@@ -964,8 +953,7 @@ public class ReplicationConsumerImpl imp
                     syncCookie = attr.getBytes();
                     lastSavedCookie = syncCookie;
                     String syncCookieString = Strings.utf8ToString( syncCookie );
-                    CONSUMER_LOG.debug( "Cookie for consumer {} : {}", config.getReplicaId(), syncCookieString );
-                    LOG.debug( "loaded cookie from DIT" );
+                    CONSUMER_LOG.debug( "Loaded cookie {} for consumer {}", syncCookieString, config.getReplicaId() );
                 }
                 else
                 {
@@ -982,9 +970,8 @@ public class ReplicationConsumerImpl imp
         {
             // can be ignored, most likely happens if there is no entry with the given Dn
             // log in debug mode
-            CONSUMER_LOG.debug( "Cannot find the  '{}' in the DIT for consumer {}", config.getConfigEntryDn(),
+            CONSUMER_LOG.debug( "Failed to read the cookie, cannot find the entry '{}' in the DIT for consumer {}", config.getConfigEntryDn(),
                 config.getReplicaId() );
-            LOG.debug( "Failed to read the cookie from the entry {}", config.getConfigEntryDn(), e );
         }
     }
 
@@ -1003,11 +990,11 @@ public class ReplicationConsumerImpl imp
         }
         catch ( Exception e )
         {
-            LOG.warn( "Failed to delete the cookie from the entry with Dn {}", config.getConfigEntryDn() );
-            LOG.warn( "{}", e );
+            CONSUMER_LOG.warn( "Failed to delete the cookie from the consumer with config entry Dn {}", config.getConfigEntryDn() );
+            CONSUMER_LOG.warn( "{}", e );
         }
 
-        LOG.info( "resetting sync cookie" );
+        CONSUMER_LOG.info( "resetting sync cookie of the consumer with config entry Dn {}", config.getConfigEntryDn() );
 
         syncCookie = null;
         lastSavedCookie = null;
@@ -1016,7 +1003,7 @@ public class ReplicationConsumerImpl imp
 
     private void applyModDnOperation( Entry remoteEntry, String entryUuid, int rid ) throws Exception
     {
-        LOG.debug( "MODDN for entry {}, new entry : {}", entryUuid, remoteEntry );
+        CONSUMER_LOG.debug( "MODDN for entry {}, new entry : {}", entryUuid, remoteEntry );
 
         // First, compute the MODDN type
         SyncModifyDnType modDnType = null;
@@ -1057,7 +1044,7 @@ public class ReplicationConsumerImpl imp
                 if ( localCsn.compareTo( remoteCsn ) >= 0 )
                 {
                     // just discard the received modified entry, that is old
-                    LOG.debug( "local modification is latest, discarding the modDn operation dn {}",
+                    CONSUMER_LOG.debug( "local modification is latest, discarding the modDn operation dn {}",
                         remoteEntry.getDn() );
                     return;
                 }
@@ -1095,7 +1082,7 @@ public class ReplicationConsumerImpl imp
             switch ( modDnType )
             {
                 case MOVE:
-                    LOG.debug( "moving {} to the new parent {}", localDn, remoteParentDn );
+                    CONSUMER_LOG.debug( "moving {} to the new parent {}", localDn, remoteParentDn );
                     MoveOperationContext movCtx = new MoveOperationContext( session, localDn, remoteParentDn );
                     movCtx.setReplEvent( true );
                     movCtx.setRid( rid );
@@ -1104,7 +1091,7 @@ public class ReplicationConsumerImpl imp
                     break;
 
                 case RENAME:
-                    LOG.debug( "renaming the Dn {} with new Rdn {} and deleteOldRdn flag set to {}", new String[]
+                    CONSUMER_LOG.debug( "renaming the Dn {} with new Rdn {} and deleteOldRdn flag set to {}", new String[]
                         { localDn.getName(), remoteRdn.getName(), String.valueOf( deleteOldRdn ) } );
 
                     RenameOperationContext renCtx = new RenameOperationContext( session, localDn, remoteRdn,
@@ -1116,7 +1103,7 @@ public class ReplicationConsumerImpl imp
                     break;
 
                 case MOVE_AND_RENAME:
-                    LOG.debug(
+                    CONSUMER_LOG.debug(
                         "moveAndRename on the Dn {} with new newParent Dn {}, new Rdn {} and deleteOldRdn flag set to {}",
                         new String[]
                             {
@@ -1160,7 +1147,7 @@ public class ReplicationConsumerImpl imp
             if ( localCsn.compareTo( remoteCsn ) >= 0 )
             {
                 // just discard the received modified entry, that is old
-                LOG.debug( "local modification is latest, discarding the modification of dn {}", remoteEntry.getDn() );
+                CONSUMER_LOG.debug( "local modification is latest, discarding the modification of dn {}", remoteEntry.getDn() );
                 return;
             }
         }
@@ -1268,17 +1255,12 @@ public class ReplicationConsumerImpl imp
             return;
         }
 
-        for ( byte[] uuid : uuidList )
-        {
-            LOG.info( "uuid: {}", Strings.uuidToString( uuid ) );
-        }
-
         // if it is refreshPresent list then send all the UUIDs for
         // filtering, otherwise breaking the list will cause the
         // other present entries to be deleted from DIT
         if ( isRefreshPresent )
         {
-            LOG.debug( "refresh present syncinfo list has {} UUIDs", uuidList.size() );
+            CONSUMER_LOG.debug( "refresh present syncinfo list has {} UUIDs", uuidList.size() );
             processDelete( uuidList, isRefreshPresent, replicaId );
             return;
         }
@@ -1323,6 +1305,7 @@ public class ReplicationConsumerImpl imp
         if ( size == 1 )
         {
             String uuid = Strings.uuidToString( limitedUuidList.get( 0 ) );
+            
             filter = new EqualityNode<String>( SchemaConstants.ENTRY_UUID_AT,
                 new org.apache.directory.api.ldap.model.entry.StringValue( uuid ) );
             if ( isRefreshPresent )
@@ -1361,7 +1344,7 @@ public class ReplicationConsumerImpl imp
 
         Dn dn = new Dn( schemaManager, config.getBaseDn() );
 
-        LOG.debug( "selecting entries to be deleted using filter {}", filter.toString() );
+        CONSUMER_LOG.debug( "selecting entries to be deleted using filter {}", filter.toString() );
         Cursor<Entry> cursor = session.search( dn, SearchScope.SUBTREE, filter,
             AliasDerefMode.NEVER_DEREF_ALIASES, SchemaConstants.ENTRY_UUID_AT );
         cursor.beforeFirst();
@@ -1420,7 +1403,7 @@ public class ReplicationConsumerImpl imp
      */
     private void deleteRecursive( Dn rootDn, Map<Dn, Cursor<Entry>> cursorMap ) throws Exception
     {
-        LOG.debug( "searching for {}", rootDn.getName() );
+        CONSUMER_LOG.debug( "searching for Dn {} before deleting", rootDn.getName() );
         Cursor<Entry> cursor = null;
 
         try
@@ -1437,13 +1420,13 @@ public class ReplicationConsumerImpl imp
                 cursor = session.search( rootDn, SearchScope.ONELEVEL, ENTRY_UUID_PRESENCE_FILTER,
                     AliasDerefMode.NEVER_DEREF_ALIASES, SchemaConstants.ENTRY_UUID_AT );
                 cursor.beforeFirst();
-                LOG.debug( "putting cursor for {}", rootDn.getName() );
+                CONSUMER_LOG.debug( "(delete operation) storing cursor of Dn {}", rootDn.getName() );
                 cursorMap.put( rootDn, cursor );
             }
 
             if ( !cursor.next() ) // if this is a leaf entry's Dn
             {
-                LOG.debug( "deleting {}", rootDn.getName() );
+                CONSUMER_LOG.debug( "deleting {}", rootDn.getName() );
                 cursorMap.remove( rootDn );
                 cursor.close();
                 session.delete( rootDn );
@@ -1460,14 +1443,14 @@ public class ReplicationConsumerImpl imp
 
                 cursorMap.remove( rootDn );
                 cursor.close();
-                LOG.debug( "deleting {}", rootDn.getName() );
+                CONSUMER_LOG.debug( "deleting {}", rootDn.getName() );
                 session.delete( rootDn );
             }
         }
         catch ( Exception e )
         {
             String msg = "Failed to delete child entries under the Dn " + rootDn.getName();
-            LOG.error( msg, e );
+            CONSUMER_LOG.error( msg, e );
             throw e;
         }
     }

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=1554028&r1=1554027&r2=1554028&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 Sun Dec 29 14:35:59 2013
@@ -116,9 +116,6 @@ import org.slf4j.LoggerFactory;
 @SuppressWarnings("unchecked")
 public class SyncReplRequestHandler implements ReplicationRequestHandler
 {
-    /** The logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( SyncReplRequestHandler.class );
-
     /** A logger for the replication provider */
     private static final Logger PROVIDER_LOG = LoggerFactory.getLogger( Loggers.PROVIDER_LOG.getName() );
 
@@ -170,7 +167,6 @@ public class SyncReplRequestHandler impl
         // Check that the handler is not already started : we don't want to start it twice...
         if ( initialized )
         {
-            LOG.warn( "syncrepl provider was already initialized" );
             PROVIDER_LOG.warn( "syncrepl provider was already initialized" );
 
             return;
@@ -178,7 +174,6 @@ public class SyncReplRequestHandler impl
 
         try
         {
-            LOG.info( "initializing the syncrepl provider" );
             PROVIDER_LOG.debug( "initializing the syncrepl provider" );
 
             this.ldapServer = server;
@@ -242,12 +237,10 @@ public class SyncReplRequestHandler impl
             }
 
             initialized = true;
-            LOG.info( "syncrepl provider initialized successfully" );
             PROVIDER_LOG.debug( "syncrepl provider initialized successfully" );
         }
         catch ( Exception e )
         {
-            LOG.error( "Failed to initialize the log files required by the syncrepl provider", e );
             PROVIDER_LOG.error( "Failed to initialize the log files required by the syncrepl provider", e );
             throw new RuntimeException( e );
         }
@@ -277,7 +270,6 @@ public class SyncReplRequestHandler impl
             }
             catch ( Exception e )
             {
-                LOG.warn( "Failed to close the event log {}", log.getId(), e );
                 PROVIDER_LOG.error( "Failed to close the event log {}", log.getId(), e );
             }
         }
@@ -322,12 +314,10 @@ public class SyncReplRequestHandler impl
                 String cookieString = Strings.utf8ToString( cookieBytes );
 
                 PROVIDER_LOG.debug( "Received a replication request {} with a cookie '{}'", request, cookieString );
-                LOG.debug( "search request received with the cookie {}", cookieString );
 
                 if ( !LdapProtocolUtils.isValidCookie( cookieString ) )
                 {
-                    LOG.error( "received a invalid cookie {} from the consumer with session {}", cookieString, session );
-                    PROVIDER_LOG.error( "received a invalid cookie {} from the consumer with session {}", cookieString,
+                    PROVIDER_LOG.error( "received an invalid cookie {} from the consumer with session {}", cookieString,
                         session );
                     sendESyncRefreshRequired( session, request );
                 }
@@ -337,8 +327,6 @@ public class SyncReplRequestHandler impl
 
                     if ( clientMsgLog == null )
                     {
-                        LOG.warn( "received a valid cookie {} but there is no event log associated with this replica",
-                            cookieString );
                         PROVIDER_LOG.debug(
                             "received a valid cookie {} but there is no event log associated with this replica",
                             cookieString );
@@ -354,7 +342,6 @@ public class SyncReplRequestHandler impl
         }
         catch ( Exception e )
         {
-            LOG.error( "Failed to handle the syncrepl request", e );
             PROVIDER_LOG.error( "Failed to handle the syncrepl request", e );
 
             throw new LdapException( e.getMessage(), e );
@@ -382,7 +369,6 @@ public class SyncReplRequestHandler impl
             {
                 ReplicaEventMessage replicaEventMessage = cursor.get();
                 Entry entry = replicaEventMessage.getEntry();
-                LOG.debug( "Read message from the queue {}", entry );
                 PROVIDER_LOG.debug( "Read message from the queue {}", entry );
 
                 lastSentCsn = entry.get( CSN_AT ).getString();
@@ -500,11 +486,11 @@ public class SyncReplRequestHandler impl
 
         if( ctrl != null )
         {
-            LOG.warn( "Removing the received sort control from the syncrepl search request during initial refresh" );
+            PROVIDER_LOG.warn( "Removing the received sort control from the syncrepl search request during initial refresh" );
             request.removeControl( ctrl );
         }
 
-        LOG.debug( "Adding sort control to sort the entries by entryDn attribute to preserve order of insertion" );
+        PROVIDER_LOG.debug( "Adding sort control to sort the entries by entryDn attribute to preserve order of insertion" );
         SortKey sk = new SortKey( SchemaConstants.ENTRY_DN_AT );
         // matchingrule for "entryDn"
         sk.setMatchingRuleId( "2.5.13.1" );
@@ -540,7 +526,6 @@ public class SyncReplRequestHandler impl
         // now we process entries forever as they change
         // irrespective of the sync mode set the 'isRealtimePush' to false initially so that we can
         // store the modifications in the queue and later if it is a persist mode
-        LOG.info( "Starting the replicaLog {}", replicaLog );
         PROVIDER_LOG.debug( "Starting the replicaLog {}", replicaLog );
 
         // we push this queue's content and switch to realtime mode
@@ -622,8 +607,6 @@ public class SyncReplRequestHandler impl
         else
         // if not succeeded return
         {
-            LOG.warn( "initial content refresh didn't succeed due to {}", searchDoneResp.getLdapResult()
-                .getResultCode() );
             PROVIDER_LOG.warn( "initial content refresh didn't succeed due to {}", searchDoneResp.getLdapResult()
                 .getResultCode() );
             replicaLog.stop();
@@ -676,7 +659,7 @@ public class SyncReplRequestHandler impl
 
             req.addAbandonListener( new SearchAbandonListener( ldapServer, cursor ) );
             setTimeLimitsOnCursor( req, session, cursor );
-            LOG.debug( "using <{},{}> for size limit", requestLimit, serverLimit );
+            PROVIDER_LOG.debug( "search operation requested size limit {}, server size limit {}", requestLimit, serverLimit );
             long sizeLimit = min( requestLimit, serverLimit );
 
             readResults( session, req, ldapResult, cursor, sizeLimit, replicaLog );
@@ -691,7 +674,7 @@ public class SyncReplRequestHandler impl
                 }
                 catch ( Exception e )
                 {
-                    LOG.error( I18n.err( I18n.ERR_168 ), e );
+                    PROVIDER_LOG.error( I18n.err( I18n.ERR_168 ), e );
                 }
             }
         }
@@ -716,7 +699,6 @@ public class SyncReplRequestHandler impl
             if ( session.getIoSession().isClosing() )
             {
                 // The client has closed the connection
-                LOG.debug( "Request terminated for message {}, the client has closed the session", req.getMessageId() );
                 PROVIDER_LOG.debug( "Request terminated for message {}, the client has closed the session",
                     req.getMessageId() );
                 break;
@@ -725,7 +707,6 @@ public class SyncReplRequestHandler impl
             if ( req.isAbandoned() )
             {
                 // The cursor has been closed by an abandon request.
-                LOG.debug( "Request terminated by an AbandonRequest for message {}", req.getMessageId() );
                 PROVIDER_LOG.debug( "Request terminated by an AbandonRequest for message {}", req.getMessageId() );
                 break;
             }
@@ -782,7 +763,6 @@ public class SyncReplRequestHandler impl
         Response resp = generateResponse( session, req, entry );
         resp.addControl( syncStateControl );
 
-        LOG.debug( "Sending {}", entry.getDn() );
         PROVIDER_LOG.debug( "Sending the entry:\n {}", resp );
         session.getIoSession().write( resp );
     }
@@ -821,7 +801,7 @@ public class SyncReplRequestHandler impl
                 }
                 catch ( LdapURLEncodingException e )
                 {
-                    LOG.error( I18n.err( I18n.ERR_165, url, entry ) );
+                    PROVIDER_LOG.error( I18n.err( I18n.ERR_165, url, entry ) );
                 }
 
                 switch ( req.getScope() )
@@ -1007,7 +987,6 @@ public class SyncReplRequestHandler impl
 
                 if ( replica.isDirty() )
                 {
-                    LOG.debug( "updating the details of replica {}", replica );
                     PROVIDER_LOG.debug( "updating the details of replica {}", replica );
                     replicaUtil.updateReplicaLastSentCsn( replica );
                     replica.setDirty( false );
@@ -1016,7 +995,6 @@ public class SyncReplRequestHandler impl
         }
         catch ( Exception e )
         {
-            LOG.error( "Failed to store the replica information", e );
             PROVIDER_LOG.error( "Failed to store the replica information", e );
         }
     }
@@ -1036,7 +1014,6 @@ public class SyncReplRequestHandler impl
             {
                 for ( ReplicaEventLog replica : eventLogs )
                 {
-                    LOG.debug( "initializing the replica log from {}", replica.getId() );
                     PROVIDER_LOG.debug( "initializing the replica log from {}", replica.getId() );
                     replicaLogMap.put( replica.getId(), replica );
                     eventLogNames.add( replica.getName() );
@@ -1050,7 +1027,6 @@ public class SyncReplRequestHandler impl
             }
             else
             {
-                LOG.debug( "no replica logs found to initialize" );
                 PROVIDER_LOG.debug( "no replica logs found to initialize" );
             }
 
@@ -1060,13 +1036,12 @@ public class SyncReplRequestHandler impl
                 if ( !eventLogNames.contains( f.getName() ) )
                 {
                     f.delete();
-                    LOG.info( "removed unused replication event log {}", f );
+                    PROVIDER_LOG.info( "removed unused replication event log {}", f );
                 }
             }
         }
         catch ( Exception e )
         {
-            LOG.error( "Failed to load the replica information", e );
             PROVIDER_LOG.error( "Failed to load the replica information", e );
         }
     }
@@ -1083,7 +1058,6 @@ public class SyncReplRequestHandler impl
 
             if ( log.getSearchCriteria() != null )
             {
-                LOG.debug( "registering persistent search for the replica {}", log.getId() );
                 PROVIDER_LOG.debug( "registering persistent search for the replica {}", log.getId() );
                 SyncReplSearchListener handler = new SyncReplSearchListener( null, null, log, false );
                 log.setPersistentListener( handler );
@@ -1092,8 +1066,6 @@ public class SyncReplRequestHandler impl
             }
             else
             {
-                LOG.warn( "invalid persistent search criteria {} for the replica {}", log.getSearchCriteria(), log
-                    .getId() );
                 PROVIDER_LOG.warn( "invalid persistent search criteria {} for the replica {}", log.getSearchCriteria(),
                     log
                         .getId() );
@@ -1122,7 +1094,6 @@ public class SyncReplRequestHandler impl
                     }
                     catch ( InterruptedException e )
                     {
-                        LOG.warn( "thread storing the replica information was interrupted", e );
                         PROVIDER_LOG.warn( "thread storing the replica information was interrupted", e );
                     }
                 }
@@ -1157,7 +1128,7 @@ public class SyncReplRequestHandler impl
     {
         int replicaId = replicaCount.incrementAndGet();
 
-        LOG.debug( "creating a new event log for the replica with id {}", replicaId );
+        PROVIDER_LOG.debug( "creating a new event log for the replica with id {}", replicaId );
 
         ReplicaEventLog replicaLog = new ReplicaEventLog( dirService, replicaId );
         replicaLog.setHostName( hostName );
@@ -1281,7 +1252,7 @@ public class SyncReplRequestHandler impl
                     }
                     catch ( LdapInvalidAttributeValueException e )
                     {
-                        LOG.warn( "Invalid attribute type", e );
+                        PROVIDER_LOG.warn( "Invalid attribute type", e );
                     }
                 }
             }