directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1486550 - in /directory/apacheds/trunk: core-integ/src/test/java/org/apache/directory/server/core/collective/ core-integ/src/test/resources/ interceptors/collective/src/main/java/org/apache/directory/server/core/collective/
Date Mon, 27 May 2013 09:40:38 GMT
Author: elecharny
Date: Mon May 27 09:40:38 2013
New Revision: 1486550

URL: http://svn.apache.org/r1486550
Log:
Added some (temporary) logs into the CollectiveAttribute interceptor, in order to understand
why we have some random failures (see DIRSERVER-1845)

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java
    directory/apacheds/trunk/core-integ/src/test/resources/log4j.properties
    directory/apacheds/trunk/interceptors/collective/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java?rev=1486550&r1=1486549&r2=1486550&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java
Mon May 27 09:40:38 2013
@@ -125,7 +125,7 @@ public class CollectiveAttributeServiceI
     }
 
 
-    private Map<String, Entry> getAllEntries( LdapConnection connection ) throws Exception
+    private Map<String, Entry> getAllEntries( LdapConnection connection, boolean print
) throws Exception
     {
         Map<String, Entry> resultMap = new HashMap<String, Entry>();
 
@@ -136,7 +136,13 @@ public class CollectiveAttributeServiceI
         {
             Entry entry = cursor.get();
 
-            resultMap.put( entry.getDn().getName(), entry );
+            String dn = entry.getDn().getName();
+            resultMap.put( dn, entry );
+
+            if ( print )
+            {
+                System.out.println( "found entry " + dn );
+            }
         }
 
         cursor.close();
@@ -360,7 +366,7 @@ public class CollectiveAttributeServiceI
         // -------------------------------------------------------------------
         // test an entry that should show the collective attribute c-ou
         // -------------------------------------------------------------------
-        Map<String, Entry> entries = getAllEntries( connection );
+        Map<String, Entry> entries = getAllEntries( connection, false );
         Entry entry = entries.get( "ou=services,ou=configuration,ou=system" );
         Attribute c_ou = entry.get( "c-ou" );
         assertNotNull( "a collective c-ou attribute should be present", c_ou );
@@ -409,7 +415,8 @@ public class CollectiveAttributeServiceI
             new DefaultAttribute( "collectiveExclusions", "c-ou" ) );
         connection.modify( "ou=services,ou=configuration, ou=system", modification );
 
-        entries = getAllEntries( connection );
+        System.out.println( "----- Checking exclusions" );
+        entries = getAllEntries( connection, true );
 
         // entry should not show the c-ou collective attribute anymore
         entry = entries.get( "ou=services,ou=configuration,ou=system" );
@@ -420,9 +427,11 @@ public class CollectiveAttributeServiceI
             assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size()
);
         }
 
+        System.out.println( "----- Exclusions OK" );
+
         // now add more collective subentries - the c-ou should still not show due to exclusions
         connection.add( getTestSubentry2( "cn=testsubentry2,ou=system" ) );
-        entries = getAllEntries( connection );
+        entries = getAllEntries( connection, false );
 
         entry = entries.get( "ou=services,ou=configuration,ou=system" );
         c_ou = entry.get( "c-ou" );
@@ -444,7 +453,7 @@ public class CollectiveAttributeServiceI
         // -------------------------------------------------------------------
 
         connection.add( getTestSubentry3( "cn=testsubentry3,ou=system" ) );
-        entries = getAllEntries( connection );
+        entries = getAllEntries( connection, false );
 
         // the new attribute c-st should appear in the node with the c-ou exclusion
         entry = entries.get( "ou=services,ou=configuration,ou=system" );
@@ -469,7 +478,7 @@ public class CollectiveAttributeServiceI
             "collectiveExclusions", "excludeAllCollectiveAttributes" ) );
         connection.modify( "ou=interceptors,ou=configuration, ou=system", modification );
 
-        entries = getAllEntries( connection );
+        entries = getAllEntries( connection, false );
 
         // none of the attributes should appear any longer
         entry = entries.get( "ou=interceptors,ou=configuration,ou=system" );

Modified: directory/apacheds/trunk/core-integ/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/resources/log4j.properties?rev=1486550&r1=1486549&r2=1486550&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/resources/log4j.properties (original)
+++ directory/apacheds/trunk/core-integ/src/test/resources/log4j.properties Mon May 27 09:40:38
2013
@@ -33,3 +33,4 @@ log4j.logger.org.apache.directory.api=FA
 log4j.logger.org.apache.directory.server=FATAL
 log4j.logger.net.sf.ehcache=FATAL
 log4j.logger.org.apache.mina=FATAL
+log4j.logger.org.apache.directory.server.core.collective.CollectiveAttributeInterceptor=DEBUG
\ No newline at end of file

Modified: directory/apacheds/trunk/interceptors/collective/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/collective/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java?rev=1486550&r1=1486549&r2=1486550&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/collective/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
(original)
+++ directory/apacheds/trunk/interceptors/collective/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
Mon May 27 09:40:38 2013
@@ -92,8 +92,8 @@ public class CollectiveAttributeIntercep
 
             return true;
         }
-        
-        
+
+
         /**
          * {@inheritDoc}
          */
@@ -147,7 +147,7 @@ public class CollectiveAttributeIntercep
         {
             return result;
         }
