directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1225696 [4/5] - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/ core-api/src/main/java/org/apache/directory/server/core/api/filtering/ core-api/src/main/java/org/apache/directory/...
Date Thu, 29 Dec 2011 23:54:20 GMT
Modified: directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java?rev=1225696&r1=1225695&r2=1225696&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java Thu Dec 29 23:54:19 2011
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.core.schema;
 
+
 import java.io.File;
 
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
@@ -27,6 +28,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.util.Strings;
 import org.junit.Before;
 
+
 /**
  * A common class for all the MetaXXXHandler test classes
  *
@@ -36,6 +38,7 @@ public abstract class AbstractMetaSchema
 {
     protected static String workingDir;
 
+
     @Before
     public void init() throws Exception
     {

Modified: directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaServiceIT.java?rev=1225696&r1=1225695&r2=1225696&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaServiceIT.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaServiceIT.java Thu Dec 29 23:54:19 2011
@@ -21,7 +21,6 @@ package org.apache.directory.server.core
 
 
 import static org.apache.directory.server.core.integ.IntegrationUtils.getRootContext;
-import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
 import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -44,14 +43,18 @@ import javax.naming.directory.SearchCont
 import javax.naming.directory.SearchResult;
 import javax.naming.ldap.LdapContext;
 
+import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.integ.IntegrationUtils;
+import org.apache.directory.shared.ldap.model.cursor.EntryCursor;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.exception.LdapOtherException;
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.model.ldif.LdifReader;
+import org.apache.directory.shared.ldap.model.message.SearchScope;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -62,25 +65,25 @@ import org.junit.runner.RunWith;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-@ApplyLdifs( {
-    // Entry # 1
-    "dn: cn=person0,ou=system",
-    "objectClass: person",
-    "cn: person0",
-    "sn: sn_person0\n",
-    // Entry # 2
-    "dn: cn=person1,ou=system",
-    "objectClass: organizationalPerson",
-    "cn: person1",
-    "sn: sn_person1",
-    "seealso: cn=Good One,ou=people,o=sevenSeas",
-    //"seealso:: Y249QmFkIEXDqWvDoCxvdT1wZW9wbGUsbz1zZXZlblNlYXM=\n",
-    // Entry # 3
-    "dn: cn=person2,ou=system",
-    "objectClass: inetOrgPerson",
-    "cn: person2",
-    "sn: sn_person2" }
-    )
+@ApplyLdifs(
+    {
+        // Entry # 1
+        "dn: cn=person0,ou=system",
+        "objectClass: person",
+        "cn: person0",
+        "sn: sn_person0\n",
+        // Entry # 2
+        "dn: cn=person1,ou=system",
+        "objectClass: organizationalPerson",
+        "cn: person1",
+        "sn: sn_person1",
+        "seealso: cn=Good One,ou=people,o=sevenSeas",
+        //"seealso:: Y249QmFkIEXDqWvDoCxvdT1wZW9wbGUsbz1zZXZlblNlYXM=\n",
+        // Entry # 3
+        "dn: cn=person2,ou=system",
+        "objectClass: inetOrgPerson",
+        "cn: person2",
+        "sn: sn_person2" })
 @RunWith(FrameworkRunner.class)
 @CreateDS(name = "SchemaServiceIT")
 public class SchemaServiceIT extends AbstractLdapTestUnit
@@ -97,7 +100,7 @@ public class SchemaServiceIT extends Abs
         Attributes attrs = new BasicAttributes( "objectClass", "top", true );
         attrs.get( "objectClass" ).add( "uidObject" );
         attrs.put( "uid", "invalid" );
-        
+
         try
         {
             getSystemContext( getService() ).createSubcontext( "uid=invalid", attrs );
@@ -106,8 +109,8 @@ public class SchemaServiceIT extends Abs
         {
         }
     }
-    
-    
+
+
     /**
      * For <a href="https://issues.apache.org/jira/browse/DIRSERVER-925">DIRSERVER-925</a>.
      *
@@ -122,7 +125,7 @@ public class SchemaServiceIT extends Abs
         attrs.put( "ou", "comedy" );
         attrs.put( "cn", "Jack Black" );
         attrs.put( "sn", "Black" );
-        
+
         try
         {
             getSystemContext( getService() ).createSubcontext( "cn=Jack Black", attrs );
@@ -131,8 +134,8 @@ public class SchemaServiceIT extends Abs
         {
         }
     }
-    
-    
+
+
     /**
      * For <a href="https://issues.apache.org/jira/browse/DIRSERVER-904">DIRSERVER-904</a>.
      *
@@ -174,26 +177,26 @@ public class SchemaServiceIT extends Abs
         LdifEntry numberOfGunsAttrEntry = ldifReader.next();
         LdifEntry shipOCEntry = ldifReader.next();
         assertFalse( ldifReader.hasNext() );
-        
+
         // should be fine with unique OID
-        getService().getAdminSession().add( 
-            new DefaultEntry( getService().getSchemaManager(), numberOfGunsAttrEntry.getEntry() ) ); 
+        getService().getAdminSession().add(
+            new DefaultEntry( getService().getSchemaManager(), numberOfGunsAttrEntry.getEntry() ) );
 
         // should blow chuncks using same OID
         try
         {
-            getService().getAdminSession().add( 
-                new DefaultEntry( getService().getSchemaManager(), shipOCEntry.getEntry() ) ); 
-            
+            getService().getAdminSession().add(
+                new DefaultEntry( getService().getSchemaManager(), shipOCEntry.getEntry() ) );
+
             fail( "Should not be possible to create two schema entities with the same OID." );
         }
-        catch( LdapOtherException e )
+        catch ( LdapOtherException e )
         {
             assertTrue( true );
         }
     }
-    
-    
+
+
     /**
      * Test that we have all the needed ObjectClasses
      * 
@@ -237,7 +240,7 @@ public class SchemaServiceIT extends Abs
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         Map<String, Attributes> persons = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = sysRoot.search( "", "(objectClass=*person)", controls );
-        
+
         while ( results.hasMore() )
         {
             SearchResult result = results.next();
@@ -281,7 +284,7 @@ public class SchemaServiceIT extends Abs
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         Map<String, Attributes> orgPersons = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = sysRoot.search( "", "(objectClass=organizationalPerson)", controls );
-        
+
         while ( results.hasMore() )
         {
             SearchResult result = results.next();
@@ -318,7 +321,7 @@ public class SchemaServiceIT extends Abs
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         Map<String, Attributes> inetOrgPersons = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = sysRoot.search( "", "(objectClass=inetOrgPerson)", controls );
-        
+
         while ( results.hasMore() )
         {
             SearchResult result = results.next();
@@ -344,9 +347,10 @@ public class SchemaServiceIT extends Abs
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.OBJECT_SCOPE );
-        
+
         Map<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
-        NamingEnumeration<SearchResult> results = getRootContext( getService() ).search( "cn=schema", "(objectClass=*)", controls );
+        NamingEnumeration<SearchResult> results = getRootContext( getService() ).search( "cn=schema",
+            "(objectClass=*)", controls );
 
         while ( results.hasMore() )
         {
@@ -356,18 +360,18 @@ public class SchemaServiceIT extends Abs
 
         // We should have only one entry in the result
         assertEquals( 1, subSchemaEntry.size() );
-        
+
         // It should be the normalized form of cn=schema
         Attributes attrs = subSchemaEntry.get( "cn=schema" );
-        
+
         assertNotNull( attrs );
-        
+
         // We should have 2 attributes in the result :
         // - attributeTypes
         // - cn
         // - objectClass
         assertEquals( 2, attrs.size() );
-        
+
         assertNotNull( attrs.get( "cn" ) );
         assertNotNull( attrs.get( "objectClass" ) );
     }
@@ -378,11 +382,12 @@ public class SchemaServiceIT extends Abs
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.OBJECT_SCOPE );
-        controls.setReturningAttributes( new String[]{ "*", "+" } );
-        
+        controls.setReturningAttributes( new String[]
+            { "*", "+" } );
+
         Map<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = getRootContext( getService() ).search(
-                "cn=schema", "(objectClass=*)", controls );
+            "cn=schema", "(objectClass=*)", controls );
 
         while ( results.hasMore() )
         {
@@ -392,26 +397,27 @@ public class SchemaServiceIT extends Abs
 
         // We should have only one entry in the result
         assertEquals( 1, subSchemaEntry.size() );
-        
+
         // It should be the normalized form of cn=schema
         Attributes attrs = subSchemaEntry.get( "cn=schema" );
-        
+
         assertNotNull( attrs );
-        
+
         assertNotNull( attrs.get( "nameForms" ) );
     }
 
-    
+
     @Test
     public void testSearchForSubSchemaSubEntrySingleAttributeSelected() throws Exception
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.OBJECT_SCOPE );
-        controls.setReturningAttributes( new String[]{ "nameForms" } );
-        
+        controls.setReturningAttributes( new String[]
+            { "nameForms" } );
+
         Map<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = getRootContext( getService() )
-                .search( "cn=schema", "(objectClass=*)", controls );
+            .search( "cn=schema", "(objectClass=*)", controls );
 
         while ( results.hasMore() )
         {
@@ -421,16 +427,16 @@ public class SchemaServiceIT extends Abs
 
         // We should have only one entry in the result
         assertEquals( 1, subSchemaEntry.size() );
-        
+
         // It should be the normalized form of cn=schema
         Attributes attrs = subSchemaEntry.get( "cn=schema" );
-        
+
         assertNotNull( attrs );
-        
+
         // We should have 1 attribute in the result :
         // - nameForms
         assertEquals( 1, attrs.size() );
-        
+
         assertNull( attrs.get( "attributeTypes" ) );
         assertNull( attrs.get( "cn" ) );
         assertNull( attrs.get( "creatorsName" ) );
@@ -447,7 +453,7 @@ public class SchemaServiceIT extends Abs
         assertNull( attrs.get( "objectClasses" ) );
     }
 
-    
+
     /**
      * Test for DIRSERVER-1055.
      * Check if modifyTimestamp and createTimestamp are present in the search result,
@@ -460,28 +466,28 @@ public class SchemaServiceIT extends Abs
         controls.setSearchScope( SearchControls.OBJECT_SCOPE );
         controls.setReturningAttributes( new String[]
             { "creatorsName", "createTimestamp", "modifiersName", "modifyTimestamp" } );
-        
+
         Map<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = getRootContext( getService() )
-        .search( "cn=schema", "(objectClass=subschema)", controls );
-        
+            .search( "cn=schema", "(objectClass=subschema)", controls );
+
         while ( results.hasMore() )
         {
             SearchResult result = results.next();
             subSchemaEntry.put( result.getName(), result.getAttributes() );
         }
-        
+
         // We should have only one entry in the result
         assertEquals( 1, subSchemaEntry.size() );
-        
+
         // It should be the normalized form of cn=schema
         Attributes attrs = subSchemaEntry.get( "cn=schema" );
-        
+
         assertNotNull( attrs );
-        
+
         // We should have 4 attribute in the result :
         assertEquals( 4, attrs.size() );
-        
+
         assertNull( attrs.get( "attributeTypes" ) );
         assertNull( attrs.get( "cn" ) );
         assertNotNull( attrs.get( "creatorsName" ) );
@@ -504,11 +510,12 @@ public class SchemaServiceIT extends Abs
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.OBJECT_SCOPE );
-        controls.setReturningAttributes( new String[]{ "+" } );
-        
+        controls.setReturningAttributes( new String[]
+            { "+" } );
+
         Map<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = getRootContext( getService() )
-                .search( "cn=schema", "(objectClass=nothing)", controls );
+            .search( "cn=schema", "(objectClass=nothing)", controls );
 
         while ( results.hasMore() )
         {
@@ -526,11 +533,12 @@ public class SchemaServiceIT extends Abs
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.OBJECT_SCOPE );
-        controls.setReturningAttributes( new String[]{ "*", "+" } );
-        
+        controls.setReturningAttributes( new String[]
+            { "*", "+" } );
+
         Map<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = getRootContext( getService() )
-                .search( "cn=schema", "(objectClass=top)", controls );
+            .search( "cn=schema", "(objectClass=top)", controls );
 
         while ( results.hasMore() )
         {
@@ -540,19 +548,19 @@ public class SchemaServiceIT extends Abs
 
         // We should have only one entry in the result
         assertEquals( 1, subSchemaEntry.size() );
-        
+
         // It should be the normalized form of cn=schema
         Attributes attrs = subSchemaEntry.get( "cn=schema" );
-        
+
         assertNotNull( attrs );
-        
+
         // We should have 18 attribute in the result :
         // - nameForms
         // - comparators
         // - normalizers
         // - syntaxCheckers
         assertEquals( 18, attrs.size() );
-        
+
         assertNotNull( attrs.get( "attributeTypes" ) );
         assertNotNull( attrs.get( "cn" ) );
         assertNotNull( attrs.get( "comparators" ) );
@@ -579,11 +587,12 @@ public class SchemaServiceIT extends Abs
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.OBJECT_SCOPE );
-        controls.setReturningAttributes( new String[]{ "*", "+" } );
-        
+        controls.setReturningAttributes( new String[]
+            { "*", "+" } );
+
         Map<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = getRootContext( getService() )
-                .search( "cn=schema", "(objectClass=subSchema)", controls );
+            .search( "cn=schema", "(objectClass=subSchema)", controls );
 
         while ( results.hasMore() )
         {
@@ -593,19 +602,19 @@ public class SchemaServiceIT extends Abs
 
         // We should have only one entry in the result
         assertEquals( 1, subSchemaEntry.size() );
-        
+
         // It should be the normalized form of cn=schema
         Attributes attrs = subSchemaEntry.get( "cn=schema" );
-        
+
         assertNotNull( attrs );
-        
+
         // We should have 18 attribute in the result :
         // - nameForms
         // - comparators
         // - normalizers
         // - syntaxCheckers
         assertEquals( 18, attrs.size() );
-        
+
         assertNotNull( attrs.get( "attributeTypes" ) );
         assertNotNull( attrs.get( "cn" ) );
         assertNotNull( attrs.get( "subtreeSpecification" ) );
@@ -629,11 +638,12 @@ public class SchemaServiceIT extends Abs
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-        controls.setReturningAttributes( new String[]{ "+" } );
-        
+        controls.setReturningAttributes( new String[]
+            { "+" } );
+
         Map<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = getRootContext( getService() )
-                .search( "cn=schema", "(objectClass=nothing)", controls );
+            .search( "cn=schema", "(objectClass=nothing)", controls );
 
         while ( results.hasMore() )
         {
@@ -651,11 +661,12 @@ public class SchemaServiceIT extends Abs
     {
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-        controls.setReturningAttributes( new String[]{ "+" } );
-        
+        controls.setReturningAttributes( new String[]
+            { "+" } );
+
         Map<String, Attributes> subSchemaEntry = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = getRootContext( getService() )
-                .search( "cn=schema", "(&(objectClass=*)(objectClass=top))", controls );
+            .search( "cn=schema", "(&(objectClass=*)(objectClass=top))", controls );
 
         while ( results.hasMore() )
         {
@@ -680,7 +691,7 @@ public class SchemaServiceIT extends Abs
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         Map<String, Attributes> persons = new HashMap<String, Attributes>();
         NamingEnumeration<SearchResult> results = getSystemContext( getService() )
-                    .search( "", "(seeAlso=cn=Good One,ou=people,o=sevenSeas)", controls );
+            .search( "", "(seeAlso=cn=Good One,ou=people,o=sevenSeas)", controls );
 
         while ( results.hasMore() )
         {
@@ -702,7 +713,7 @@ public class SchemaServiceIT extends Abs
         assertTrue( ocs.contains( "person" ) );
         assertTrue( ocs.contains( "organizationalPerson" ) );
 
-        Attribute seeAlso = person.get(  "seeAlso"  );
+        Attribute seeAlso = person.get( "seeAlso" );
         assertTrue( seeAlso.contains( "cn=Good One,ou=people,o=sevenSeas" ) );
         //assertTrue( seeAlso.contains( "cn=Bad E\u00e9k\u00e0,ou=people,o=sevenSeas" ) );
     }
@@ -720,11 +731,12 @@ public class SchemaServiceIT extends Abs
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         Map<String, Attributes> persons = new HashMap<String, Attributes>();
-        controls.setReturningAttributes( new String[] { "9.9.9" } );
+        controls.setReturningAttributes( new String[]
+            { "9.9.9" } );
 
         NamingEnumeration<SearchResult> results = getSystemContext( getService() )
-                .search( "", "(objectClass=person)", controls );
-        
+            .search( "", "(objectClass=person)", controls );
+
         while ( results.hasMore() )
         {
             SearchResult result = results.next();
@@ -741,7 +753,7 @@ public class SchemaServiceIT extends Abs
         assertNotNull( person );
         ocs = person.get( "objectClass" );
         assertNull( ocs );
-        
+
         ocs = person.get( "9.9.9" );
         assertNull( ocs );
 
@@ -756,7 +768,7 @@ public class SchemaServiceIT extends Abs
         assertNull( ocs );
     }
 
-    
+
     /**
      * Check that if we request a Attribute which is not an AttributeType,
      * we still get a result
@@ -769,11 +781,12 @@ public class SchemaServiceIT extends Abs
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         Map<String, Attributes> persons = new HashMap<String, Attributes>();
-        controls.setReturningAttributes( new String[] { "2.5.6.6" } );
+        controls.setReturningAttributes( new String[]
+            { "2.5.6.6" } );
 
         NamingEnumeration<SearchResult> results = getSystemContext( getService() )
-                .search( "", "(objectClass=person)", controls );
-        
+            .search( "", "(objectClass=person)", controls );
+
         while ( results.hasMore() )
         {
             SearchResult result = results.next();
@@ -790,7 +803,7 @@ public class SchemaServiceIT extends Abs
         assertNotNull( person );
         ocs = person.get( "objectClass" );
         assertNull( ocs );
-        
+
         // We should not get this attribute (it's an ObjectClass)
         ocs = person.get( "2.5.6.6" );
         assertNull( ocs );
@@ -806,7 +819,7 @@ public class SchemaServiceIT extends Abs
         assertNull( ocs );
     }
 
-    
+
     /**
      * Check that if we request a Attribute which is an ObjectClass.
      *
@@ -818,11 +831,12 @@ public class SchemaServiceIT extends Abs
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         Map<String, Attributes> persons = new HashMap<String, Attributes>();
-        controls.setReturningAttributes( new String[] { "person" } );
+        controls.setReturningAttributes( new String[]
+            { "person" } );
 
         NamingEnumeration<SearchResult> results = getSystemContext( getService() )
-                .search( "", "(objectClass=person)", controls );
-        
+            .search( "", "(objectClass=person)", controls );
+
         while ( results.hasMore() )
         {
             SearchResult result = results.next();
@@ -839,7 +853,7 @@ public class SchemaServiceIT extends Abs
         assertNotNull( person );
         ocs = person.get( "objectClass" );
         assertNull( ocs );
-        
+
         // We should not get this attrinute (it's an ObjectClass)
         ocs = person.get( "2.5.4.46" );
         assertNull( ocs );
@@ -872,7 +886,7 @@ public class SchemaServiceIT extends Abs
         Map<String, Attributes> persons = new HashMap<String, Attributes>();
 
         NamingEnumeration<SearchResult> results = sysRoot.search( "", "(name=person*)", controls );
-        
+
         while ( results.hasMore() )
         {
             SearchResult result = results.next();
@@ -905,9 +919,8 @@ public class SchemaServiceIT extends Abs
         assertTrue( ocs.contains( "organizationalPerson" ) );
         assertTrue( ocs.contains( "inetOrgPerson" ) );
     }
-    
-    
-    
+
+
     /**
      * Search all the entries with a 'metaTop' ObjectClass, or an ObjectClass
      * inheriting from 'metaTop' 
@@ -917,22 +930,18 @@ public class SchemaServiceIT extends Abs
     @Test
     public void testSearchForMetaTop() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        
-        SearchControls controls = new SearchControls();
-        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> results = schemaRoot.search( "", "(objectClass=top)", controls );
-        assertTrue( "Expected some results", results.hasMore() );
-        
-        controls = new SearchControls();
-        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        results = schemaRoot.search( "", "(objectClass=metaAttributeType)", controls );
-        assertTrue( "Expected some results", results.hasMore() );
-        
-        controls = new SearchControls();
-        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        results = schemaRoot.search( "", "(objectClass=metaTop)", controls );
-        assertTrue( "Expected some results", results.hasMore() );
+        LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
+
+        EntryCursor cursor = connection.search( "ou=schema", "(objectClass=top)", SearchScope.SUBTREE, "*" );
+        assertTrue( "Expected some results", cursor.next() );
+        cursor.close();
+
+        cursor = connection.search( "ou=schema", "(objectClass=metaAttributeType)", SearchScope.SUBTREE, "*" );
+        assertTrue( "Expected some results", cursor.next() );
+        cursor.close();
+
+        cursor = connection.search( "ou=schema", "(objectClass=metaTop)", SearchScope.SUBTREE, "*" );
+        assertTrue( "Expected some results", cursor.next() );
+        cursor.close();
     }
-    
 }

Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java?rev=1225696&r1=1225695&r2=1225696&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java Thu Dec 29 23:54:19 2011
@@ -86,12 +86,14 @@ public class DefaultOperationExecutionMa
     /** Txn manager Factory */
     private TxnManagerFactory txnManagerFactory;
 
