directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From malder...@apache.org
Subject svn commit: r552568 - in /directory/apacheds/trunk/mitosis/src: main/java/org/apache/directory/mitosis/service/ReplicationService.java test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
Date Mon, 02 Jul 2007 19:26:24 GMT
Author: malderson
Date: Mon Jul  2 12:26:23 2007
New Revision: 552568

URL: http://svn.apache.org/viewvc?view=rev&rev=552568
Log:
Delete, move and rename operations are now replicated again and search/list operations filter
out the tombstoned entries once more (DIRSERVER-929).

Modified:
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java?view=diff&rev=552568&r1=552567&r2=552568
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
(original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
Mon Jul  2 12:26:23 2007
@@ -60,7 +60,10 @@
 import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
 import org.apache.directory.server.core.interceptor.context.GetMatchedNameOperationContext;
 import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
+import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
+import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
 import org.apache.directory.server.core.interceptor.context.OperationContext;
+import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.invocation.InvocationStack;
 import org.apache.directory.server.core.partition.PartitionNexus;
@@ -383,9 +386,10 @@
     }
 
 
-    public void delete( NextInterceptor nextInterceptor, LdapDN name ) throws NamingException
+    @Override
+    public void delete( NextInterceptor next, OperationContext opContext ) throws NamingException
     {
-        Operation op = operationFactory.newDelete( name );
+        Operation op = operationFactory.newDelete( opContext.getDn() );
         op.execute( nexus, store, attrRegistry );
     }
 
@@ -395,27 +399,31 @@
         Operation op = operationFactory.newModify( modifyContext );
         op.execute( nexus, store, attrRegistry );
     }
-
-
-    public void modifyRn( NextInterceptor next, LdapDN oldName, String newRDN, boolean deleteOldRDN
)
-        throws NamingException
+    
+    
+    @Override
+    public void move( NextInterceptor next, OperationContext opContext ) throws NamingException
     {
-        Operation op = operationFactory.newModifyRn( oldName, newRDN, deleteOldRDN );
+        MoveOperationContext moveOpContext = (MoveOperationContext) opContext;
+        Operation op = operationFactory.newMove( moveOpContext.getDn(), moveOpContext.getParent()
);
         op.execute( nexus, store, attrRegistry );
     }
-
-
-    public void move( NextInterceptor next, LdapDN oldName, LdapDN newParentName, String
newRDN, boolean deleteOldRDN )
-        throws NamingException
+    
+    
+    @Override
+    public void moveAndRename( NextInterceptor next, OperationContext opContext ) throws
NamingException
     {
-        Operation op = operationFactory.newMove( oldName, newParentName, newRDN, deleteOldRDN
);
+        MoveAndRenameOperationContext moveAndRenameOpContext = (MoveAndRenameOperationContext)
opContext;
+        Operation op = operationFactory.newMove( moveAndRenameOpContext.getDn(), moveAndRenameOpContext.getParent(),
moveAndRenameOpContext.getNewRdn(), moveAndRenameOpContext.getDelOldDn() );
         op.execute( nexus, store, attrRegistry );
     }
-
-
-    public void move( NextInterceptor next, LdapDN oldName, LdapDN newParentName ) throws
NamingException
+    
+    
+    @Override
+    public void rename( NextInterceptor next, OperationContext opContext ) throws NamingException
     {
-        Operation op = operationFactory.newMove( oldName, newParentName );
+        RenameOperationContext renameOpContext = (RenameOperationContext) opContext;
+        Operation op = operationFactory.newModifyRn( renameOpContext.getDn(), renameOpContext.getNewRdn(),
renameOpContext.getDelOldDn() );
         op.execute( nexus, store, attrRegistry );
     }
 
@@ -481,12 +489,13 @@
     }
 
 