-        
+
         // Adding the collective attributes if any
         addCollectiveAttributes( lookupContext, result );
 
@@ -174,7 +174,7 @@ public class CollectiveAttributeIntercep
         EntryFilteringCursor cursor = next( searchContext );
 
         // only add collective attributes for non-syncrepl search
-        if( !searchContext.isSyncreplSearch() )
+        if ( !searchContext.isSyncreplSearch() )
         {
             cursor.addEntryFilter( SEARCH_FILTER );
         }
@@ -342,6 +342,7 @@ public class CollectiveAttributeIntercep
             return;
         }
 
+        LOG.debug( "Filtering entry " + entry.getDn() );
         /*
          * Before we proceed we need to lookup the exclusions within the entry
          * and build a set of exclusions for rapid lookup.  We use OID values
@@ -350,10 +351,12 @@ public class CollectiveAttributeIntercep
          */
         Attribute collectiveExclusions = ( ( ClonedServerEntry ) entry ).getOriginalEntry().get(
             COLLECTIVE_EXCLUSIONS_AT );
-        Set<String> exclusions = new HashSet<String>();
+        Set<AttributeType> exclusions = new HashSet<AttributeType>();
 
         if ( collectiveExclusions != null )
         {
+            LOG.debug( "The entry has some exclusions : {}", collectiveExclusions );
+
             if ( collectiveExclusions.contains( SchemaConstants.EXCLUDE_ALL_COLLECTIVE_ATTRIBUTES_AT_OID
)
                 || collectiveExclusions.contains( SchemaConstants.EXCLUDE_ALL_COLLECTIVE_ATTRIBUTES_AT
) )
             {
@@ -361,15 +364,15 @@ public class CollectiveAttributeIntercep
                  * This entry does not allow any collective attributes
                  * to be injected into itself.
                  */
+                LOG.debug( "The entry excludes all the collectiveAttributes" );
                 return;
             }
 
-            exclusions = new HashSet<String>();
-
             for ( Value<?> value : collectiveExclusions )
             {
                 AttributeType attrType = schemaManager.lookupAttributeTypeRegistry( value.getString()
);
-                exclusions.add( attrType.getOid() );
+                exclusions.add( attrType );
+                LOG.debug( "Adding {} in the list of excluded collectiveAttributes", attrType.getName()
);
             }
         }
 
@@ -383,6 +386,8 @@ public class CollectiveAttributeIntercep
             String subentryDnStr = value.getString();
             Dn subentryDn = session.getDirectoryService().getDnFactory().create( subentryDnStr
);
 
+            LOG.debug( "Applying subentries {}", subentryDn.getName() );
+
             /*
              * TODO - Instead of hitting disk here can't we leverage the
              * SubentryService to get us cached sub-entries so we're not
@@ -394,14 +399,17 @@ public class CollectiveAttributeIntercep
                 SchemaConstants.ALL_ATTRIBUTES_ARRAY );
             Entry subentry = session.getDirectoryService().getPartitionNexus().lookup( lookupContext
);
 
+            //LOG.debug( "Fetched the subentry : {}", subentry.getDn().getName() );
+
             for ( Attribute attribute : subentry.getAttributes() )
             {
                 AttributeType attributeType = attribute.getAttributeType();
-                String attrId = attributeType.getName();
+                //String attrId = attributeType.getName();
 
-                // Skip the attributes which are not collectve
+                // Skip the attributes which are not collective
                 if ( !attributeType.isCollective() )
                 {
+                    //LOG.debug( "The {} subentry attribute is not collective", attributeType.getName()
);
                     continue;
                 }
 
@@ -409,8 +417,10 @@ public class CollectiveAttributeIntercep
                  * Skip the addition of this collective attribute if it is excluded
                  * in the 'collectiveAttributes' attribute.
                  */
-                if ( exclusions.contains( attributeType.getOid() ) )
+                if ( exclusions.contains( attributeType ) )
                 {
+                    LOG.debug( "The {} subentry attribute has been removed, it's in the exclusion
list",
+                        attributeType.getName() );
                     continue;
                 }
 
@@ -420,18 +430,20 @@ public class CollectiveAttributeIntercep
                  */
                 if ( !opContext.isAllUserAttributes() && !opContext.contains( schemaManager,
attributeType ) )
                 {
+                    LOG.debug( "The {} subentry attribute is not in the list of attributes
to return",
+                        attributeType.getName() );
                     continue;
                 }
 
-                Attribute subentryColAttr = subentry.get( attrId );
-                Attribute entryColAttr = entry.get( attrId );
+                Attribute subentryColAttr = subentry.get( attributeType );
+                Attribute entryColAttr = entry.get( attributeType );
 
                 /*
                  * If entry does not have attribute for collective attribute then create
it.
                  */
                 if ( entryColAttr == null )
                 {
-                    entryColAttr = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry(
attrId ) );
+                    entryColAttr = new DefaultAttribute( attributeType );
                     entry.put( entryColAttr );
                 }
 
@@ -441,6 +453,7 @@ public class CollectiveAttributeIntercep
                  */
                 for ( Value<?> subentryColVal : subentryColAttr )
                 {
+                    LOG.debug( "Adding the {} collective attribute into the entry", subentryColAttr
);
                     entryColAttr.add( subentryColVal.getString() );
                 }
             }



Mime
View raw message