-    public DefaultOperationExecutionManager( TxnManagerFactory txnManagerFactory  )
+
+    public DefaultOperationExecutionManager( TxnManagerFactory txnManagerFactory )
     {
         this.txnManagerFactory = txnManagerFactory;
         txnLogManager = txnManagerFactory.txnLogManagerInstance();
     }
-    
+
+
     //---------------------------------------------------------------------------------------------
     // The Add operation
     //---------------------------------------------------------------------------------------------
@@ -269,20 +271,20 @@ public class DefaultOperationExecutionMa
 
             // Add the parentId in the entry
             entry.put( SchemaConstants.ENTRY_PARENT_ID_AT, parentId.toString() );
-            
+
             // Add the dn
             entry.setDn( entryDn );
 
             // And finally prepare the entry change
             EntryAddDelete entryAdd = new EntryAddDelete( entry, EntryAddDelete.Type.ADD );
             changeContainer.addChange( entryAdd );
-            
+
             // Set the modified entry
             addContext.setModifiedEntry( entry );
 
             // log the change
             txnLogManager.log( changeContainer, false );
-            
+
             //TODO TODO TODO REMOVE THIS
             partition.add( addContext );
         }
@@ -304,12 +306,12 @@ public class DefaultOperationExecutionMa
      * {@inheritDoc}
      */
     public void delete( Partition partition, DeleteOperationContext deleteContext ) throws LdapException
