directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r733098 - in /directory/apacheds/trunk/mitosis/src: main/java/org/apache/directory/mitosis/common/ main/java/org/apache/directory/mitosis/configuration/ main/java/org/apache/directory/mitosis/operation/ main/java/org/apache/directory/mitosi...
Date Fri, 09 Jan 2009 17:52:41 GMT
Author: elecharny
Date: Fri Jan  9 09:52:40 2009
New Revision: 733098

URL: http://svn.apache.org/viewvc?rev=733098&view=rev
Log:
o Removed the useless interfaces and renamed the DefaultCSN/DefaultCSNFactory to CSN/CSNFactory
o Used the CSN factory to create CSN except in the deserializer
o Switching some tests to use Junit 4.4
o Initialized the factory in the interceptor
o Added some javadoc
o Changed the Factory behavior : no more synchronization, as we now use volatile variables, and correct the CSN generation

Added:
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSN.java
      - copied, changed from r732113, directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultCSN.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNFactory.java
      - copied, changed from r732113, directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultCSNFactory.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNFactoryTest.java
      - copied, changed from r732113, directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/DefaultCSNFactoryTest.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNTest.java
      - copied, changed from r732113, directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/DefaultCSNTest.java
Removed:
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultCSN.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultCSNFactory.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/DefaultCSNFactoryTest.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/DefaultCSNTest.java
Modified:
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNVector.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfiguration.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageDecoder.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationLogIterator.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStore.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageCodecTest.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java