-    public NamingEnumeration list( NextInterceptor nextInterceptor, LdapDN baseName ) throws
NamingException
+    @Override
+    public NamingEnumeration list( NextInterceptor next, OperationContext opContext ) throws
NamingException
     {
         DirContext ctx = ( DirContext ) InvocationStack.getInstance().peek().getCaller();
-        NamingEnumeration e = nextInterceptor.search(
+        NamingEnumeration e = next.search(
             new SearchOperationContext( 
-                baseName, ctx.getEnvironment(),
+                opContext.getDn(), ctx.getEnvironment(),
                 new PresenceNode( SchemaConstants.OBJECT_CLASS_AT_OID ),
                 new SearchControls() ) );
 
@@ -495,9 +504,12 @@
     }
 
 
-    public NamingEnumeration search( NextInterceptor nextInterceptor, LdapDN baseName, Map
environment, ExprNode filter,
-        SearchControls searchControls ) throws NamingException
+    @Override
+    public NamingEnumeration<SearchResult> search( NextInterceptor next, OperationContext
opContext ) throws NamingException
     {
+        SearchOperationContext searchOpContext = (SearchOperationContext) opContext;
+        SearchControls searchControls = searchOpContext.getSearchControls();
+        
         if ( searchControls.getReturningAttributes() != null )
         {
             String[] oldAttrIds = searchControls.getReturningAttributes();
@@ -507,8 +519,8 @@
             searchControls.setReturningAttributes( newAttrIds );
         }
         
-        NamingEnumeration e = nextInterceptor.search( 
-            new SearchOperationContext( baseName, environment, filter, searchControls ) );
+        NamingEnumeration e = next.search( 
+            new SearchOperationContext( searchOpContext.getDn(), searchOpContext.getEnv(),
searchOpContext.getFilter(), searchControls ) );
         return new SearchResultFilteringEnumeration( e, searchControls, InvocationStack.getInstance().peek(),
             Constants.DELETED_ENTRIES_FILTER, "Search Replication filter" );
     }

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java?view=diff&rev=552568&r1=552567&r2=552568
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
(original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
Mon Jul  2 12:26:23 2007
@@ -30,6 +30,7 @@
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.ldap.InitialLdapContext;
@@ -48,6 +49,7 @@
 import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
 import org.apache.directory.server.core.configuration.ShutdownConfiguration;
 import org.apache.directory.server.core.jndi.CoreContextFactory;
+import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.mina.util.AvailablePortFinder;
 
@@ -72,21 +74,11 @@
         destroyAllReplicas();
     }
 
-    public void testOneWayBind() throws Exception
+    public void testOneWay() throws Exception
     {
-        LdapContext ctxA = getReplicaContext( "A" );
-        LdapContext ctxB = getReplicaContext( "B" );
-        LdapContext ctxC = getReplicaContext( "C" );
-
-        Attributes entry = new AttributesImpl( true );
-        entry.put( "cn", "test" );
-        entry.put( "objectClass", "top" );
-        ctxA.bind( "cn=test,ou=system", entry );
-
-        Thread.sleep( 7000 );
-
-        Assert.assertNotNull( ctxB.lookup( "cn=test,ou=system" ) );
-        Assert.assertNotNull( ctxC.lookup( "cn=test,ou=system" ) );
+        String dn1 = "cn=test,ou=system";
+        testOneWayBind( dn1 );
+        testOneWayUnbind( dn1 );
     }
     
     public void _testTwoWayBind() throws Exception
@@ -112,6 +104,52 @@
         Assert.assertEquals( "B", getAttributeValue( ctxA, "cn=test,ou=system", "ou" ) );
         Assert.assertEquals( "B", getAttributeValue( ctxB, "cn=test,ou=system", "ou" ) );
         Assert.assertEquals( "B", getAttributeValue( ctxC, "cn=test,ou=system", "ou" ) );
+    }
+    
+    private void testOneWayBind( String dn ) throws Exception
+    {
+        LdapContext ctxA = getReplicaContext( "A" );
+        LdapContext ctxB = getReplicaContext( "B" );
+        LdapContext ctxC = getReplicaContext( "C" );
+        
+        Attributes entry = new AttributesImpl( true );
+        entry.put( "cn", "test" );
+        entry.put( "objectClass", "top" );
+        ctxA.bind( dn, entry );
+
+        Thread.sleep( 7000 );
+
+        Assert.assertNotNull( ctxB.lookup( dn ) );
+        Assert.assertNotNull( ctxC.lookup( dn ) );
+    }
+    
+    private void testOneWayUnbind( String dn ) throws Exception
+    {
+        LdapContext ctxA = getReplicaContext( "A" );
+        LdapContext ctxB = getReplicaContext( "B" );
+        LdapContext ctxC = getReplicaContext( "C" );
+        
+        ctxA.unbind( dn );
+        
+        Thread.sleep( 7000 );
+        
+        assertNotExists( ctxA, dn );
+        assertNotExists( ctxB, dn );
+        assertNotExists( ctxC, dn );
+    }
+    
+    private void assertNotExists( LdapContext ctx, String dn ) throws NamingException
+    {
+        try
+        {
+            ctx.lookup( dn );
+        }
+        catch ( LdapNameNotFoundException e )
+        {
+            // This is expected so return immediately.
+            return;
+        }
+        throw new AssertionError( "The entry exists" );
     }
     
     private String getAttributeValue( LdapContext ctx, String name, String attrName ) throws
Exception



Mime
View raw message