-    {        
+    {
         Dn dn = deleteContext.getDn();
 
         //TODO TODO TODO REMOVE THIS
         partition.delete( deleteContext );
-        
+
         // Add write dependency on the dn
         txnLogManager.addWrite( dn, SearchScope.SUBTREE );
 
@@ -508,7 +510,7 @@ public class DefaultOperationExecutionMa
                 modifyContext.getModItems().toArray( new Modification[]
                     {} ) );
             modifyContext.setAlteredEntry( modifiedEntry );
-            
+
             //TODO TODO TODO REMOVE THIS
             partition.modify( modifyContext );
 
@@ -558,14 +560,14 @@ public class DefaultOperationExecutionMa
                     throw new LdapException( I18n.err( I18n.ERR_221 ) );
             }
         }
-        
+
         // For now use and EntryReplace change
         EntryReplace entryReplace = new EntryReplace( entry, originalEntry );
         changeContainer.addChange( entryReplace );
 
         // log the changes
         txnLogManager.log( changeContainer, false );
-        
+
         return entry;
     }
 
@@ -633,17 +635,17 @@ public class DefaultOperationExecutionMa
             }
         }
 
-//        // create log edit for the entry change
-//        Modification undo = null;
-//
-//        if ( prevValueExists )
-//        {
-//            undo = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, changedAttribute );
-//        }
-//
-//        EntryChange entryChange = new EntryChange( mod, null );
-//        changeContainer.addChange( entryChange );
-        
+        //        // create log edit for the entry change
+        //        Modification undo = null;
+        //
+        //        if ( prevValueExists )
+        //        {
+        //            undo = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, changedAttribute );
+        //        }
+        //
+        //        EntryChange entryChange = new EntryChange( mod, null );
+        //        changeContainer.addChange( entryChange );
+
         // add all the values in mods to the same attribute in the entry
         for ( Value<?> value : mods )
         {
@@ -794,17 +796,17 @@ public class DefaultOperationExecutionMa
             dropAliasIndices( partition, entryDn, id, null, changeContainer );
         }
 
-//        // create log edit for the entry change
-//        Modification undo = null;
-//
-//        if ( prevValueExists )
-//        {
-//            undo = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, replacedAttribute );
-//        }
-//
-//        EntryChange entryChange = new EntryChange( mod, undo );
-//        changeContainer.addChange( entryChange );
-        
+        //        // create log edit for the entry change
+        //        Modification undo = null;
+        //
+        //        if ( prevValueExists )
+        //        {
+        //            undo = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, replacedAttribute );
+        //        }
+        //
+        //        EntryChange entryChange = new EntryChange( mod, undo );
+        //        changeContainer.addChange( entryChange );
+
         // replaces old attributes with new modified ones if they exist
         if ( mods.size() > 0 )
         {
@@ -964,17 +966,17 @@ public class DefaultOperationExecutionMa
             }
         }
 
-//        // Prepare the entry change
-//        Modification undo = null;
-//
-//        if ( prevValueExists )
-//        {
-//            undo = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, changedAttribute );
-//        }
-//
-//        EntryChange entryChange = new EntryChange( mod, undo );
-//        changeContainer.addChange( entryChange );
-        
+        //        // Prepare the entry change
+        //        Modification undo = null;
+        //
+        //        if ( prevValueExists )
+        //        {
+        //            undo = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, changedAttribute );
+        //        }
+        //
+        //        EntryChange entryChange = new EntryChange( mod, undo );
+        //        changeContainer.addChange( entryChange );
+
         /*
          * If there are no attribute values in the modifications then this
          * implies the complete removal of the attribute from the entry. Else
@@ -1022,11 +1024,11 @@ public class DefaultOperationExecutionMa
             Dn oldDn = renameContext.getDn();
             Rdn newRdn = renameContext.getNewRdn();
             boolean deleteOldRdn = renameContext.getDeleteOldRdn();
-            Entry originalEntry = ( ( ClonedServerEntry )renameContext.getOriginalEntry() );
-            
+            Entry originalEntry = ( ( ClonedServerEntry ) renameContext.getOriginalEntry() );
+
             if ( originalEntry != null )
             {
-                originalEntry = ( ( ClonedServerEntry )originalEntry ).getOriginalEntry();
+                originalEntry = ( ( ClonedServerEntry ) originalEntry ).getOriginalEntry();
             }
 
             if ( renameContext.getEntry() != null )
@@ -1038,7 +1040,7 @@ public class DefaultOperationExecutionMa
             {
                 rename( partition, oldDn, newRdn, deleteOldRdn, null, originalEntry );
             }
-            
+
             //TODO TODO TODO REMOVE THIS
             partition.rename( renameContext );
         }
@@ -1053,7 +1055,8 @@ public class DefaultOperationExecutionMa
      * {@inheritDoc}
      */
     @SuppressWarnings("unchecked")