Copied: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSN.java (from r732113, directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultCSN.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSN.java?p2=directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSN.java&p1=directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultCSN.java&r1=732113&r2=733098&rev=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultCSN.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSN.java Fri Jan  9 09:52:40 2009
@@ -24,11 +24,30 @@
 
 
 /**
- * A default implementation of {@link CSN}.
+ * Represents 'Change Sequence Number' in LDUP specification.
+ * 
+ * A CSN is a composition of a timestamp, a replica ID and a 
+ * operation sequence number.
+ * 
+ * It's described in http://tools.ietf.org/html/draft-sermersheim-ldap-csn-02.
+ * 
+ * The ASN.1 syntax is :
+ * <pre>
+ * ChangeSequenceNumber ::= SEQUENCE {
+ *     time GeneralizedTime,
+ *     timeCount INTEGER (0 ..  MaxInt),
+ *     replicaID UTF8String,
+ *     changeCount INTEGER (0 ..  MaxInt)
+ * }
+ * </pre>
+ *  
+ * It distinguishes a change made on an object on a server,
+ * and if two operations take place during the same timeStamp,
+ * the operation sequence number makes those operations distinct.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DefaultCSN implements CSN, Serializable, Comparable<CSN>
+public class CSN implements Serializable, Comparable<CSN>
 {
     /**
      * Declares the Serial Version Uid.
@@ -57,12 +76,13 @@
 
     /**
      * Creates a new instance.
+     * <b>This method should be used only for deserializing a CSN</b> 
      * 
      * @param timestamp GMT timestamp of modification
      * @param replicaId Replica ID where modification occurred (<tt>[-_A-Za-z0-9]{1,16}</tt>)
      * @param operationSequence Operation sequence
      */
-    public DefaultCSN( long timestamp, String replicaId, int operationSequence )
+    public CSN( long timestamp, String replicaId, int operationSequence )
     {
         this.timestamp = timestamp;
         this.replicaId = replicaId;
@@ -78,7 +98,7 @@
      *
      * @param value The String containing the CSN
      */
-    public DefaultCSN( String value ) throws InvalidCSNException
+    public CSN( String value ) throws InvalidCSNException
     {
         assert value != null;
 
@@ -127,7 +147,7 @@
      *
      * @param value The byte array which contains the serialized CSN
      */
-    public DefaultCSN( byte[] value )
+    /** Package protected */ CSN( byte[] value )
     {
         timestamp = ( ( long ) ( value[0] & 0x00FF ) << 56 ) | ( ( long ) ( value[1] & 0x00FF ) << 48 )
             | ( ( long ) ( value[2] & 0x00FF ) << 40 ) | ( ( long ) ( value[3] & 0x00FF ) << 32 )
@@ -268,11 +288,6 @@
      */
     public boolean equals( Object o )
     {
-        if ( o == null )
-        {
-            return false;
-        }
-
         if ( this == o )
         {
             return true;
@@ -285,8 +300,8 @@
 
         CSN that = ( CSN ) o;
 
-        return timestamp == that.getTimestamp() && replicaId.equals( that.getReplicaId() )
-            && operationSequence == that.getOperationSequence();
+        return ( timestamp == that.getTimestamp() ) && ( replicaId.equals( that.getReplicaId() ) )
+            && ( operationSequence == that.getOperationSequence() );
     }
 
 

Copied: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNFactory.java (from r732113, directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultCSNFactory.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNFactory.java?p2=directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNFactory.java&p1=directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultCSNFactory.java&r1=732113&r2=733098&rev=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultCSNFactory.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNFactory.java Fri Jan  9 09:52:40 2009
@@ -21,17 +21,22 @@
 
 
 /**
- * A default {@link CSNFactory} implementation.
+ * Generates a new {@link CSN}.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DefaultCSNFactory implements CSNFactory
+public class CSNFactory
 {
-    private static int operationSequence;
+    /** The last timestamp */
+    private static volatile long lastTimestamp;
+    
+    /** The integer used to disambiguate CSN generated at the same time */
+    private static volatile int operationSequence;
 
 
-    public DefaultCSNFactory()
+    public CSNFactory()
     {
+        operationSequence = 0;
     }
 
 
@@ -43,17 +48,49 @@
      * @param replicaId Replica ID.  ReplicaID must be 1-8 digit alphanumeric
      *        string.
      */
-    public synchronized CSN newInstance( String replicaId )
+    public CSN newInstance( String replicaId )
     {
         long newTimestamp = System.currentTimeMillis();
         
-        if ( operationSequence == Integer.MAX_VALUE )
+        // We will be able to generate 2 147 483 647 CSNs each 10 ms max
+        if ( lastTimestamp == newTimestamp )
         {
-            // Roll over when reaching the limit.
+            operationSequence ++;
+        }
+        else
+        {
+            lastTimestamp = newTimestamp;
             operationSequence = 0;
         }
 
-        CSN newCSN = new DefaultCSN( newTimestamp, replicaId, operationSequence++ );
-        return newCSN;
+        return new CSN( lastTimestamp, replicaId, operationSequence );
+    }
+
+
+
+
+    /**
+     * Returns a new {@link CSN} created from the given values.
+     * 
+     * This method is <b>not</b> to be used except for test purposes.
+     * 
+     * @param timestamp The timestamp to use
+     * @param replicaId Replica ID.  ReplicaID must be 1-8 digit alphanumeric
+     * string.
+     * @param operationSequence The operation sequence to use
+     */
+    public CSN newInstance( long timestamp, String replicaId, int operationSequence )
+    {
+        return new CSN( timestamp, replicaId, operationSequence );
+    }
+    /**
+     * Generates a CSN used to purge data. Its replicaID is not associated
+     * to a server. 
+     * 
+     * @param expirationDate The time up to the first CSN we want to keep 
+     */
+    public CSN newInstance( long expirationDate )
+    {
+        return new CSN( expirationDate, "ZZZZZZZZZZZZZZZZ", Integer.MAX_VALUE );
     }
 }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNVector.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNVector.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNVector.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNVector.java Fri Jan  9 09:52:40 2009
@@ -83,6 +83,7 @@
     public void setAllCSN( CSNVector vector )
     {
         Iterator<CSN> i = vector.csns.values().iterator();
+        
         while ( i.hasNext() )
         {
             setCSN( i.next() );

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfiguration.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfiguration.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfiguration.java Fri Jan  9 09:52:40 2009
@@ -31,7 +31,7 @@
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.common.Replica;
-import org.apache.directory.mitosis.common.DefaultCSNFactory;
+import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.service.ReplicationInterceptor;
 import org.apache.directory.mitosis.store.ReplicationStore;
 import org.apache.directory.mitosis.store.derby.DerbyReplicationStore;
@@ -69,7 +69,7 @@
     private final Set<Replica> peerReplicas = new HashSet<Replica>();
     
     /** Factories */
-    private CSNFactory csnFactory = new DefaultCSNFactory();
+    private CSNFactory csnFactory = new CSNFactory();
     private ReplicationStore store = new DerbyReplicationStore();
     
     /** The longest period of time before a stored entry is removed from storage */
@@ -158,7 +158,7 @@
 
     /**
      * Returns the {@link CSNFactory} for generating {@link CSN}s.
-     * The default factory is {@link DefaultCSNFactory}.
+     * The default factory is {@link CSNFactory}.
      */
     public CSNFactory getCsnFactory()
     {
@@ -168,7 +168,7 @@
 
     /**                +
      * Sets the {@link CSNFactory} for generating {@link CSN}s.
-     * The default factory is {@link DefaultCSNFactory}.
+     * The default factory is {@link CSNFactory}.
      * @org.apache.xbean.Property hidden="true"
      */
     public void setCsnFactory( CSNFactory csnFactory )

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java Fri Jan  9 09:52:40 2009
@@ -21,6 +21,7 @@
 
 
 import org.apache.directory.mitosis.common.CSN;
+import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.operation.support.EntryUtil;
 import org.apache.directory.mitosis.store.ReplicationStore;
 import org.apache.directory.server.core.CoreSession;
@@ -92,10 +93,10 @@
      * @param store not used... Just for inheritance sake.
      * @param coreSession the current session
      */
-    protected void applyOperation( PartitionNexus nexus, ReplicationStore store, CoreSession coreSession )
+    protected void applyOperation( PartitionNexus nexus, ReplicationStore store, CoreSession coreSession, CSNFactory csnFactory )
         throws Exception
     {
-        if ( ! EntryUtil.isEntryUpdatable( coreSession, entry.getDn(), getCSN() ) )
+        if ( ! EntryUtil.isEntryUpdatable( csnFactory, coreSession, entry.getDn(), getCSN() ) )
         {
             return;
         }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java Fri Jan  9 09:52:40 2009
@@ -26,6 +26,7 @@
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.mitosis.common.CSN;
+import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.operation.support.EntryUtil;
 import org.apache.directory.mitosis.store.ReplicationStore;
 
@@ -96,10 +97,10 @@
      * @param store the replication storage
      * @param coreSession the current session
      */
-    protected final void applyOperation( PartitionNexus nexus, ReplicationStore store, CoreSession coreSession ) 
+    protected final void applyOperation( PartitionNexus nexus, ReplicationStore store, CoreSession coreSession, CSNFactory csnFactory ) 
         throws Exception
     {
-        if ( ! EntryUtil.isEntryUpdatable( coreSession, dn, getCSN() ) )
+        if ( ! EntryUtil.isEntryUpdatable( csnFactory, coreSession, dn, getCSN() ) )
         {
             return;
         }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java Fri Jan  9 09:52:40 2009
@@ -21,6 +21,7 @@
 
 
 import org.apache.directory.mitosis.common.CSN;
+import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.common.CSNVector;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.store.ReplicationLogIterator;
@@ -204,13 +205,14 @@
      * @param nexus the partition on which the modification will be done
      * @param store the replication store
      * @param coreSession the current session
+     * @param csnFactory The CSN Factory
      */
-    protected void applyOperation( PartitionNexus nexus, ReplicationStore store, CoreSession coreSession ) 
+    protected void applyOperation( PartitionNexus nexus, ReplicationStore store, CoreSession coreSession, CSNFactory csnFactory ) 
         throws Exception
     {
         for ( Operation op : children )
         {
-            op.execute( nexus, DUMMY_STORE, coreSession );
+            op.execute( nexus, DUMMY_STORE, coreSession, csnFactory );
         }
     }
     

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java Fri Jan  9 09:52:40 2009
@@ -29,6 +29,7 @@
 import javax.naming.OperationNotSupportedException;
 
 import org.apache.directory.mitosis.common.CSN;
+import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.common.Constants;
 import org.apache.directory.mitosis.store.ReplicationStore;
 import org.apache.directory.server.core.CoreSession;
@@ -72,10 +73,10 @@
 
     /** The entry CSN */
     protected CSN csn;
-    
+
     /** The operation type */
     protected OperationType operationType;
-    
+
     /** A reference on the server registries */
     protected Registries registries;
 
@@ -89,13 +90,13 @@
      * @param registries the server registries
      * @param operationType the operation type
      */
-    /* no qualifier */ Operation( Registries registries, OperationType operationType )
+    /* no qualifier */Operation( Registries registries, OperationType operationType )
     {
         this.registries = registries;
         this.operationType = operationType;
     }
 
-    
+
     /**
      * Creates a new instance of Operation, for the entry which
      * csn is given as a parameter.
@@ -128,32 +129,34 @@
      * @param nexus the partition nexus
      * @param store the replication store
      * @param coreSession the current session
+     * @param csnFactory The CSN Factory
      */
-    public final void execute( PartitionNexus nexus, ReplicationStore store, CoreSession coreSession ) 
-        throws Exception
+    public final void execute( PartitionNexus nexus, ReplicationStore store, CoreSession coreSession, CSNFactory csnFactory ) throws Exception
     {
         synchronized ( nexus )
         {
-            applyOperation( nexus, store, coreSession );
+            applyOperation( nexus, store, coreSession, csnFactory );
             store.putLog( this );
         }
     }
 
+
     /**
      * Not supported. We should never call this method directly.
      * 
      * @param nexus the partition nexus
      * @param store the replication store
      * @param coreSession the current session
+     * @param csnFactory The CSN Factory
      * @throws Exception
      */
-    protected void applyOperation( PartitionNexus nexus, ReplicationStore store, CoreSession coreSession ) 
-        throws Exception
+    protected void applyOperation( PartitionNexus nexus, ReplicationStore store, CoreSession coreSession,
+        CSNFactory csnFactory ) throws Exception
     {
         throw new OperationNotSupportedException( nexus.getSuffixDn().toString() );
     }
 
-    
+
     /**
      * De-serialize an Attribute Operation
      *
@@ -164,38 +167,38 @@
      * @throws ClassNotFoundException 
      * @throws IOException
      */
-    private static Operation readAttributeOperation( ObjectInput in, Registries registries, 
-        Operation operation ) throws ClassNotFoundException, IOException
+    private static Operation readAttributeOperation( ObjectInput in, Registries registries, Operation operation )
+        throws ClassNotFoundException, IOException
     {
-        AttributeOperation attributeOperation = (AttributeOperation)operation;
+        AttributeOperation attributeOperation = ( AttributeOperation ) operation;
         // Read the DN
         LdapDN dn = LdapDNSerializer.deserialize( in );
-        
+
         // Read the Attribute ID
         String id = in.readUTF();
-        
+
         try
         {
             // Get the AttributeType
             AttributeType at = registries.getAttributeTypeRegistry().lookup( id );
-            
+
             // De-serialize the attribute
             DefaultServerAttribute attribute = new DefaultServerAttribute( id, at );
             attribute.deserialize( in );
-            
+
             // Store the read data into the operation 
             attributeOperation.dn = dn;
-            attributeOperation.attribute = attribute; 
-                
+            attributeOperation.attribute = attribute;
+
             return operation;
         }
         catch ( NamingException ne )
         {
-            throw new IOException( "Cannot find the '" + id + "' attributeType" ); 
+            throw new IOException( "Cannot find the '" + id + "' attributeType" );
         }
     }
-    
-    
+
+
     /**
      * De-serialize an operation. This is a recursive method, as we may have 
      * composite operations.
@@ -206,92 +209,93 @@
      * @throws ClassNotFoundException
      * @throws IOException
      */
-    public static Operation deserialize( Registries registries, ObjectInput in ) throws ClassNotFoundException, IOException
+    public static Operation deserialize( Registries registries, ObjectInput in ) throws ClassNotFoundException,
+        IOException
     {
         // Read the operation type
         int opTypeValue = in.readInt();
         OperationType opType = OperationType.get( opTypeValue );
-        
+
         // Read the CSN
-        CSN csn = (CSN)in.readObject();
-        
+        CSN csn = ( CSN ) in.readObject();
+
         Operation operation = null;
 
         switch ( opType )
         {
-            case ADD_ATTRIBUTE :
+            case ADD_ATTRIBUTE:
                 // Create a new AddAttribute operation
                 operation = new AddAttributeOperation( registries );
-                
+
                 // Set the CSN
                 operation.csn = csn;
-                
+
                 // Read it
                 readAttributeOperation( in, registries, operation );
-                
+
                 return operation;
-                
-            case DELETE_ATTRIBUTE :
+
+            case DELETE_ATTRIBUTE:
                 // Create a new DeleteAttribute operation
                 operation = new DeleteAttributeOperation( registries );
-                
+
                 // Set the CSN
                 operation.csn = csn;
-                
+
                 // Read it
                 readAttributeOperation( in, registries, operation );
-                
+
                 return operation;
-        
-            case REPLACE_ATTRIBUTE :
+
+            case REPLACE_ATTRIBUTE:
                 // Create a new ReplaceAttribute operation
                 operation = new ReplaceAttributeOperation( registries );
-                
+
                 // Set the CSN
                 operation.csn = csn;
-                
+
                 // Read it
                 readAttributeOperation( in, registries, operation );
-                
+
                 return operation;
-        
-            case ADD_ENTRY :
+
+            case ADD_ENTRY:
                 // Create a new AddEntry operation
                 operation = new AddEntryOperation( registries );
-                
+
                 // Set the CSN
                 operation.csn = csn;
-                
+
                 DefaultServerEntry entry = new DefaultServerEntry( registries );
                 entry.deserialize( in );
-                ((AddEntryOperation)operation).setEntry( entry );
-                
+                ( ( AddEntryOperation ) operation ).setEntry( entry );
+
                 return operation;
-        
-            case COMPOSITE_OPERATION :
+
+            case COMPOSITE_OPERATION:
                 // Create a new Composite operation
                 operation = new CompositeOperation( registries );
-                
+
                 // Set the CSN
                 operation.csn = csn;
 
                 // Read the number of operations to deserialize
                 int nbOperations = in.readInt();
-                
+
                 for ( int i = 0; i < nbOperations; i++ )
                 {
                     Operation child = deserialize( registries, in );
                     child.csn = csn;
-                    ((CompositeOperation)operation).add( child );
+                    ( ( CompositeOperation ) operation ).add( child );
                 }
-            
+
                 return operation;
-            
-            default :
+
+            default:
                 throw new IOException( "Cannot read the unkown operation" );
         }
     }
-    
+
 
     /**
      * Serialize an operation. This is a recursive method, as an operation
@@ -305,49 +309,49 @@
     public static void serialize( Operation operation, ObjectOutput out ) throws ClassNotFoundException, IOException
     {
         OperationType opType = operation.operationType;
-        
+
         // Write the operation type
         out.writeInt( opType.ordinal() );
-        
+
         // Write the CSN
         out.writeObject( operation.csn );
-        
+
         switch ( opType )
         {
-            case REPLACE_ATTRIBUTE :
-            case DELETE_ATTRIBUTE :
-            case ADD_ATTRIBUTE :
-                AttributeOperation attrOp = (AttributeOperation)operation;
-                
+            case REPLACE_ATTRIBUTE:
+            case DELETE_ATTRIBUTE:
+            case ADD_ATTRIBUTE:
+                AttributeOperation attrOp = ( AttributeOperation ) operation;
+
                 // Write the DN
                 LdapDNSerializer.serialize( attrOp.dn, out );
-                
+
                 // Write the attribute ID
-                out.writeUTF( ((AttributeOperation)operation).attribute.getId() );
-                
+                out.writeUTF( ( ( AttributeOperation ) operation ).attribute.getId() );
+
                 // Write the attribute
-                DefaultServerAttribute attr = (DefaultServerAttribute)(attrOp.attribute);
+                DefaultServerAttribute attr = ( DefaultServerAttribute ) ( attrOp.attribute );
                 attr.serialize( out );
                 return;
-                
-            case ADD_ENTRY :
-                ((DefaultServerEntry)((AddEntryOperation)operation).getEntry()).serialize( out );
+
+            case ADD_ENTRY:
+                ( ( DefaultServerEntry ) ( ( AddEntryOperation ) operation ).getEntry() ).serialize( out );
                 return;
-                
-            case COMPOSITE_OPERATION :
-                out.writeInt( ((CompositeOperation)operation).size() );
-                
+
+            case COMPOSITE_OPERATION:
+                out.writeInt( ( ( CompositeOperation ) operation ).size() );
+
                 // Loop on all the operations
-                for ( Operation child:((CompositeOperation)operation).getChildren() )
+                for ( Operation child : ( ( CompositeOperation ) operation ).getChildren() )
                 {
                     serialize( child, out );
                 }
-                
+
                 return;
         }
     }
-    
-    
+
+
     /**
      * Read the CSN from an input stream
      * 
@@ -357,17 +361,17 @@
      */
     public void readExternal( ObjectInput in ) throws ClassNotFoundException, IOException
     {
-        csn = (CSN)in.readObject();
+        csn = ( CSN ) in.readObject();
     }
-    
-    
+
+
     /**
      * Write the CSN to an output stream
      * 
      * @param out the output stream in which the CSN is written
      * @throws IOException if we can't write to the stream
      */
-    public void writeExternal( ObjectOutput out) throws IOException
+    public void writeExternal( ObjectOutput out ) throws IOException
     {
         out.writeObject( csn );
     }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java Fri Jan  9 09:52:40 2009
@@ -114,6 +114,8 @@
     /**
      * Creates a new {@link Operation} that performs LDAP "add" operation
      * with a newly generated {@link CSN}.
+     * 
+     * @param normalizedName The entry DN
      */
     public Operation newAdd( LdapDN normalizedName, ServerEntry entry ) throws Exception
     {
@@ -134,8 +136,6 @@
 
         // Insert 'entryUUID' and 'entryDeleted'.
         ServerEntry cloneEntry = ( ServerEntry ) entry.clone();
-        cloneEntry.removeAttributes( ApacheSchemaConstants.ENTRY_UUID_AT );
-        cloneEntry.removeAttributes( ApacheSchemaConstants.ENTRY_DELETED_AT );
         cloneEntry.put( ApacheSchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
         cloneEntry.put( ApacheSchemaConstants.ENTRY_DELETED_AT, "FALSE" );
 

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java Fri Jan  9 09:52:40 2009
@@ -36,14 +36,13 @@
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.directory.mitosis.common.CSN;
-import org.apache.directory.mitosis.common.Constants;
-import org.apache.directory.mitosis.common.DefaultCSN;
+import org.apache.directory.mitosis.common.CSNFactory;
 
 
 public class EntryUtil
 {
     @SuppressWarnings("unchecked")
-    public static boolean isEntryUpdatable( CoreSession coreSession, LdapDN name, CSN newCSN ) 
+    public static boolean isEntryUpdatable( CSNFactory csnFactory, CoreSession coreSession, LdapDN name, CSN newCSN ) 
         throws Exception
     {
         PartitionNexus nexus = coreSession.getDirectoryService().getPartitionNexus();
@@ -71,11 +70,11 @@
                 
                 if ( val instanceof byte[] )
                 {
-                    oldCSN = new DefaultCSN( StringTools.utf8ToString( (byte[])val ) );
+                    oldCSN = csnFactory.newInstance( StringTools.utf8ToString( (byte[])val ) );
                 }
                 else
                 {
-                    oldCSN = new DefaultCSN( (String)val );
+                    oldCSN = csnFactory.newInstance( (String)val );
                 }
             }
             catch ( IllegalArgumentException e )

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java Fri Jan  9 09:52:40 2009
@@ -21,8 +21,8 @@
 
 
 import org.apache.directory.mitosis.common.CSN;
+import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.common.Constants;
-import org.apache.directory.mitosis.common.DefaultCSN;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.Operation;
 import org.apache.directory.mitosis.operation.OperationFactory;
@@ -158,15 +158,30 @@
      */
     private String name = DEFAULT_SERVICE_NAME;
 
+    /** The Directory service instance */
     private DirectoryService directoryService;
-    private ReplicationConfiguration configuration;
+    
+    /** The registries */
+    private Registries registries;
+
+    /** The directory nexus */
     private PartitionNexus nexus;
+
+    /** A reference to the replication configuration */
+    private ReplicationConfiguration configuration;
+    
+    
     private OperationFactory operationFactory;
     private ReplicationStore store;
     private NioSocketAcceptor registry;
     private final ClientConnectionManager clientConnectionManager = new ClientConnectionManager( this );
-    private Registries registries;
 
+    /** A unique CSN factory instance */
+    private CSNFactory csnFactory;
+    
+    
+    /** Stores the number of milli seconds per day */
+    private static final long MS_PER_DAY = 24L * 60L * 60L * 1000L;
 
     /**
      * Creates a new instance of ReplicationInterceptor.
@@ -229,6 +244,10 @@
         // Initialize store and service
         store.open( directoryService, configuration );
         boolean serviceStarted = false;
+        
+        // Create the CSN factory
+        csnFactory = new CSNFactory();
+        
         try
         {
             startNetworking();
@@ -331,9 +350,9 @@
             throw new NamingException( "No namingContexts attributes in rootDSE." );
         }
 
-        CSN purgeCSN = new DefaultCSN( System.currentTimeMillis() - configuration.getLogMaxAge() * 1000L * 60L * 60L
-            * 24L, // convert days to millis
-            "ZZZZZZZZZZZZZZZZ", Integer.MAX_VALUE );
+        long timeout = System.currentTimeMillis() - configuration.getLogMaxAge() * MS_PER_DAY;
+        CSN purgeCSN = csnFactory.newInstance( timeout );
+        
         ExprNode filter;
 
         try
@@ -418,7 +437,7 @@
     {
         Operation op = operationFactory.newAdd( 
             addContext.getDn(), addContext.getEntry() );
-        op.execute( nexus, store, addContext.getSession() );
+        op.execute( nexus, store, addContext.getSession(), csnFactory );
     }
 
 
@@ -426,14 +445,14 @@
     public void delete( NextInterceptor next, DeleteOperationContext deleteContext ) throws Exception
     {
         Operation op = operationFactory.newDelete( deleteContext.getDn() );
-        op.execute( nexus, store, deleteContext.getSession() );
+        op.execute( nexus, store, deleteContext.getSession(), csnFactory );
     }
 
 
     public void modify( NextInterceptor next, ModifyOperationContext modifyContext ) throws Exception
     {
         Operation op = operationFactory.newModify( modifyContext );
-        op.execute( nexus, store, modifyContext.getSession() );
+        op.execute( nexus, store, modifyContext.getSession(), csnFactory );
     }
 
 
@@ -441,7 +460,7 @@
     public void move( NextInterceptor next, MoveOperationContext moveOpContext ) throws Exception
     {
         Operation op = operationFactory.newMove( moveOpContext.getDn(), moveOpContext.getParent() );
-        op.execute( nexus, store, moveOpContext.getSession() );
+        op.execute( nexus, store, moveOpContext.getSession(), csnFactory );
     }
 
 
@@ -451,7 +470,7 @@
         Operation op = operationFactory.newMove( moveAndRenameOpContext.getDn(),
                 moveAndRenameOpContext.getParent(), moveAndRenameOpContext.getNewRdn(),
                 moveAndRenameOpContext.getDelOldDn() );
-        op.execute( nexus, store, moveAndRenameOpContext.getSession() );
+        op.execute( nexus, store, moveAndRenameOpContext.getSession(), csnFactory );
     }
 
 
@@ -459,7 +478,7 @@
     public void rename( NextInterceptor next, RenameOperationContext renameOpContext ) throws Exception
     {
         Operation op = operationFactory.newModifyRn( renameOpContext.getDn(), renameOpContext.getNewRdn(), renameOpContext.getDelOldDn() );
-        op.execute( nexus, store, renameOpContext.getSession() );
+        op.execute( nexus, store, renameOpContext.getSession(), csnFactory );
     }
 
 
@@ -581,7 +600,16 @@
         return entry.contains( ApacheSchemaConstants.ENTRY_DELETED_AT, "TRUE" );
     }
 
+    
+    /**
+     * @return The CSNFactory
+     */
+    public CSNFactory getCsnFactory()
+    {
+        return csnFactory;
+    }
 
+    
     public DirectoryService getDirectoryService()
     {
         return directoryService;

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageDecoder.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageDecoder.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageDecoder.java Fri Jan  9 09:52:40 2009
@@ -25,7 +25,7 @@
 import java.nio.charset.CharsetDecoder;
 
 import org.apache.directory.mitosis.common.CSNVector;
-import org.apache.directory.mitosis.common.DefaultCSN;
+import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.service.protocol.Constants;
 import org.apache.directory.mitosis.service.protocol.message.BaseMessage;
 import org.apache.directory.mitosis.service.protocol.message.BeginLogEntriesAckMessage;
@@ -87,7 +87,7 @@
                 throw new ProtocolDecoderException( "Invalid replicaId", e );
             }
 
-            updateVector.setCSN( new DefaultCSN( in.getLong(), replicaId, in.getInt() ) );
+            updateVector.setCSN( new CSN( in.getLong(), replicaId, in.getInt() ) );
         }
     }
 

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java Fri Jan  9 09:52:40 2009
@@ -22,7 +22,6 @@
 
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.common.CSNVector;
-import org.apache.directory.mitosis.common.DefaultCSN;
 import org.apache.directory.mitosis.common.Replica;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.AddEntryOperation;
@@ -422,11 +421,11 @@
 
                     if ( val instanceof byte[] )
                     {
-                        csn = new DefaultCSN( StringTools.utf8ToString( ( byte[] ) val ) );
+                        csn = new CSN( StringTools.utf8ToString( ( byte[] ) val ) );
                     }
                     else
                     {
-                        csn = new DefaultCSN( ( String ) val );
+                        csn = new CSN( ( String ) val );
                     }
                 }
                 catch ( IllegalArgumentException ex )

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java Fri Jan  9 09:52:40 2009
@@ -20,10 +20,12 @@
 package org.apache.directory.mitosis.service.protocol.handler;
 
 
+import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.common.CSNVector;
 import org.apache.directory.mitosis.common.Replica;
 import org.apache.directory.mitosis.operation.Operation;
 import org.apache.directory.mitosis.service.ReplicationContext;
+import org.apache.directory.mitosis.service.ReplicationInterceptor;
 import org.apache.directory.mitosis.service.ReplicationContext.State;
 import org.apache.directory.mitosis.service.protocol.Constants;
 import org.apache.directory.mitosis.service.protocol.message.BeginLogEntriesAckMessage;
@@ -35,6 +37,8 @@
 import org.apache.directory.mitosis.service.protocol.message.LoginAckMessage;
 import org.apache.directory.mitosis.service.protocol.message.LoginMessage;
 import org.apache.directory.mitosis.store.ReplicationStore;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.interceptor.Interceptor;
 import org.apache.mina.core.session.IdleStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -193,10 +197,14 @@
 
         Operation op = message.getOperation();
         LogEntryAckMessage ack = null;
+        
         try
         {
-            op.execute( ctx.getDirectoryService().getPartitionNexus(), ctx.getConfiguration().getStore(),
-                        ctx.getDirectoryService().getSession() );
+            DirectoryService directoryService = ctx.getDirectoryService();
+            Interceptor interceptorInstance = directoryService.getInterceptor( ReplicationInterceptor.class.getName() ); 
+            CSNFactory csnFactory = ((ReplicationInterceptor)interceptorInstance).getCsnFactory();
+            op.execute( directoryService.getPartitionNexus(), ctx.getConfiguration().getStore(),
+                directoryService.getSession(), csnFactory );
             
             ack = new LogEntryAckMessage( message.getSequence(), Constants.OK );
         }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationLogIterator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationLogIterator.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationLogIterator.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationLogIterator.java Fri Jan  9 09:52:40 2009
@@ -26,7 +26,7 @@
 import java.sql.Statement;
 
 import org.apache.directory.mitosis.common.CSN;
-import org.apache.directory.mitosis.common.DefaultCSN;
+import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.operation.Operation;
 import org.apache.directory.mitosis.operation.OperationCodec;
 import org.apache.directory.mitosis.store.ReplicationLogIterator;
@@ -77,7 +77,7 @@
             String replicaId = rs.getString( 1 );
             long timestamp = rs.getLong( 2 );
             int operationSequence = rs.getInt( 3 );
-            return new DefaultCSN( timestamp, replicaId, operationSequence );
+            return new CSN( timestamp, replicaId, operationSequence );
         }
         catch ( Exception e )
         {

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStore.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStore.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStore.java Fri Jan  9 09:52:40 2009
@@ -23,7 +23,6 @@
 import org.apache.commons.dbcp.BasicDataSource;
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.common.CSNVector;
-import org.apache.directory.mitosis.common.DefaultCSN;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.Operation;
 import org.apache.directory.mitosis.operation.OperationCodec;
@@ -550,7 +549,7 @@
         {
             for ( String knownReplicaId : knownReplicaIds )
             {
-                newUV.setCSN( new DefaultCSN( 0, knownReplicaId, 0 ) );
+                newUV.setCSN( new CSN( 0, knownReplicaId, 0 ) );
             }
         }
 
@@ -717,7 +716,7 @@
                 
                 if ( rs.next() )
                 {
-                    result.setCSN( new DefaultCSN( rs.getLong( 1 ), replicaId, rs.getInt( 2 ) ) );
+                    result.setCSN( new CSN( rs.getLong( 1 ), replicaId, rs.getInt( 2 ) ) );
                 }
                 
                 rs.close();

Copied: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNFactoryTest.java (from r732113, directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/DefaultCSNFactoryTest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNFactoryTest.java?p2=directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNFactoryTest.java&p1=directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/DefaultCSNFactoryTest.java&r1=732113&r2=733098&rev=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/DefaultCSNFactoryTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNFactoryTest.java Fri Jan  9 09:52:40 2009
@@ -29,7 +29,7 @@
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DefaultCSNFactoryTest extends TestCase
+public class CSNFactoryTest extends TestCase
 {
     private static final int NUM_GENERATES = 10;
 
@@ -41,7 +41,7 @@
     public void testUnique()
     {
         String replicaID = "test";
-        DefaultCSNFactory defaultCSNFactory = new DefaultCSNFactory();
+        CSNFactory defaultCSNFactory = new CSNFactory();
 
         CSN[] csns = new CSN[NUM_GENERATES];
 

Copied: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNTest.java (from r732113, directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/DefaultCSNTest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNTest.java?p2=directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNTest.java&p1=directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/DefaultCSNTest.java&r1=732113&r2=733098&rev=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/DefaultCSNTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNTest.java Fri Jan  9 09:52:40 2009
@@ -20,23 +20,28 @@
 package org.apache.directory.mitosis.common;
 
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 
 /**
  * 
- * Test for the SimpleCSN class
+ * Test for the CSN class
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DefaultCSNTest extends TestCase
+public class CSNTest
 {
 
+    @Test
     public void testCSN()
     {
         long ts = System.currentTimeMillis();
 
-        CSN csn = new DefaultCSN( Long.toString( ts, 16 ) + ":abcdefghi0123:" + 1 );
+        CSN csn = new CSN( Long.toString( ts, 16 ) + ":abcdefghi0123:" + 1 );
 
         assertEquals( ts, csn.getTimestamp() );
         assertEquals( 1, csn.getOperationSequence() );
@@ -44,11 +49,12 @@
     }
 
 
+    @Test
     public void testCSNEmpty()
     {
         try
         {
-            new DefaultCSN( "" );
+            new CSN( "" );
             fail();
         }
         catch ( AssertionError ae )
@@ -62,11 +68,12 @@
     }
 
 
+    @Test
     public void testCSNTSOnly()
     {
         try
         {
-            new DefaultCSN( "123" );
+            new CSN( "123" );
             fail();
         }
         catch ( AssertionError ae )
@@ -80,11 +87,12 @@
     }
 
 
+    @Test
     public void testCSNInvalidTS()
     {
         try
         {
-            new DefaultCSN( "zzz:abc:1" );
+            new CSN( "zzz:abc:1" );
             fail();
         }
         catch ( AssertionError ae )
@@ -98,11 +106,12 @@
     }
 
 
+    @Test
     public void testCSNNoTS()
     {
         try
         {
-            new DefaultCSN( ":abc:1" );
+            new CSN( ":abc:1" );
             fail();
         }
         catch ( AssertionError ae )
@@ -116,11 +125,12 @@
     }
 
 
+    @Test
     public void testCSNInavlidReplica()
     {
         try
         {
-            new DefaultCSN( "123:*:1" );
+            new CSN( "123:*:1" );
             fail();
         }
         catch ( AssertionError ae )
@@ -134,11 +144,12 @@
     }
 
 
+    @Test
     public void testCSNNoReplica()
     {
         try
         {
-            new DefaultCSN( "123::1" );
+            new CSN( "123::1" );
             fail();
         }
         catch ( AssertionError ae )
@@ -152,11 +163,12 @@
     }
 
 
+    @Test
     public void testCSNInavlidOpSeq()
     {
         try
         {
-            new DefaultCSN( "123:abc:zzz" );
+            new CSN( "123:abc:zzz" );
             fail();
         }
         catch ( AssertionError ae )
@@ -170,11 +182,12 @@
     }
 
 
+    @Test
     public void testCSNEmptyOpSeq()
     {
         try
         {
-            new DefaultCSN( "123:abc:" );
+            new CSN( "123:abc:" );
             fail();
         }
         catch ( AssertionError ae )
@@ -188,11 +201,12 @@
     }
 
 
+    @Test
     public void testCSNNoOpSeq()
     {
         try
         {
-            new DefaultCSN( "123:abc" );
+            new CSN( "123:abc" );
             fail();
         }
         catch ( AssertionError ae )
@@ -206,9 +220,10 @@
     }
 
 
+    @Test
     public void testCSNToBytes()
     {
-        CSN csn = new DefaultCSN( "0123456789abcdef:test:5678cdef" );
+        CSN csn = new CSN( "0123456789abcdef:test:5678cdef" );
 
         byte[] bytes = csn.toBytes();
 
@@ -227,7 +242,7 @@
 
         assertEquals( "test", new String( bytes, 12, bytes.length - 12 ) );
 
-        CSN deserializedCSN = new DefaultCSN( bytes );
+        CSN deserializedCSN = new CSN( bytes );
         assertEquals( csn, deserializedCSN );
     }
 }

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageCodecTest.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageCodecTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageCodecTest.java Fri Jan  9 09:52:40 2009
@@ -20,8 +20,8 @@
 package org.apache.directory.mitosis.service.protocol.codec;
 
 
+import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.common.CSNVector;
-import org.apache.directory.mitosis.common.DefaultCSN;
 import org.apache.directory.mitosis.service.protocol.Constants;
 import org.apache.directory.mitosis.service.protocol.codec.BeginLogEntriesAckMessageDecoder;
 import org.apache.directory.mitosis.service.protocol.codec.BeginLogEntriesAckMessageEncoder;
@@ -33,18 +33,19 @@
 
     private static final CSNVector PURGE_VECTOR = new CSNVector();
     private static final CSNVector UPDATE_VECTOR = new CSNVector();
+    private static CSNFactory csnFactory = new CSNFactory();
 
     static
     {
-        PURGE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() - 400, "replica0", 3456 ) );
-        PURGE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() - 300, "replica1", 9012 ) );
-        PURGE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() - 200, "replica2", 5678 ) );
-        PURGE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() - 100, "replica3", 1234 ) );
-
-        UPDATE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() + 000, "replica0", 1234 ) );
-        UPDATE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() + 100, "replica1", 5678 ) );
-        UPDATE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() + 200, "replica2", 9012 ) );
-        UPDATE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() + 300, "replica3", 3456 ) );
+        PURGE_VECTOR.setCSN( csnFactory.newInstance( System.currentTimeMillis() - 400, "replica0", 3456 ) );
+        PURGE_VECTOR.setCSN( csnFactory.newInstance( System.currentTimeMillis() - 300, "replica1", 9012 ) );
+        PURGE_VECTOR.setCSN( csnFactory.newInstance( System.currentTimeMillis() - 200, "replica2", 5678 ) );
+        PURGE_VECTOR.setCSN( csnFactory.newInstance( System.currentTimeMillis() - 100, "replica3", 1234 ) );
+
+        UPDATE_VECTOR.setCSN( csnFactory.newInstance( System.currentTimeMillis() + 000, "replica0", 1234 ) );
+        UPDATE_VECTOR.setCSN( csnFactory.newInstance( System.currentTimeMillis() + 100, "replica1", 5678 ) );
+        UPDATE_VECTOR.setCSN( csnFactory.newInstance( System.currentTimeMillis() + 200, "replica2", 9012 ) );
+        UPDATE_VECTOR.setCSN( csnFactory.newInstance( System.currentTimeMillis() + 300, "replica3", 3456 ) );
     }
 
 

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java Fri Jan  9 09:52:40 2009
@@ -26,7 +26,7 @@
 import javax.naming.InvalidNameException;
 import javax.naming.NamingException;
 
-import org.apache.directory.mitosis.common.DefaultCSN;
+import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.operation.AddAttributeOperation;
 import org.apache.directory.mitosis.service.protocol.codec.LogEntryMessageDecoder;
 import org.apache.directory.mitosis.service.protocol.codec.LogEntryMessageEncoder;
@@ -45,6 +45,8 @@
 
     private static DefaultDirectoryService service;
     
+    private static CSNFactory csnFactory = new CSNFactory();
+    
     static 
     {
         oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
@@ -62,7 +64,7 @@
                 1234, 
                 new AddAttributeOperation( 
                     service.getRegistries(),
-                    new DefaultCSN( System.currentTimeMillis(),
+                    csnFactory.newInstance( System.currentTimeMillis(),
                         "testReplica0", 1234 ), 
                     new LdapDN( "ou=system" ).normalize( oids ),
                     new DefaultServerAttribute( "ou", 

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java?rev=733098&r1=733097&r2=733098&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java Fri Jan  9 09:52:40 2009
@@ -50,8 +50,6 @@
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.common.CSNVector;
-import org.apache.directory.mitosis.common.DefaultCSN;
-import org.apache.directory.mitosis.common.DefaultCSNFactory;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.AddAttributeOperation;
 import org.apache.directory.mitosis.operation.AddEntryOperation;
@@ -70,7 +68,7 @@
     private static final String OTHER_REPLICA_ID_2 = "OTHER_REPLICA_2";
     private static final File DB_PATH = new File( "target/testDB" );
 
-    private final CSNFactory csnFactory = new DefaultCSNFactory();
+    private final CSNFactory csnFactory = new CSNFactory();
     private DerbyReplicationStore store;
     private int testCount;
     private long startTime;
@@ -281,7 +279,7 @@
         CSN csn;
         ReplicationLogIterator it;
 
-        it = store.getLogs( new DefaultCSN( 0, REPLICA_ID, 0 ), false );
+        it = store.getLogs( csnFactory.newInstance( 0, REPLICA_ID, 0 ), false );
         it.next();
         csn = it.getOperation( service.getRegistries() ).getCSN();
         it.close();
@@ -290,7 +288,7 @@
         Assert.assertEquals( 1, store.removeLogs( csn, true ) );
         Assert.assertEquals( 0, store.getLogSize( REPLICA_ID ) );
 
-        it = store.getLogs( new DefaultCSN( 0, OTHER_REPLICA_ID, 0 ), false );
+        it = store.getLogs( csnFactory.newInstance( 0, OTHER_REPLICA_ID, 0 ), false );
         Assert.assertTrue( it.next() );
         csn = it.getOperation( service.getRegistries() ).getCSN();
         it.close();
@@ -305,10 +303,10 @@
 
     private void subTestVectors() throws Exception
     {
-        CSN csnA = new DefaultCSN( 0, REPLICA_ID, 0 );
-        CSN csnB = new DefaultCSN( 1, REPLICA_ID, 0 );
-        CSN csnC = new DefaultCSN( 0, OTHER_REPLICA_ID_2, 0 );
-        CSN csnD = new DefaultCSN( 0, OTHER_REPLICA_ID_2, 1 );
+        CSN csnA = csnFactory.newInstance( 0, REPLICA_ID, 0 );
+        CSN csnB = csnFactory.newInstance( 1, REPLICA_ID, 0 );
+        CSN csnC = csnFactory.newInstance( 0, OTHER_REPLICA_ID_2, 0 );
+        CSN csnD = csnFactory.newInstance( 0, OTHER_REPLICA_ID_2, 1 );
         AttributeType at = service.getRegistries().getAttributeTypeRegistry().lookup( "ou" );
         EntryAttribute attribute = new DefaultServerAttribute( at, "test" );
         store.putLog( new AddAttributeOperation( service.getRegistries(), csnA, LdapDN.EMPTY_LDAPDN, attribute ) );



Mime
View raw message