-    public void rename( Partition partition, Dn dn, Rdn newRdn, boolean deleteOldRdn, Entry entry, Entry originalEntry ) throws Exception
+    public void rename( Partition partition, Dn dn, Rdn newRdn, boolean deleteOldRdn, Entry entry, Entry originalEntry )
+        throws Exception
     {
         if ( partition.updateEntryOnDnChange() )
         {
@@ -1063,7 +1066,7 @@ public class DefaultOperationExecutionMa
             newDn.apply( partition.getSchemaManager() );
             handleDnChange( partition, dn, newDn, id );
         }
-        
+
         renameInternal( partition, dn, newRdn, deleteOldRdn, entry, originalEntry );
     }
 
@@ -1359,15 +1362,15 @@ public class DefaultOperationExecutionMa
             Dn newSuperior = moveContext.getNewSuperior();
             Dn newDn = moveContext.getNewDn();
             Entry modifiedEntry = moveContext.getModifiedEntry();
-            Entry originalEntry = ( ClonedServerEntry )moveContext.getOriginalEntry();
-            
+            Entry originalEntry = ( ClonedServerEntry ) moveContext.getOriginalEntry();
+
             if ( originalEntry != null )
             {
-                originalEntry = ( ( ClonedServerEntry )originalEntry ).getOriginalEntry();
+                originalEntry = ( ( ClonedServerEntry ) originalEntry ).getOriginalEntry();
             }
 
             move( partition, oldDn, newSuperior, newDn, modifiedEntry, originalEntry );
-            
+
             //TODO TODO TODO REMOVE THIS
             partition.move( moveContext );
 
@@ -1433,13 +1436,14 @@ public class DefaultOperationExecutionMa
         {
             modifiedEntry = originalEntry.clone();
         }
-        
+
         if ( partition.updateEntryOnDnChange() )
         {
             handleDnChange( partition, oldDn, newDn, entryId );
         }
-        
-        moveInternal( partition, oldDn, newSuperiorDn, newDn, modifiedEntry, originalEntry, newParentId, entryId, oldParentId, false );
+
+        moveInternal( partition, oldDn, newSuperiorDn, newDn, modifiedEntry, originalEntry, newParentId, entryId,
+            oldParentId, false );
     }
 
 
@@ -1465,11 +1469,11 @@ public class DefaultOperationExecutionMa
             Rdn newRdn = moveAndRenameContext.getNewRdn();
             boolean deleteOldRdn = moveAndRenameContext.getDeleteOldRdn();
             Entry modifiedEntry = moveAndRenameContext.getModifiedEntry();
-            Entry originalEntry = ( ClonedServerEntry )moveAndRenameContext.getOriginalEntry();
-            
+            Entry originalEntry = ( ClonedServerEntry ) moveAndRenameContext.getOriginalEntry();
+
             if ( originalEntry != null )
             {
-                originalEntry = ( ( ClonedServerEntry )originalEntry ).getOriginalEntry();
+                originalEntry = ( ( ClonedServerEntry ) originalEntry ).getOriginalEntry();
             }
 
             moveAndRename( partition, oldDn, newSuperiorDn, newRdn, modifiedEntry, originalEntry, deleteOldRdn );
@@ -1516,7 +1520,7 @@ public class DefaultOperationExecutionMa
         }
 
         Dn newDn = newSuperiorDn.add( newRdn );
-        
+
         UUID oldParentId = getParentId( partition, oldId );
 
         // Now check that the new entry does not exist
@@ -1544,19 +1548,20 @@ public class DefaultOperationExecutionMa
         {
             modifiedEntry = originalEntry.clone();
         }
-        
+
         if ( partition.updateEntryOnDnChange() )
         {
             handleDnChange( partition, oldDn, newDn, oldId );
         }
-        
+
         renameInternal( partition, oldDn, newRdn, deleteOldRdn, modifiedEntry, originalEntry );
-        
+
         Dn parentDn = oldDn.getParent();
         oldDn = new Dn( newRdn, parentDn );
         oldDn.apply( partition.getSchemaManager() );
-        
-        moveInternal( partition, oldDn, newSuperiorDn, newDn, modifiedEntry, originalEntry, newSuperiorId, oldId, oldParentId, true );
+
+        moveInternal( partition, oldDn, newSuperiorDn, newDn, modifiedEntry, originalEntry, newSuperiorId, oldId,
+            oldParentId, true );
     }
 
 
@@ -1679,8 +1684,8 @@ public class DefaultOperationExecutionMa
             throw new LdapOperationErrorException( e.getMessage(), e );
         }
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -1691,16 +1696,16 @@ public class DefaultOperationExecutionMa
             UUID id = getEntryId( partition, entryContext.getDn() );
 
             Entry entry = lookup( partition, id );
-            
-            return entry != null; 
+
+            return entry != null;
         }
         catch ( LdapException e )
         {
             return false;
         }
     }
-    
-    
+
+
     //---------------------------------------------------------------------------------------------
     // The List operation
     //---------------------------------------------------------------------------------------------
@@ -1711,10 +1716,10 @@ public class DefaultOperationExecutionMa
     {
         try
         {
-        return new BaseEntryFilteringCursor( 
-            new EntryCursorAdaptor( partition, 
-                list( partition, getEntryId( partition, listContext.getDn() ) ), 
-                txnManagerFactory ), listContext );
+            return new BaseEntryFilteringCursor(
+                new EntryCursorAdaptor( partition,
+                    list( partition, getEntryId( partition, listContext.getDn() ) ),
+                    txnManagerFactory ), listContext );
         }
         catch ( Exception e )
         {
@@ -1722,28 +1727,29 @@ public class DefaultOperationExecutionMa
         }
     }
 
-    
+
     public IndexCursor<UUID> list( Partition partition, UUID id ) throws LdapException
     {
         try
         {
-            Index<UUID> oneLevelIdx = ( Index<UUID> )partition.getSystemIndex( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
-            oneLevelIdx = ( Index<UUID> )txnLogManager.wrap( partition.getSuffixDn(), oneLevelIdx );
-            
+            Index<UUID> oneLevelIdx = ( Index<UUID> ) partition
+                .getSystemIndex( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
+            oneLevelIdx = ( Index<UUID> ) txnLogManager.wrap( partition.getSuffixDn(), oneLevelIdx );
+
             // We use the OneLevel index to get all the entries from a starting point
             // and below
             IndexCursor<UUID> cursor = oneLevelIdx.forwardCursor( id );
             cursor.beforeFirst();
-            
+
             return cursor;
-         }
+        }
         catch ( Exception e )
         {
             throw new LdapOperationErrorException( e.getMessage(), e );
         }
     }
 
-    
+
     //---------------------------------------------------------------------------------------------
     // ID and DN operations
     //---------------------------------------------------------------------------------------------
@@ -1834,17 +1840,18 @@ public class DefaultOperationExecutionMa
 
         return dn;
     }
-    
+
+
     private Entry getEntry( Partition partition, MasterTable wrappedTable, UUID id ) throws Exception
     {
         Entry entry = wrappedTable.get( id );
-        
+
         if ( entry != null )
         {
             Dn dn = buildEntryDn( partition, id );
             entry.setDn( dn );
         }
-        
+
         return entry;
     }
 
@@ -1867,8 +1874,8 @@ public class DefaultOperationExecutionMa
 
         return key.getParentId();
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -1880,15 +1887,15 @@ public class DefaultOperationExecutionMa
         {
             Index<?> oneLevelIdx = partition.getSystemIndex( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
             oneLevelIdx = txnLogManager.wrap( partition.getSuffixDn(), oneLevelIdx );
-            cursor =  ( ( Index<Object> ) oneLevelIdx ).forwardCursor( id );
-            
+            cursor = ( ( Index<Object> ) oneLevelIdx ).forwardCursor( id );
+
             int count = 0;
-            
+
             while ( cursor.next() )
             {
                 count++;
             }
-            
+
             return count;
         }
         catch ( Exception e )
@@ -2016,7 +2023,7 @@ public class DefaultOperationExecutionMa
 
 
     private void moveInternal( Partition partition, Dn oldDn, Dn newSuperiorDn, Dn newDn, Entry modifiedEntry,
-        Entry originalEntry, UUID newParentId, UUID entryId, UUID oldParentId, boolean afterRename  ) throws Exception
+        Entry originalEntry, UUID newParentId, UUID entryId, UUID oldParentId, boolean afterRename ) throws Exception
     {
         DataChangeContainer changeContainer = new DataChangeContainer( partition );
         changeContainer.setEntryID( entryId );
@@ -2091,9 +2098,11 @@ public class DefaultOperationExecutionMa
         // log the change
         txnLogManager.log( changeContainer, false );
     }
-    
+
+
     @SuppressWarnings("unchecked")
-    private void renameInternal( Partition partition, Dn dn, Rdn newRdn, boolean deleteOldRdn, Entry entry, Entry originalEntry )
+    private void renameInternal( Partition partition, Dn dn, Rdn newRdn, boolean deleteOldRdn, Entry entry,
+        Entry originalEntry )
         throws Exception
     {
         UUID id = getEntryId( partition, dn );
@@ -2112,7 +2121,7 @@ public class DefaultOperationExecutionMa
             // First get the entry
             originalEntry = getEntry( partition, master, id );
         }
-        
+
         if ( entry == null )
         {
             entry = originalEntry.clone();
@@ -2278,47 +2287,47 @@ public class DefaultOperationExecutionMa
         txnLogManager.log( changeContainer, false );
 
     }
-    
-    
+
+
     private void handleDnChange( Partition partition, Dn oldDn, Dn newDn, UUID baseId ) throws Exception
     {
-        Dn  suffixDn = partition.getSuffixDn();
+        Dn suffixDn = partition.getSuffixDn();
         SchemaManager schemaManager = partition.getSchemaManager();
         Index<?> subLevelIdx = partition.getSystemIndex( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID );
         subLevelIdx = txnLogManager.wrap( suffixDn, subLevelIdx );
-        
+
         MasterTable master = partition.getMasterTable();
         master = txnLogManager.wrap( partition.getSuffixDn(), master );
-        
+
         Entry childEntry;
         Entry clonedChildEntry;
         UUID childId;
         Dn childDn;
         Dn childNewDn = null;
         IndexCursor<UUID> cursor = ( ( Index<UUID> ) subLevelIdx ).forwardCursor( baseId );
-        
+
         try
         {
             while ( cursor.next() )
             {
                 childId = cursor.get().getId();
-                
+
                 // Skip base entry
-                
+
                 if ( UUIDComparator.INSTANCE.compare( baseId, childId ) == 0 )
                 {
                     continue;
                 }
-                
+
                 childEntry = getEntry( partition, master, childId );
                 clonedChildEntry = childEntry.clone();
-                
-                childDn = childEntry.getDn();                
+
+                childDn = childEntry.getDn();
                 int startIdx = childDn.size() - oldDn.size() - 1;
-                
+
                 for ( int idx = startIdx; idx >= 0; idx-- )
                 {
-                    if (  idx == startIdx )
+                    if ( idx == startIdx )
                     {
                         childNewDn = new Dn( childDn.getRdn( idx ), newDn );
                         childNewDn.apply( schemaManager );
@@ -2328,9 +2337,9 @@ public class DefaultOperationExecutionMa
                         childNewDn = childNewDn.add( childDn.getRdn( idx ) );
                     }
                 }
-                
+
                 clonedChildEntry.setDn( childNewDn );
-                
+
                 /*
                  * Prepare the log edit for the entry change
                  */

Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java?rev=1225696&r1=1225695&r2=1225696&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java Thu Dec 29 23:54:19 2011
@@ -45,8 +45,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.CompareOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext;
-import org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.GetRootDseOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.ListOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext;
@@ -107,7 +107,7 @@ public class DefaultPartitionNexus exten
 
     /** the fixed id: 'NEXUS' */
     private static final String ID = "NEXUS";
-    
+
     /** Speedup for logs */
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
@@ -138,15 +138,14 @@ public class DefaultPartitionNexus exten
     private final List<Modification> mods = new ArrayList<Modification>( 2 );
 
     private String lastSyncedCtxCsn = null;
-    
+
     /** The cn=schema Dn */
     private Dn subschemSubentryDn;
-    
+
     /** Operation Execution Manager */
     OperationExecutionManager operationExecutionManager;
 
 
-
     /**
      * Creates the root nexus singleton of the entire system.  The root DSE has
      * several attributes that are injected into it besides those that may
@@ -157,13 +156,14 @@ public class DefaultPartitionNexus exten
      * @param rootDse the root entry for the DSA
      * @throws javax.naming.Exception on failure to initialize
      */
-    public DefaultPartitionNexus( Entry rootDse, OperationExecutionManagerFactory executionManagerFactory ) throws Exception
+    public DefaultPartitionNexus( Entry rootDse, OperationExecutionManagerFactory executionManagerFactory )
+        throws Exception
     {
         id = ID;
         suffixDn = null;
-        
+
         operationExecutionManager = executionManagerFactory.instance();
-            
+
         // setup that root DSE
         this.rootDse = rootDse;
 
@@ -191,7 +191,7 @@ public class DefaultPartitionNexus exten
         }
 
         rootDse.put( SchemaConstants.VENDOR_VERSION_AT, props.getProperty( "apacheds.version", "UNKNOWN" ) );
-        
+
         // The rootDSE uuid has been randomly created
         rootDse.put( SchemaConstants.ENTRY_UUID_AT, "f290425c-8272-4e62-8a67-92b06f38dbf5" );
     }
@@ -204,33 +204,33 @@ public class DefaultPartitionNexus exten
     {
         // NOTE: We ignore ContextPartitionConfiguration parameter here.
         if ( !initialized )
-        {  
+        {
             // Add the supported controls
             Iterator<String> ctrlOidItr = directoryService.getLdapCodecService().registeredControls();
-            
+
             while ( ctrlOidItr.hasNext() )
             {
                 rootDse.add( SchemaConstants.SUPPORTED_CONTROL_AT, ctrlOidItr.next() );
             }
-    
+
             schemaManager = directoryService.getSchemaManager();
             ENTRY_CSN_AT = schemaManager.getAttributeType( SchemaConstants.ENTRY_CSN_AT );
             OBJECT_CLASS_AT = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT );
-    
+
             // Initialize and normalize the localy used DNs
             Dn adminDn = directoryService.getDnFactory().create( ServerDNConstants.ADMIN_SYSTEM_DN );
             adminDn.apply( schemaManager );
-    
+
             Value<?> attr = rootDse.get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
             subschemSubentryDn = directoryService.getDnFactory().create( attr.getString() );
-    
+
             //initializeSystemPartition( directoryService );
-    
+
             List<Partition> initializedPartitions = new ArrayList<Partition>();
-            
+
             initializedPartitions.add( 0, directoryService.getSystemPartition() );
             addContextPartition( directoryService.getSystemPartition() );
-    
+
             try
             {
                 for ( Partition partition : directoryService.getPartitions() )
@@ -238,9 +238,9 @@ public class DefaultPartitionNexus exten
                     addContextPartition( partition );
                     initializedPartitions.add( partition );
                 }
-    
+
                 createContextCsnModList();
-    
+
                 initialized = true;
             }
             finally
@@ -248,12 +248,12 @@ public class DefaultPartitionNexus exten
                 if ( !initialized )
                 {
                     Iterator<Partition> i = initializedPartitions.iterator();
-                    
+
                     while ( i.hasNext() )
                     {
                         Partition partition = i.next();
                         i.remove();
-                        
+
                         try
                         {
                             partition.destroy();
@@ -285,11 +285,11 @@ public class DefaultPartitionNexus exten
         if ( !system.hasEntry( new HasEntryOperationContext( adminSession, systemSuffixDn ) ) )
         {
             Entry systemEntry = new DefaultEntry( schemaManager, systemSuffixDn );
-            
+
             // Add the ObjectClasses
             systemEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC,
                 SchemaConstants.ORGANIZATIONAL_UNIT_OC, SchemaConstants.EXTENSIBLE_OBJECT_OC );
-            
+
             // Add some operational attributes
             systemEntry.put( SchemaConstants.CREATORS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN );
             systemEntry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
@@ -297,7 +297,7 @@ public class DefaultPartitionNexus exten
             systemEntry.add( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
             systemEntry.put( DnUtils.getRdnAttributeType( ServerDNConstants.SYSTEM_DN ), DnUtils
                 .getRdnValue( ServerDNConstants.SYSTEM_DN ) );
-            
+
             AddOperationContext addOperationContext = new AddOperationContext( adminSession, systemEntry );
             system.add( addOperationContext );
         }
@@ -347,7 +347,7 @@ public class DefaultPartitionNexus exten
         {
             try
             {
-                removeContextPartition(  directoryService.getDnFactory().create( suffix ) );
+                removeContextPartition( directoryService.getDnFactory().create( suffix ) );
             }
             catch ( Exception e )
             {
@@ -532,7 +532,7 @@ public class DefaultPartitionNexus exten
         }
 
         Partition partition = getPartition( dn );
-        
+
         return operationExecutionManager.hasEntry( partition, hasEntryContext );
     }
 
@@ -543,7 +543,7 @@ public class DefaultPartitionNexus exten
     public EntryFilteringCursor list( ListOperationContext listContext ) throws LdapException
     {
         Partition partition = getPartition( listContext.getDn() );
-        
+
         return operationExecutionManager.list( partition, listContext );
     }
 
@@ -564,9 +564,9 @@ public class DefaultPartitionNexus exten
         if ( dn.size() == 0 )
         {
             Entry retval = new ClonedServerEntry( schemaManager, rootDse );
-            
+
             return retval;
-            
+
             /*
             if ( ( lookupContext.getAttrsId() != null ) && !lookupContext.getAttrsId().isEmpty() )
             {
@@ -591,8 +591,8 @@ public class DefaultPartitionNexus exten
         }
 
         Partition partition = getPartition( dn );
-        Entry entry =  operationExecutionManager.lookup( partition, lookupContext );
-        
+        Entry entry = operationExecutionManager.lookup( partition, lookupContext );
+
         if ( entry == null )
         {
             LdapNoSuchObjectException e = new LdapNoSuchObjectException( "Attempt to lookup non-existant entry: "
@@ -619,9 +619,9 @@ public class DefaultPartitionNexus exten
         Partition partition = getPartition( modifyContext.getDn() );
 
         operationExecutionManager.modify( partition, modifyContext );
-        
+
         Entry alteredEntry = modifyContext.getAlteredEntry();
-        
+
         if ( alteredEntry != null )
         {
             directoryService.setContextCsn( alteredEntry.get( ENTRY_CSN_AT ).getString() );
@@ -771,7 +771,7 @@ public class DefaultPartitionNexus exten
             boolean isSearchAll = false;
 
             // We have to be careful, as we may have a filter which is not a PresenceFilter
-            if ( filter instanceof PresenceNode)
+            if ( filter instanceof PresenceNode )
             {
                 isSearchAll = ( ( PresenceNode ) filter ).getAttributeType().equals( OBJECT_CLASS_AT );
             }
@@ -795,10 +795,11 @@ public class DefaultPartitionNexus exten
                 for ( Partition partition : partitions.values() )
                 {
                     Dn contextDn = partition.getSuffixDn();
-                    HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( searchContext.getSession(), contextDn );
-                    
+                    HasEntryOperationContext hasEntryContext = new HasEntryOperationContext(
+                        searchContext.getSession(), contextDn );
+
                     // search only if the context entry exists
-                    if( partition.hasEntry( hasEntryContext ) )
+                    if ( partition.hasEntry( hasEntryContext ) )
                     {
                         searchContext.setDn( contextDn );
                         searchContext.setScope( SearchScope.OBJECT );
@@ -953,7 +954,7 @@ public class DefaultPartitionNexus exten
         {
             partitionLookupTree.remove( partition.getSuffixDn() );
         }
-        
+
         partitions.remove( key );
 
         try
@@ -973,7 +974,7 @@ public class DefaultPartitionNexus exten
     public Partition getPartition( Dn dn ) throws LdapException
     {
         Partition parent = null;
-        
+
         synchronized ( partitionLookupTree )
         {
             parent = partitionLookupTree.getElement( dn );
@@ -1018,7 +1019,7 @@ public class DefaultPartitionNexus exten
 
         if ( supportedExtension == null )
         {
-            rootDse.put( SchemaConstants.SUPPORTED_EXTENSION_AT, (String)null );
+            rootDse.put( SchemaConstants.SUPPORTED_EXTENSION_AT, ( String ) null );
             supportedExtension = rootDse.get( SchemaConstants.SUPPORTED_EXTENSION_AT );
         }
 
@@ -1036,13 +1037,14 @@ public class DefaultPartitionNexus exten
     {
         Attribute supportedSaslMechanismsAt = null;
 
-        supportedSaslMechanismsAt = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( SchemaConstants.SUPPORTED_SASL_MECHANISMS_AT ) );
+        supportedSaslMechanismsAt = new DefaultAttribute(
+            schemaManager.lookupAttributeTypeRegistry( SchemaConstants.SUPPORTED_SASL_MECHANISMS_AT ) );
 
         for ( String saslMechanism : supportedSaslMechanisms )
         {
             supportedSaslMechanismsAt.add( saslMechanism );
         }
-        
+
         rootDse.add( supportedSaslMechanismsAt );
     }
 

Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/AbstractTransaction.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/AbstractTransaction.java?rev=1225696&r1=1225695&r2=1225696&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/AbstractTransaction.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/AbstractTransaction.java Thu Dec 29 23:54:19 2011
@@ -19,10 +19,10 @@
  */
 package org.apache.directory.server.core.shared.txn;
 
+
+import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.UUID;
 
 import org.apache.directory.server.core.api.partition.index.ForwardIndexEntry;
@@ -31,63 +31,80 @@ import org.apache.directory.server.core.
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.name.Dn;
 
+
 /**
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 abstract class AbstractTransaction implements Transaction
 {
-    /** Logical time(LSN in the wal) when the txn began */ 
-    long startTime;
-    
+    /** Logical time(LSN in the wal) when the txn began */
+    private long startTime;
+
     /** logical commit time, set when txn commits */
-    long commitTime;
-    
+    protected long commitTime;
+
     /** State of the transaction */
-    State txnState;
-    
-    /** List of txns that this txn depends */
-    List<ReadWriteTxn> txnsToCheck = new ArrayList<ReadWriteTxn>();
- 
-    
+    private State txnState;
+
+    /** List of txns that this txn depends on */
+    private List<ReadWriteTxn> txnsToCheck = new ArrayList<ReadWriteTxn>();
+
+    /** The number of operations using this transaction */
+    private int nbRef;
+
+
     /**
      * TODO : doco
      */
-    public AbstractTransaction( )
+    public AbstractTransaction()
     {
         txnState = State.INITIAL;
+        nbRef = 0;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
-    public void startTxn( long startTime )
+    protected void startTxn( long startTime )
     {
         this.startTime = startTime;
         setState( State.READ );
+        nbRef++;
     }
-    
-    
+
+
+    public void reuseTxn()
+    {
+        nbRef++;
+    }
+
+
     /**
      * {@inheritDoc}
-     */  
+     */
     public long getStartTime()
     {
         return startTime;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     public void commitTxn( long commitTime )
     {
         this.commitTime = commitTime;
-        setState( State.COMMIT );
+        nbRef--;
+
+        if ( nbRef == 0 )
+        {
+            setState( State.COMMIT );
+        }
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -95,132 +112,117 @@ abstract class AbstractTransaction imple
     {
         return commitTime;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     public void abortTxn()
     {
-       setState( State.ABORT ); 
+        setState( State.ABORT );
     }
 
-    
+
     /**
      * {@inheritDoc}
-     */  
+     */
     public List<ReadWriteTxn> getTxnsToCheck()
     {
         return txnsToCheck;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
-     */  
+     */
     public State getState()
     {
         return txnState;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
-     */  
+     */
     public void setState( State newState )
     {
         txnState = newState;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     public Entry mergeUpdates( Dn partitionDn, UUID entryID, Entry entry )
     {
-        Entry prevEntry  = entry;
+        Entry prevEntry = entry;
         Entry curEntry = entry;
-        ReadWriteTxn curTxn;
         boolean cloneOnChange = true;
-        
-        Iterator<ReadWriteTxn> it = txnsToCheck.iterator();
-        
-        while ( it.hasNext() )
+
+        for ( ReadWriteTxn curTxn : txnsToCheck )
         {
-            curTxn = it.next();
             curEntry = curTxn.applyUpdatesToEntry( partitionDn, entryID, curEntry, cloneOnChange );
-            
+
             if ( curEntry != prevEntry )
             {
                 cloneOnChange = false;
             }
         }
-        
+
         return curEntry;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
-    public UUID mergeForwardLookup(Dn partitionDn, String attributeOid,  Object key, UUID curId, Comparator<Object> valueComparator )
+    public UUID mergeForwardLookup( Dn partitionDn, String attributeOid, Object key, UUID curId,
+        Comparator<Object> valueComparator )
     {
         ForwardIndexEntry<Object> indexEntry = new ForwardIndexEntry<Object>();
         indexEntry.setId( curId );
         indexEntry.setValue( key );
-        
-        ReadWriteTxn curTxn;
-        Iterator<ReadWriteTxn> it = txnsToCheck.iterator();
-        
-        while ( it.hasNext() )
+
+        for ( ReadWriteTxn curTxn : txnsToCheck )
         {
-            curTxn = it.next();
-            curTxn.updateForwardLookup( partitionDn, attributeOid, indexEntry, valueComparator );   
+            curTxn.updateForwardLookup( partitionDn, attributeOid, indexEntry, valueComparator );
         }
-        
+
         return indexEntry.getId();
     }
-   
-    
+
+
     /**
      * {@inheritDoc}
      */
-    public Object mergeReverseLookup(Dn partitionDn, String attributeOid,  UUID id, Object curValue )
+    public Object mergeReverseLookup( Dn partitionDn, String attributeOid, UUID id, Object curValue )
     {
         ReverseIndexEntry<Object> indexEntry = new ReverseIndexEntry<Object>();
         indexEntry.setId( id );
         indexEntry.setValue( curValue );
-        
-        ReadWriteTxn curTxn;
-        Iterator<ReadWriteTxn> it = txnsToCheck.iterator();
-        
-        while ( it.hasNext() )
+
+        for ( ReadWriteTxn curTxn : txnsToCheck )
         {
-            curTxn = it.next();
             curTxn.updateReverseLookup( partitionDn, attributeOid, indexEntry );
         }
-        
+
         return indexEntry.getValue();
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
-    public boolean mergeExistence(Dn partitionDN, String attributeOid,  IndexEntry<?> indexEntry, boolean currentlyExists )
+    public boolean mergeExistence( Dn partitionDN, String attributeOid, IndexEntry<?> indexEntry,
+        boolean currentlyExists )
     {
-        ReadWriteTxn curTxn;
         boolean forward = ( indexEntry instanceof ForwardIndexEntry );
-        
-        Iterator<ReadWriteTxn> it = txnsToCheck.iterator();
-        
-        while ( it.hasNext() )
+
+        for ( ReadWriteTxn curTxn : txnsToCheck )
         {
-            curTxn = it.next();
             currentlyExists = curTxn.updateExistence( partitionDN, attributeOid, indexEntry, currentlyExists, forward );
-          
         }
-        
+
         return currentlyExists;
     }
 }
\ No newline at end of file

Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java?rev=1225696&r1=1225695&r2=1225696&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java Thu Dec 29 23:54:19 2011
@@ -20,33 +20,28 @@
 package org.apache.directory.server.core.shared.txn;
 
 
-import org.apache.directory.server.core.api.partition.Partition;
-import org.apache.directory.server.core.api.txn.TxnConflictException;
-import org.apache.directory.server.core.api.txn.TxnHandle;
-import org.apache.directory.server.core.api.txn.TxnLogManager;
-import org.apache.directory.server.core.shared.txn.logedit.TxnStateChange;
-import org.apache.directory.server.core.api.log.LogAnchor;
-
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.ObjectOutputStream;
-
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.atomic.AtomicLong;
-
+import org.apache.directory.server.core.api.log.LogAnchor;
 import org.apache.directory.server.core.api.log.UserLogRecord;
-
-import java.io.IOException;
+import org.apache.directory.server.core.api.partition.Partition;
+import org.apache.directory.server.core.api.txn.TxnConflictException;
+import org.apache.directory.server.core.api.txn.TxnHandle;
+import org.apache.directory.server.core.api.txn.TxnLogManager;
+import org.apache.directory.server.core.shared.txn.logedit.TxnStateChange;
 
 
 /**
@@ -76,34 +71,34 @@ class DefaultTxnManager implements TxnMa
 
     /** Latest flushed txn's logical commit time */
     private AtomicLong latestFlushedTxnLSN = new AtomicLong( LogAnchor.UNKNOWN_LSN );
-    
+
     /** Default flush interval in ms */
     private final static int DEFAULT_FLUSH_INTERVAL = 100;
-    
+
     /** Flush interval */
     private int flushInterval;
-    
+
     /** Flush lock */
     private Lock flushLock = new ReentrantLock();
-    
+
     /** Number of flushes */
     private int numFlushes;
-    
+
     /** Flush Condition object */
     private Condition flushCondition = flushLock.newCondition();
-    
+
     /** Whether flushing is failed */
     private boolean flushFailed;
-    
+
     /** partitions to be synced after applying changes */
     private HashSet<Partition> flushedToPartitions = new HashSet<Partition>();
-    
+
     /** Backgorund syncing thread */
     private LogSyncer syncer;
-    
+
     /** Initial committed txn */
     private ReadWriteTxn dummyTxn = new ReadWriteTxn();
-    
+
     private AtomicInteger pending = new AtomicInteger();
 
     /** Per thread txn context */
@@ -131,22 +126,22 @@ class DefaultTxnManager implements TxnMa
     {
         this.txnLogManager = txnLogManager;
         flushInterval = DEFAULT_FLUSH_INTERVAL;
-        
+
         dummyTxn.commitTxn( LogAnchor.UNKNOWN_LSN );
         latestCommittedTxn.set( dummyTxn );
         latestVerifiedTxn.set( dummyTxn );
         committedQueue.offer( dummyTxn );
-        
+
         syncer = new LogSyncer();
         syncer.setDaemon( true );
         syncer.start();
     }
-    
-    
+
+
     public void uninit()
     {
         syncer.interrupt();
-        
+
         try
         {
             syncer.join();
@@ -155,10 +150,10 @@ class DefaultTxnManager implements TxnMa
         {
             // Ignore
         }
-        
+
         // Do a best effort last flush
         flushLock.lock();
-        
+
         try
         {
             flushTxns();
@@ -171,7 +166,7 @@ class DefaultTxnManager implements TxnMa
         {
             flushLock.unlock();
         }
-        
+
         syncer = null;
     }
 
@@ -268,8 +263,8 @@ class DefaultTxnManager implements TxnMa
         
         return curTxn;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -289,8 +284,8 @@ class DefaultTxnManager implements TxnMa
         
         txnVar.set( ( Transaction )txnHandle );
     }
-  
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -299,19 +294,19 @@ class DefaultTxnManager implements TxnMa
         return ( Transaction ) txnVar.get();
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     public void applyPendingTxns()
     {
         flushLock.lock();
-        
+
         try
         {
             flushTxns();
         }
-        catch( Exception e )
+        catch ( Exception e )
         {
             e.printStackTrace();
             // Ignore
@@ -320,9 +315,10 @@ class DefaultTxnManager implements TxnMa
         {
             flushLock.unlock();
         }
-        
+
     }
 
+
     /**
      * Begins a read only txn. A read only txn does not put any log edits
      * to the txn log.Its start time is the latest committed txn's commit time. 
@@ -371,10 +367,10 @@ class DefaultTxnManager implements TxnMa
         }
 
         txn.startTxn( startTime );
-        
-//        int refCount = lastTxnToCheck.getRefCount().get();
-//        System.out.println("start time" + startTime + " " + refCount + 
-//            " pending " + pending.incrementAndGet() );
+
+        //        int refCount = lastTxnToCheck.getRefCount().get();
+        //        System.out.println("start time" + startTime + " " + refCount + 
+        //            " pending " + pending.incrementAndGet() );
 
         buildCheckList( txn, lastTxnToCheck );
         txnVar.set( txn );
@@ -393,7 +389,7 @@ class DefaultTxnManager implements TxnMa
         UserLogRecord logRecord = txn.getUserLogRecord();
 
         TxnStateChange txnRecord = new TxnStateChange( LogAnchor.UNKNOWN_LSN,
-            TxnStateChange.State.TXN_BEGIN );
+            TxnStateChange.ChangeState.TXN_BEGIN );
         ObjectOutputStream out = null;
         ByteArrayOutputStream bout = null;
         byte[] data;
@@ -562,13 +558,13 @@ class DefaultTxnManager implements TxnMa
             }
 
             lastTxnToCheck.getRefCount().decrementAndGet();
-            
-//            if ( txn instanceof ReadOnlyTxn )
-//            {
-//                System.out.println(" txn end " + txn.getStartTime() + " " + 
-//                    lastTxnToCheck.getRefCount() 
-//                    + " pending " + pending.decrementAndGet() );
-//            }
+
+            //            if ( txn instanceof ReadOnlyTxn )
+            //            {
+            //                System.out.println(" txn end " + txn.getStartTime() + " " + 
+            //                    lastTxnToCheck.getRefCount() 
+            //                    + " pending " + pending.decrementAndGet() );
+            //            }
         }
     }
 
@@ -602,7 +598,7 @@ class DefaultTxnManager implements TxnMa
         UserLogRecord logRecord = txn.getUserLogRecord();
 
         TxnStateChange txnRecord = new TxnStateChange( txn.getStartTime(),
-            TxnStateChange.State.TXN_COMMIT );
+            TxnStateChange.ChangeState.TXN_COMMIT );
         ObjectOutputStream out = null;
         ByteArrayOutputStream bout = null;
         byte[] data;
@@ -687,7 +683,7 @@ class DefaultTxnManager implements TxnMa
         UserLogRecord logRecord = txn.getUserLogRecord();
 
         TxnStateChange txnRecord = new TxnStateChange( txn.getStartTime(),
-            TxnStateChange.State.TXN_ABORT );
+            TxnStateChange.ChangeState.TXN_ABORT );
         ObjectOutputStream out = null;
         ByteArrayOutputStream bout = null;
         byte[] data;
@@ -716,96 +712,97 @@ class DefaultTxnManager implements TxnMa
         logRecord.setData( data, data.length );
         txnLogManager.log( logRecord, false );
     }
-    
-   /**
-    *  Flush the changes of the txns in the committed queue. A txn is flushed
-    *  only if flushing it will not cause a pending txn to see changes beyond its
-    *  start time.
-    *  throws Exception thrown if anything goes wrong during flush.
-    *
-    */
-   private void flushTxns() throws Exception
-   {
-       // If flushing failed already, dont do anything anymore
-       if ( flushFailed )
-       {
-           return;
-       }
-       
-       /*
-        * First get the latest committed txn ref and then the iterator.
-        * Order is important.
-        */
-       ReadWriteTxn latestCommitted = latestCommittedTxn.get();
-       long latestFlushedLsn = latestFlushedTxnLSN.get();
-       flushedToPartitions.clear();
-       
-       Iterator<ReadWriteTxn> it = committedQueue.iterator();
-       ReadWriteTxn txnToFlush = null;
-       
-       while ( it.hasNext() )
-       {
-           txnToFlush = it.next();
-           
-           if ( txnToFlush.getCommitTime() > latestFlushedLsn )
-           {
-               // Apply changes
-               txnToFlush.flushLogEdits( flushedToPartitions );
-               
-               latestFlushedTxnLSN.set( txnToFlush.getCommitTime() );
-           }
-           
-           if ( txnToFlush == latestCommitted )
-           {
-               // leave latest committed txn in queue and dont go beyond it.
-               break;
-           }
-           
-           numFlushes++;
-           
-//           if (  numFlushes % 100 == 0 )
-//           {
-//           System.out.println( "lastFlushed lsn: " + latestFlushedTxnLSN  + " " + committedQueue.size() );
-//           
-//           System.out.println( " last commit txn: " + latestCommitted.getCommitTime() );
-//           System.out.println( "txnToFlush: " + txnToFlush.getRefCount() + " " + txnToFlush.getCommitTime() ); 
-//           }
-           
-           /*
-            *  If the latest flushed txn has ref count > 0, then
-            *  following txns wont be flushed yet.
-            */
-           
-           if ( txnToFlush.getRefCount().get() >  0 )
-           {
-          //     System.out.println( "breaking out: " + txnToFlush.getCommitTime()  + " " + committedQueue.size() );
-               break;
-           }
-           
-           // Remove from the queue
-           it.remove();
-       }
-       
-       // Sync each flushed to partition
-       Iterator<Partition> partitionIt = flushedToPartitions.iterator();
-       
-       while ( partitionIt.hasNext() )
-       {
-           partitionIt.next().sync();
-       }
-           
-   }
-    
-    class LogSyncer extends Thread 
+
+
+    /**
+     *  Flush the changes of the txns in the committed queue. A txn is flushed
+     *  only if flushing it will not cause a pending txn to see changes beyond its
+     *  start time.
+     *  throws Exception thrown if anything goes wrong during flush.
+     *
+     */
+    private void flushTxns() throws Exception
+    {
+        // If flushing failed already, dont do anything anymore
+        if ( flushFailed )
+        {
+            return;
+        }
+
+        /*
+         * First get the latest committed txn ref and then the iterator.
+         * Order is important.
+         */
+        ReadWriteTxn latestCommitted = latestCommittedTxn.get();
+        long latestFlushedLsn = latestFlushedTxnLSN.get();
+        flushedToPartitions.clear();
+
+        Iterator<ReadWriteTxn> it = committedQueue.iterator();
+        ReadWriteTxn txnToFlush = null;
+
+        while ( it.hasNext() )
+        {
+            txnToFlush = it.next();
+
+            if ( txnToFlush.getCommitTime() > latestFlushedLsn )
+            {
+                // Apply changes
+                txnToFlush.flushLogEdits( flushedToPartitions );
+
+                latestFlushedTxnLSN.set( txnToFlush.getCommitTime() );
+            }
+
+            if ( txnToFlush == latestCommitted )
+            {
+                // leave latest committed txn in queue and dont go beyond it.
+                break;
+            }
+
+            numFlushes++;
+
+            //           if (  numFlushes % 100 == 0 )
+            //           {
+            //           System.out.println( "lastFlushed lsn: " + latestFlushedTxnLSN  + " " + committedQueue.size() );
+            //           
+            //           System.out.println( " last commit txn: " + latestCommitted.getCommitTime() );
+            //           System.out.println( "txnToFlush: " + txnToFlush.getRefCount() + " " + txnToFlush.getCommitTime() ); 
+            //           }
+
+            /*
+             *  If the latest flushed txn has ref count > 0, then
+             *  following txns wont be flushed yet.
+             */
+
+            if ( txnToFlush.getRefCount().get() > 0 )
+            {
+                //     System.out.println( "breaking out: " + txnToFlush.getCommitTime()  + " " + committedQueue.size() );
+                break;
+            }
+
+            // Remove from the queue
+            it.remove();
+        }
+
+        // Sync each flushed to partition
+        Iterator<Partition> partitionIt = flushedToPartitions.iterator();
+
+        while ( partitionIt.hasNext() )
+        {
+            partitionIt.next().sync();
+        }
+
+    }
+
+    class LogSyncer extends Thread
     {
 
         @Override
-        public void run() 
+        public void run()
         {
             flushLock.lock();
+
             try
             {
-
                 while ( !this.isInterrupted() )
                 {
                     flushCondition.await( flushInterval, TimeUnit.MILLISECONDS );
@@ -827,7 +824,6 @@ class DefaultTxnManager implements TxnMa
                 flushLock.unlock();
             }
         }
-      }
-    
-    
+    }
+
 }

Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/ReadOnlyTxn.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/ReadOnlyTxn.java?rev=1225696&r1=1225695&r2=1225696&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/ReadOnlyTxn.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/ReadOnlyTxn.java Thu Dec 29 23:54:19 2011
@@ -19,11 +19,31 @@
  */
 package org.apache.directory.server.core.shared.txn;
 
+
 /**
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-/** Package protected */ class ReadOnlyTxn extends AbstractTransaction
+/** Package protected */
+class ReadOnlyTxn extends AbstractTransaction
 {
+    private int nbRef = 0;
+
+
+    public void releaseTxn()
+    {
+        nbRef--;
+    }
+
+
+    public void acquireTxn()
+    {
+        nbRef++;
+    }
+
 
+    public boolean isReused()
+    {
+        return nbRef > 1;
+    }
 }

Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/Transaction.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/Transaction.java?rev=1225696&r1=1225695&r2=1225696&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/Transaction.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/Transaction.java Thu Dec 29 23:54:19 2011
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.core.shared.txn;
 
+
 import java.util.Comparator;
 import java.util.List;
 import java.util.UUID;
@@ -33,7 +34,8 @@ import org.apache.directory.shared.ldap.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-/** Package protected */ interface Transaction extends TxnHandle
+/** Package protected */
+interface Transaction extends TxnHandle
 {
 
     /**
@@ -59,7 +61,9 @@ import org.apache.directory.shared.ldap.
      *
      * @param startTime start time of the txn
      */
-    void startTxn( long startTime );
+    //void startTxn( long startTime );
+
+    void reuseTxn();
 
 
     /**
@@ -103,8 +107,8 @@ import org.apache.directory.shared.ldap.
      * @return
      */
     Entry mergeUpdates( Dn partitionDn, UUID entryID, Entry entry );
-    
-    
+
+
     /**
      * Checks all the updates done on the given index for the given key and returns 
      * the latest version of the coressponding id
@@ -115,9 +119,10 @@ import org.apache.directory.shared.ldap.
      * @param valueComp value comparator
      * @return id corresponding to the key
      */
-    UUID mergeForwardLookup(Dn partitionDN, String attributeOid,  Object key, UUID curId, Comparator<Object> valueComparator );
-    
-    
+    UUID mergeForwardLookup( Dn partitionDN, String attributeOid, Object key, UUID curId,
+        Comparator<Object> valueComparator );
+
+
     /**
      * Checks all the updates done on the given index for the given id and returns 
      * the latest version of the corressponding value
@@ -127,9 +132,9 @@ import org.apache.directory.shared.ldap.
      * @param id key to do the lookup on 
      * @return value corresponding to the id
      */
-    Object mergeReverseLookup(Dn partitionDN, String attributeOid,  UUID id, Object curValue );
-    
-    
+    Object mergeReverseLookup( Dn partitionDN, String attributeOid, UUID id, Object curValue );
+
+
     /**
      * Checks all the updates on the given index entry and returns whether the it exists or not
      *
@@ -139,8 +144,7 @@ import org.apache.directory.shared.ldap.
      * @param currentlyExists true if the index entry currently exists in the underlying partition
      * @return true if the given index entry exists
      */
-    boolean mergeExistence(Dn partitionDN, String attributeOid,  IndexEntry<?> indexEntry, boolean currentlyExists );
-
+    boolean mergeExistence( Dn partitionDN, String attributeOid, IndexEntry<?> indexEntry, boolean currentlyExists );
 
     enum State
     {

Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnManagerInternal.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnManagerInternal.java?rev=1225696&r1=1225695&r2=1225696&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnManagerInternal.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnManagerInternal.java Thu Dec 29 23:54:19 2011
@@ -19,17 +19,21 @@
  */
 package org.apache.directory.server.core.shared.txn;
 
+
 import org.apache.directory.server.core.api.txn.TxnManager;
 
+
 /**
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-/** Package protected */ interface TxnManagerInternal extends TxnManager
+/** Package protected */
+interface TxnManagerInternal extends TxnManager
 {
     /**
      * Returns the current txn associated with the current thread.
      *
+     * @param readOnly whether the txn is read only
      * @return current txn
      */
     Transaction getCurTxn();

Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java?rev=1225696&r1=1225695&r2=1225696&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java Thu Dec 29 23:54:19 2011
@@ -19,12 +19,14 @@
  */
 package org.apache.directory.server.core.shared.txn.logedit;
 
+
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
 import org.apache.directory.server.core.api.txn.logedit.AbstractLogEdit;
 
+
 /**
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -33,42 +35,43 @@ public class TxnStateChange extends Abst
 {
     /** ID of the txn associated with this change */
     long txnID;
-    
+
     /** State to record for the txn */
-    State txnState;
-    
+    ChangeState txnState;
+
     private static final long serialVersionUID = 1;
-    
+
+
     // For deserialization
     public TxnStateChange()
     {
     }
-    
-    
-    public TxnStateChange( long txnID, State txnState )
+
+
+    public TxnStateChange( long txnID, ChangeState txnState )
     {
         this.txnID = txnID;
         this.txnState = txnState;
     }
-    
-    
+
+
     public long getTxnID()
     {
         return txnID;
     }
-    
-    
-    public State getTxnState()
+
+
+    public ChangeState getTxnState()
     {
         return txnState;
     }
-    
-    
+
+
     @Override
     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
     {
         txnID = in.readLong();
-        txnState = State.values()[in.readInt()];
+        txnState = ChangeState.values()[in.readInt()];
     }
 
 
@@ -78,9 +81,8 @@ public class TxnStateChange extends Abst
         out.writeLong( txnID );
         out.writeInt( txnState.ordinal() );
     }
-    
-    
-    public enum State
+
+    public enum ChangeState
     {
         TXN_BEGIN,
         TXN_COMMIT,



Mime
View raw message