directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r688929 - 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 Tue, 26 Aug 2008 01:00:56 GMT
Author: akarasulu
Date: Mon Aug 25 18:00:55 2008
New Revision: 688929

URL: http://svn.apache.org/viewvc?rev=688929&view=rev
Log:
Reverting modifications in revisions that break the build: 688907 688908 688573.  Would have fixed the breakage in two tests but did not have time to figure out what was not committed.  Complaints were about missing signatures.  To correct revert this commit in the mitosis module.

Added:
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultUUID.java
      - copied unchanged from r688906, directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultUUID.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultUUIDFactory.java
      - copied unchanged from r688906, directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultUUIDFactory.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/ReplicaId.java
      - copied unchanged from r688572, directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/ReplicaId.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/UUID.java
      - copied unchanged from r688906, directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/UUID.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/UUIDFactory.java
      - copied unchanged from r688906, directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/UUIDFactory.java
Modified:
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSN.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNFactory.java
    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/common/DefaultCSN.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/DefaultCSNFactory.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/Replica.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaIdPropertyEditor.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/CompositeOperation.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/service/ClientConnectionManager.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/codec/BeginLogEntriesAckMessageEncoder.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesMessageEncoder.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesAckMessageEncoder.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesMessageEncoder.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryAckMessageEncoder.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageEncoder.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageDecoder.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageEncoder.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageDecoder.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageEncoder.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/message/LoginAckMessage.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/message/LoginMessage.java
    directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/ReplicationStore.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/main/java/org/apache/directory/mitosis/util/OctetString.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.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/service/protocol/codec/LoginAckMessageCodecTest.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageCodecTest.java
    directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSN.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSN.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSN.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSN.java Mon Aug 25 18:00:55 2008
@@ -29,25 +29,13 @@
  * 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 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 interface CSN extends Serializable, Comparable<CSN>
+public interface CSN extends Serializable, Comparable
 {
     /**
      * Returns GMT timestamp of modification.
@@ -58,7 +46,7 @@
     /**
      * Returns replica ID.
      */
-    String getReplicaId();
+    ReplicaId getReplicaId();
 
 
     /**

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNFactory.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNFactory.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/CSNFactory.java Mon Aug 25 18:00:55 2008
@@ -36,4 +36,15 @@
      *        string.
      */
     CSN newInstance( String replicaId );
+
+
+    /**
+     * Returns a new {@link CSN}.
+     * Generated CSN can be duplicate if user generates CSNs more than 2G 
+     * times a milliseconds.
+     * 
+     * @param replicaId Replica ID.  ReplicaID must be 1-8 digit alphanumeric
+     *        string.
+     */
+    CSN newInstance( ReplicaId replicaId );
 }

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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -33,8 +33,8 @@
 /**
  * Creates a set of {@link CSN}s, which is defined in LDUP specification.
  * Each {@link CSN} in the same {@link CSNVector} has different
- * Replica Id from each other.  Its data structure is 
- * similar to a {@link Map} whose key is the Replica Id.
+ * {@link ReplicaId} component from each other.  Its data structure is 
+ * similar to a {@link Map} whose key is {@link ReplicaId}.
  * <p>
  * {@link CSNVector} is usually used to represent 'Update Vector (UV)' and
  * 'Purge Vector (PV)'.  Please refer to the LDUP specification and other 
@@ -53,7 +53,7 @@
      */
     private static final long serialVersionUID = 1L;
 
-    private final Map<String,CSN> csns = new HashMap<String,CSN>();
+    private final Map<ReplicaId,CSN> csns = new HashMap<ReplicaId,CSN>();
 
     /**
      * Creates a new empty instance.
@@ -64,7 +64,7 @@
 
     /**
      * Adds the specified <tt>csn</tt> to this vector.  If there's a
-     * {@link CSN} with the same Replica Id, it is replaced by
+     * {@link CSN} with the same {@link ReplicaId}, it is replaced by
      * the specified <tt>csn</tt>.
      */
     public void setCSN( CSN csn )
@@ -75,7 +75,7 @@
 
     /**
      * Adds all {@link CSN}s that the specified <tt>vector</tt> contains to
-     * this vector.  If there's a {@link CSN} with the same Replica Id
+     * this vector.  If there's a {@link CSN} with the same {@link ReplicaId}
      * in this vector, it is replaced by the {@link CSN} in the specified
      * <tt>vector</tt>.
      */
@@ -94,29 +94,29 @@
      * 
      * @return <tt>null</tt> if there's no match
      */
-    public CSN getCSN( String replicaId )
+    public CSN getCSN( ReplicaId replicaId )
     {
         return csns.get( replicaId );
     }
 
 
     /**
-     * Removed the {@link CSN} whith the specified <tt>replica Id</tt> from
+     * Removed the {@link CSN} whith the specified <tt>replicaId</tt> from
      * this vector and returns the removed {@link CSN}.
      * 
      * @return <tt>null</tt> if there's no match
      */
-    public CSN removeCSN( String replicaId )
+    public CSN removeCSN( ReplicaId replicaId )
     {
         return csns.remove( replicaId );
     }
 
 
     /**
-     * Returns the {@link Set} of the Replica Ids extracted from
+     * Returns the {@link Set} of the {@link ReplicaId}s extracted from
      * the {@link CSN}s in this vector.
      */
-    public Set<String> getReplicaIds()
+    public Set<ReplicaId> getReplicaIds()
     {
         return csns.keySet();
     }

Modified: 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/DefaultCSN.java?rev=688929&r1=688928&r2=688929&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/DefaultCSN.java Mon Aug 25 18:00:55 2008
@@ -30,7 +30,7 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DefaultCSN implements CSN, Serializable, Comparable<CSN>
+public class DefaultCSN implements CSN, Serializable, Comparable
 {
     /**
      * Declares the Serial Version Uid.
@@ -45,7 +45,7 @@
     private final long timestamp;
 
     /** The server identification */
-    private final String replicaId;
+    private final ReplicaId replicaId;
 
     /** The operation number in the same timestamp */
     private final int operationSequence;
@@ -64,7 +64,7 @@
      * @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 DefaultCSN( long timestamp, ReplicaId replicaId, int operationSequence )
     {
         this.timestamp = timestamp;
         this.replicaId = replicaId;
@@ -106,7 +106,7 @@
 
         try
         {
-            replicaId = value.substring( sepTS + 1, sepID );
+            replicaId = new ReplicaId( value.substring( sepTS + 1, sepID ) );
         }
         catch ( IllegalArgumentException iae )
         {
@@ -146,7 +146,7 @@
             chars[i - 12] = ( char ) ( value[i] & 0x00FF );
         }
 
-        replicaId = new String( chars );
+        replicaId = new ReplicaId( new String( chars ) );
         bytes = value;
     }
 
@@ -186,7 +186,7 @@
     {
         if ( bytes == null )
         {
-            String id = replicaId;
+            String id = replicaId.getId();
             byte[] bb = new byte[8 + id.length() + 4];
 
             bb[0] = ( byte ) ( timestamp >> 56 );
@@ -226,7 +226,7 @@
     /**
      * @return The replicaId
      */
-    public String getReplicaId()
+    public ReplicaId getReplicaId()
     {
         return replicaId;
     }
@@ -301,7 +301,7 @@
      * @return  a negative integer, zero, or a positive integer as this object
      *      is less than, equal to, or greater than the specified object.
      */
-    public int compareTo( CSN o )
+    public int compareTo( Object o )
     {
         CSN that = ( CSN ) o;
         long thatTimestamp = that.getTimestamp();

Modified: 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/DefaultCSNFactory.java?rev=688929&r1=688928&r2=688929&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/DefaultCSNFactory.java Mon Aug 25 18:00:55 2008
@@ -43,13 +43,17 @@
      * @param replicaId Replica ID.  ReplicaID must be 1-8 digit alphanumeric
      *        string.
      */
-    public synchronized CSN newInstance( String replicaId )
+    public CSN newInstance( String replicaId )
+    {
+        return newInstance( new ReplicaId( replicaId ) );
+    }
+
+
+    public synchronized CSN newInstance( ReplicaId replicaId )
     {
         long newTimestamp = System.currentTimeMillis();
-        
         if ( operationSequence == Integer.MAX_VALUE )
         {
-            // Roll over when reaching the limit.
             operationSequence = 0;
         }
 

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/Replica.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/Replica.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/Replica.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/common/Replica.java Mon Aug 25 18:00:55 2008
@@ -41,7 +41,7 @@
     private static final boolean IS_DEBUG = log.isDebugEnabled();
 
     /** The replicaId */
-    private final String id;
+    private final ReplicaId id;
 
     /** The server address */
     private final InetSocketAddress address;
@@ -82,7 +82,7 @@
             throw new IllegalArgumentException( "Port number not found in replica : " + replica );
         }
 
-        id = replica.substring( 0, atPos );
+        id = new ReplicaId( replica.substring( 0, atPos ) );
         String server = replica.substring( atPos + 1, colonPos );
         int port = -1;
 
@@ -120,7 +120,7 @@
      * @param id The Replica Id
      * @param address The server address.
      */
-    public Replica( String id, InetSocketAddress address )
+    public Replica( ReplicaId id, InetSocketAddress address )
     {
         assert id != null;
         assert address != null;
@@ -142,7 +142,7 @@
     /**
      * @return the replica Id
      */
-    public String getId()
+    public ReplicaId getId()
     {
         return id;
     }
@@ -150,7 +150,7 @@
 
     /**
      * Compute the instance's hash code
-     * @return the instance's hash code 
+     * @return the instance's hashcode 
      */
     public int hashCode()
     {

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaIdPropertyEditor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaIdPropertyEditor.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaIdPropertyEditor.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaIdPropertyEditor.java Mon Aug 25 18:00:55 2008
@@ -22,13 +22,12 @@
 
 import java.beans.PropertyEditor;
 import java.beans.PropertyEditorSupport;
-import java.util.regex.Pattern;
 
-import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.directory.mitosis.common.ReplicaId;
 
 
 /**
- * A {@link PropertyEditor} that converts strings into Replica Ids
+ * A {@link PropertyEditor} that converts strings into {@link ReplicaId}s
  * and vice versa.
  *
  * @author The Apache Directory Project (dev@directory.apache.org)
@@ -36,9 +35,6 @@
  */
 public class ReplicaIdPropertyEditor extends PropertyEditorSupport
 {
-    /** The replica pattern. */
-    private static final Pattern REPLICA_ID_PATTERN = Pattern.compile( "[-_A-Z0-9]{1,16}" );
-
     public ReplicaIdPropertyEditor()
     {
         super();
@@ -51,39 +47,9 @@
     }
 
 
-    /**
-     * Check a new instance of ReplicaId. The id must be a String 
-     * which respect the pattern :
-     * 
-     * [-_a-zA-Z0-9]*
-     * 
-     * and must be between 1 and 16 chars length
-     *
-     * @param id The replica to check
-     * @return true if the replicaId is well formed
-     */
-    public static boolean check( String id )
-    {
-        if ( StringTools.isEmpty( id ) )
-        {
-            throw new IllegalArgumentException( "Empty ID: " + id );
-        }
-
-        String tmpId = id.trim().toUpperCase();
-
-        if ( !REPLICA_ID_PATTERN.matcher( tmpId ).matches() )
-        {
-            return false;
-        }
-
-        return true;
-    }
-    
-    
     public String getAsText()
     {
         Object val = getValue();
-        
         if ( val == null )
         {
             return "";
@@ -98,21 +64,13 @@
     public void setAsText( String text ) throws IllegalArgumentException
     {
         text = text.trim();
-        
         if ( text.length() == 0 )
         {
             setValue( null );
         }
         else
         {
-            if ( check( text ) )
-            {
-                setValue( text );
-            }
-            else
-            {
-                setValue( null );
-            }
+            setValue( new ReplicaId( text ) );
         }
     }
 }

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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -24,6 +24,7 @@
 import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
@@ -31,7 +32,11 @@
 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.ReplicaId;
 import org.apache.directory.mitosis.common.DefaultCSNFactory;
+import org.apache.directory.mitosis.common.DefaultUUIDFactory;
+import org.apache.directory.mitosis.common.UUID;
+import org.apache.directory.mitosis.common.UUIDFactory;
 import org.apache.directory.mitosis.service.ReplicationInterceptor;
 import org.apache.directory.mitosis.store.ReplicationStore;
 import org.apache.directory.mitosis.store.derby.DerbyReplicationStore;
@@ -58,7 +63,7 @@
     private static Logger log = LoggerFactory.getLogger( ReplicationConfiguration.class );
 
     /** The server identifier */ 
-    private String replicaId;
+    private ReplicaId replicaId;
     
     /** Default values for the communication part */
     private int serverPort = DEFAULT_SERVER_PORT;
@@ -69,6 +74,7 @@
     private final Set<Replica> peerReplicas = new HashSet<Replica>();
     
     /** Factories */
+    private UUIDFactory uuidFactory = new DefaultUUIDFactory();
     private CSNFactory csnFactory = new DefaultCSNFactory();
     private ReplicationStore store = new DerbyReplicationStore();
     
@@ -151,7 +157,6 @@
         {
             replicationInterval = 0;
         }
-        
         this.replicationInterval = replicationInterval;
     }
 
@@ -215,21 +220,24 @@
     /**
      * Sets the remote peer replica list.
      */
-    public void setPeerReplicas( Set<Replica> replicas )
+    public void setPeerReplicas( Set replicas )
     {
         assert replicas != null;
 
         Set<Replica> normalizedReplicas = new HashSet<Replica>();
+        Iterator i = replicas.iterator();
         
-        for ( Object replica:replicas )
+        while ( i.hasNext() )
         {
-            if ( replica instanceof Replica )
+            Object o = i.next();
+            
+            if ( o instanceof Replica )
             {
-                normalizedReplicas.add( ( Replica ) replica );
+                normalizedReplicas.add( ( Replica ) o );
             }
             else
             {
-                normalizedReplicas.add( new Replica( replica.toString() ) );
+                normalizedReplicas.add( new Replica( o.toString() ) );
             }
         }
         
@@ -240,7 +248,7 @@
     /**
      * Returns the ID of the replica this configuration is configuring.
      */
-    public String getReplicaId()
+    public ReplicaId getReplicaId()
     {
         return replicaId;
     }
@@ -248,8 +256,9 @@
     /**
      * Sets the ID of the replica this configuration is configuring.
      */
-    public void setReplicaId( String replicaId )
+    public void setReplicaId( ReplicaId replicaId )
     {
+        assert replicaId != null;
         this.replicaId = replicaId;
     }
 
@@ -274,6 +283,26 @@
     }
 
     /**
+     * Returns the {@link UUIDFactory} which generates {@link UUID}s for
+     * new directory entries.  The default implementation is
+     * {@link DefaultUUIDFactory}.
+     */
+    public UUIDFactory getUuidFactory()
+    {
+        return uuidFactory;
+    }
+
+    /**
+     * Sets the {@link UUIDFactory} which generates {@link UUID}s for
+     * new directory entries.  The default implementation is
+     * {@link DefaultUUIDFactory}.
+     */
+    public void setUuidFactory( UUIDFactory uuidFactory )
+    {
+        this.uuidFactory = uuidFactory;
+    }
+
+    /**
      * Returns the maximum age (days) of change logs stored in
      * {@link ReplicationStore}.  Any change logs and deleted entries
      * older than this value will be purged periodically.  The default value
@@ -337,6 +366,12 @@
             throw new ReplicationConfigurationException( "Invalid response timeout: " + responseTimeout );
         }
 
+        if ( uuidFactory == null )
+        {
+            log.error( "The UUID factory has not been declared" );
+            throw new ReplicationConfigurationException( "UUID factory is not specified." );
+        }
+
         if ( csnFactory == null )
         {
             log.error( "The CSN factory has not been declared" );
@@ -362,7 +397,7 @@
         Map<String, Integer> servers = new HashMap<String, Integer>();
 
         // Initialize the set with this server replicaId
-        ids.add( replicaId );
+        ids.add( replicaId.getId() );
 
         // And store the local inetadress
         servers.put( "localhost", serverPort );
@@ -380,7 +415,7 @@
 
         for ( Replica peer:peerReplicas )
         {
-            if ( ids.contains( peer.getId() ) )
+            if ( ids.contains( peer.getId().getId() ) )
             {
                 log.error( "Peer replica ID '{}' has already been declared.", peer.getId() );
                 throw new ReplicationConfigurationException( "Peer replica ID '" + peer.getId()

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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -22,6 +22,8 @@
 
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.common.CSNVector;
+import org.apache.directory.mitosis.common.ReplicaId;
+import org.apache.directory.mitosis.common.UUID;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.store.ReplicationLogIterator;
 import org.apache.directory.mitosis.store.ReplicationStore;
@@ -33,7 +35,6 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
-import java.util.UUID;
 
 
 /**
@@ -58,13 +59,13 @@
         }
 
 
-        public String getReplicaId()
+        public ReplicaId getReplicaId()
         {
             return null;
         }
 
 
-        public Set<String> getKnownReplicaIds()
+        public Set<ReplicaId> getKnownReplicaIds()
         {
             return null;
         }
@@ -117,7 +118,7 @@
         }
 
 
-        public int getLogSize( String replicaId )
+        public int getLogSize( ReplicaId replicaId )
         {
             return 0;
         }

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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -23,6 +23,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.ReplicaId;
+import org.apache.directory.mitosis.common.UUIDFactory;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.CoreSession;
@@ -56,7 +58,6 @@
 import javax.naming.directory.SearchControls;
 
 import java.util.List;
-import java.util.UUID;
 
 
 /**
@@ -85,8 +86,9 @@
  */
 public class OperationFactory
 {
-    private final String replicaId;
+    private final ReplicaId replicaId;
     private final PartitionNexus nexus;
+    private final UUIDFactory uuidFactory;
     private final CSNFactory csnFactory;
     
     /** The attributeType registry */
@@ -103,6 +105,7 @@
     {
         replicaId = cfg.getReplicaId();
         nexus = directoryService.getPartitionNexus();
+        uuidFactory = cfg.getUuidFactory();
         csnFactory = cfg.getCsnFactory();
         registries = directoryService.getRegistries();
         attributeRegistry = registries.getAttributeTypeRegistry();
@@ -135,7 +138,7 @@
         ServerEntry cloneEntry = ( ServerEntry ) entry.clone();
         cloneEntry.removeAttributes( Constants.ENTRY_UUID );
         cloneEntry.removeAttributes( Constants.ENTRY_DELETED );
-        cloneEntry.put( Constants.ENTRY_UUID, UUID.randomUUID().toString() );
+        cloneEntry.put( Constants.ENTRY_UUID, uuidFactory.newInstance().toOctetString() );
         cloneEntry.put( Constants.ENTRY_DELETED, "FALSE" );
 
         // NOTE: We inlined addDefaultOperations() because ApacheDS currently

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/ClientConnectionManager.java Mon Aug 25 18:00:55 2008
@@ -29,6 +29,7 @@
 import java.util.concurrent.TimeUnit;
 
 import org.apache.directory.mitosis.common.Replica;
+import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.service.protocol.codec.ReplicationClientProtocolCodecFactory;
 import org.apache.directory.mitosis.service.protocol.handler.ReplicationClientContextHandler;
@@ -72,7 +73,7 @@
     private final ReplicationInterceptor interceptor;
     private final IoConnector connector = new SocketConnector();
     private final IoConnectorConfig connectorConfig = new SocketConnectorConfig();
-    private final Map<String,Connection> sessions = new HashMap<String,Connection>();
+    private final Map<ReplicaId,Connection> sessions = new HashMap<ReplicaId,Connection>();
     private ReplicationConfiguration configuration;
     private ConnectionMonitor monitor;
 
@@ -169,7 +170,6 @@
             for ( Replica replica : configuration.getPeerReplicas() )
             {
                 Connection con = sessions.get( replica.getId() );
-                
                 if ( con == null )
                 {
                     con = new Connection();
@@ -284,11 +284,10 @@
             LOG.info( "[Replica-{}] Closing all connections...", configuration.getReplicaId() );
             for ( ;; )
             {
-                Iterator<Connection> i = sessions.values().iterator();
-                
+                Iterator i = sessions.values().iterator();
                 while ( i.hasNext() )
                 {
-                    Connection con = i.next();
+                    Connection con = ( Connection ) i.next();
                     synchronized ( con )
                     {
                         if ( con.inProgress )
@@ -405,7 +404,7 @@
         private int delay = -1;
         private boolean inProgress;
         private Connector connector;
-        private String replicaId;
+        private ReplicaId replicaId;
 
 
         public Connection()

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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -23,6 +23,7 @@
 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.ReplicaId;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.Operation;
 import org.apache.directory.mitosis.operation.OperationFactory;
@@ -148,7 +149,7 @@
     private static final Logger LOG = LoggerFactory.getLogger( ReplicationInterceptor.class );
 
     /** The service name */
-    public static final String DEFAULT_SERVICE_NAME = "replicationService";
+    public static final String NAME = "replicationService";
 
 
     private static final String ENTRY_CSN_OID = "1.3.6.1.4.1.18060.0.4.1.2.30";
@@ -157,7 +158,7 @@
     /**
      * default name is the service name?
      */
-    private String name = DEFAULT_SERVICE_NAME;
+    private String name = NAME;
 
     private DirectoryService directoryService;
     private ReplicationConfiguration configuration;
@@ -169,31 +170,19 @@
     private Registries registries;
 
 
-    /**
-     * Creates a new instance of ReplicationInterceptor.
-     */
     public ReplicationInterceptor()
     {
     }
 
     /**
-     * This interceptor has configuration so it might be useful to allow several instances in a chain.
-     * 
+     * this interceptor has configuration so it might be useful to allow several instances in a chain.
      * @return configured name for this interceptor.
      */
-    public String getName() 
-    {
+    public String getName() {
         return name;
     }
 
-    
-    /**
-     * Set the name for this service instance
-     *
-     * @param name The new name
-     */
-    public void setName( String name ) 
-    {
+    public void setName(String name) {
         this.name = name;
     }
 
@@ -203,19 +192,11 @@
     }
 
 
-    public void setConfiguration(ReplicationConfiguration configuration) 
-    {
+    public void setConfiguration(ReplicationConfiguration configuration) {
         this.configuration = configuration;
     }
 
 
-    /**
-     * Initialize the Replication service. We have to check that the configuration
-     * is valid, initialize a store for pending operations, and start the communication
-     * with the other LDAP servers.
-     * 
-     * @param directoryService the DirectoryService instance 
-     */
     public void init( DirectoryService directoryService ) throws Exception
     {
         configuration.validate();
@@ -334,7 +315,7 @@
 
         CSN purgeCSN = new DefaultCSN( System.currentTimeMillis() - configuration.getLogMaxAge() * 1000L * 60L * 60L
             * 24L, // convert days to millis
-            "ZZZZZZZZZZZZZZZZ", Integer.MAX_VALUE );
+            new ReplicaId( "ZZZZZZZZZZZZZZZZ" ), Integer.MAX_VALUE );
         ExprNode filter;
 
         try

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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -25,6 +25,7 @@
 import java.nio.charset.CharsetDecoder;
 
 import org.apache.directory.mitosis.common.CSNVector;
+import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.common.DefaultCSN;
 import org.apache.directory.mitosis.service.protocol.Constants;
 import org.apache.directory.mitosis.service.protocol.message.BaseMessage;
@@ -74,11 +75,10 @@
 
         for ( ; nReplicas > 0; nReplicas-- )
         {
-            String replicaId;
-            
+            ReplicaId replicaId;
             try
             {
-                replicaId = in.getString( utf8decoder );
+                replicaId = new ReplicaId( in.getString( utf8decoder ) );
             }
             catch ( CharacterCodingException e )
             {

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageEncoder.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageEncoder.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesAckMessageEncoder.java Mon Aug 25 18:00:55 2008
@@ -24,11 +24,13 @@
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetEncoder;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.common.CSNVector;
+import org.apache.directory.mitosis.common.ReplicaId;
 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;
@@ -63,18 +65,18 @@
 
     private void writeCSNVector( ByteBuffer out, CSNVector csns )
     {
-        Set<String> replicaIds = csns.getReplicaIds();
+        Set replicaIds = csns.getReplicaIds();
 
         int nReplicas = replicaIds.size();
         out.putInt( nReplicas );
-        
-        for ( String replicaId:replicaIds )
+        Iterator it = replicaIds.iterator();
+        while ( it.hasNext() )
         {
+            ReplicaId replicaId = ( ReplicaId ) it.next();
             CSN csn = csns.getCSN( replicaId );
-            
             try
             {
-                out.putString( replicaId, utf8encoder );
+                out.putString( replicaId.getId(), utf8encoder );
                 out.put( ( byte ) 0x00 );
                 out.putLong( csn.getTimestamp() );
                 out.putInt( csn.getOperationSequence() );
@@ -87,9 +89,9 @@
     }
 
 
-    public Set<Class<?>> getMessageTypes()
+    public Set getMessageTypes()
     {
-        Set<Class<?>> set = new HashSet<Class<?>>();
+        Set<Class> set = new HashSet<Class>();
         set.add( BeginLogEntriesAckMessage.class );
         return set;
     }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesMessageEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesMessageEncoder.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesMessageEncoder.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/BeginLogEntriesMessageEncoder.java Mon Aug 25 18:00:55 2008
@@ -40,9 +40,9 @@
     }
 
 
-    public Set<Class<?>> getMessageTypes()
+    public Set getMessageTypes()
     {
-        Set<Class<?>> set = new HashSet<Class<?>>();
+        Set<Class> set = new HashSet<Class>();
         set.add( BeginLogEntriesMessage.class );
         return set;
     }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesAckMessageEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesAckMessageEncoder.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesAckMessageEncoder.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesAckMessageEncoder.java Mon Aug 25 18:00:55 2008
@@ -35,9 +35,9 @@
     }
 
 
-    public Set<Class<?>> getMessageTypes()
+    public Set getMessageTypes()
     {
-        Set<Class<?>> set = new HashSet<Class<?>>();
+        Set<Class> set = new HashSet<Class>();
         set.add( EndLogEntriesAckMessage.class );
         return set;
     }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesMessageEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesMessageEncoder.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesMessageEncoder.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/EndLogEntriesMessageEncoder.java Mon Aug 25 18:00:55 2008
@@ -40,9 +40,9 @@
     }
 
 
-    public Set<Class<?>> getMessageTypes()
+    public Set getMessageTypes()
     {
-        Set<Class<?>> set = new HashSet<Class<?>>();
+        Set<Class> set = new HashSet<Class>();
         set.add( EndLogEntriesMessage.class );
         return set;
     }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryAckMessageEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryAckMessageEncoder.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryAckMessageEncoder.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryAckMessageEncoder.java Mon Aug 25 18:00:55 2008
@@ -35,9 +35,9 @@
     }
 
 
-    public Set<Class<?>> getMessageTypes()
+    public Set getMessageTypes()
     {
-        Set<Class<?>> set = new HashSet<Class<?>>();
+        Set<Class> set = new HashSet<Class>();
         set.add( LogEntryAckMessage.class );
         return set;
     }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageEncoder.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageEncoder.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageEncoder.java Mon Aug 25 18:00:55 2008
@@ -46,9 +46,9 @@
     }
 
 
-    public Set<Class<?>> getMessageTypes()
+    public Set getMessageTypes()
     {
-        Set<Class<?>> set = new HashSet<Class<?>>();
+        Set<Class> set = new HashSet<Class>();
         set.add( LogEntryMessage.class );
         return set;
     }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageDecoder.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageDecoder.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageDecoder.java Mon Aug 25 18:00:55 2008
@@ -26,6 +26,7 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.apache.directory.mitosis.common.ReplicaId;
 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.LoginAckMessage;
@@ -44,7 +45,7 @@
 
     protected BaseMessage decodeBody( int sequence, int bodyLength, int responseCode, ByteBuffer in ) throws Exception
     {
-        return new LoginAckMessage( sequence, responseCode, in.getString( utf8decoder ) );
+        return new LoginAckMessage( sequence, responseCode, new ReplicaId( in.getString( utf8decoder ) ) );
     }
 
 

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageEncoder.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageEncoder.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageEncoder.java Mon Aug 25 18:00:55 2008
@@ -40,9 +40,9 @@
     }
 
 
-    public Set<Class<?>> getMessageTypes()
+    public Set getMessageTypes()
     {
-        Set<Class<?>> set = new HashSet<Class<?>>();
+        Set<Class> set = new HashSet<Class>();
         set.add( LoginAckMessage.class );
         return set;
     }
@@ -52,7 +52,7 @@
     {
         LoginAckMessage m = ( LoginAckMessage ) in;
         super.encodeBody( in, out );
-        out.putString( m.getReplicaId(), utf8encoder );
+        out.putString( m.getReplicaId().getId(), utf8encoder );
     }
 
 }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageDecoder.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageDecoder.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageDecoder.java Mon Aug 25 18:00:55 2008
@@ -26,6 +26,7 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.apache.directory.mitosis.common.ReplicaId;
 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.LoginMessage;
@@ -45,7 +46,7 @@
 
     protected BaseMessage decodeBody( int sequence, int bodyLength, ByteBuffer in ) throws Exception
     {
-        return new LoginMessage( sequence, in.getString( utf8decoder ) );
+        return new LoginMessage( sequence, new ReplicaId( in.getString( utf8decoder ) ) );
     }
 
 

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageEncoder.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageEncoder.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageEncoder.java Mon Aug 25 18:00:55 2008
@@ -48,7 +48,7 @@
 
         try
         {
-            out.putString( m.getReplicaId(), utf8encoder );
+            out.putString( m.getReplicaId().getId(), utf8encoder );
         }
         catch ( CharacterCodingException e )
         {
@@ -57,9 +57,9 @@
     }
 
 
-    public Set<Class<?>> getMessageTypes()
+    public Set getMessageTypes()
     {
-        Set<Class<?>> set = new HashSet<Class<?>>();
+        Set<Class> set = new HashSet<Class>();
         set.add( LoginMessage.class );
 
         return set;

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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -24,6 +24,7 @@
 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.common.ReplicaId;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.AddEntryOperation;
 import org.apache.directory.mitosis.operation.Operation;
@@ -265,8 +266,8 @@
             // Initiate replication process asking update vector.
             if ( SessionLog.isDebugEnabled( ctx.getSession() ) )
             {
-                SessionLog.debug( ctx.getSession(), "(" + ctx.getConfiguration().getReplicaId() + "->"
-                    + ( ctx.getPeer() != null ? ctx.getPeer().getId() : "null" ) + ") Beginning replication. " );
+                SessionLog.debug( ctx.getSession(), "(" + ctx.getConfiguration().getReplicaId().getId() + "->"
+                    + ( ctx.getPeer() != null ? ctx.getPeer().getId().getId() : "null" ) + ") Beginning replication. " );
             }
             ctx.getSession().write( new BeginLogEntriesMessage( ctx.getNextSequence() ) );
             return true;
@@ -275,8 +276,8 @@
         {
             if ( SessionLog.isDebugEnabled( ctx.getSession() ) )
             {
-                SessionLog.debug( ctx.getSession(), "(" + ctx.getConfiguration().getReplicaId() + "->"
-                    + ( ctx.getPeer() != null ? ctx.getPeer().getId() : "null" )
+                SessionLog.debug( ctx.getSession(), "(" + ctx.getConfiguration().getReplicaId().getId() + "->"
+                    + ( ctx.getPeer() != null ? ctx.getPeer().getId().getId() : "null" )
                     + ") Couldn't begin replication.  State:" + ctx.getState() + ", scheduledExpirations:"
                     + ctx.getScheduledExpirations() + ", scheduledWriteRequests:"
                     + ctx.getSession().getScheduledWriteRequests() );
@@ -449,11 +450,10 @@
     @SuppressWarnings("unchecked")
     private void sendReplicationLogs( ReplicationContext ctx, CSNVector myPV, CSNVector yourUV )
     {
-        for ( String replicaId : myPV.getReplicaIds() )
+        for ( ReplicaId replicaId : myPV.getReplicaIds() )
         {
             CSN myCSN = myPV.getCSN( replicaId );
             CSN yourCSN = yourUV.getCSN( replicaId );
-            
             if ( yourCSN != null && ( myCSN == null || yourCSN.compareTo( myCSN ) < 0 ) )
             {
                 SessionLog.warn( ctx.getSession(), "Remote update vector (" + yourUV

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/message/LoginAckMessage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/message/LoginAckMessage.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/message/LoginAckMessage.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/message/LoginAckMessage.java Mon Aug 25 18:00:55 2008
@@ -22,15 +22,16 @@
 
 import org.apache.directory.shared.ldap.util.EqualsBuilder;
 import org.apache.directory.shared.ldap.util.HashCodeBuilder;
+import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.service.protocol.Constants;
 
 
 public class LoginAckMessage extends ResponseMessage
 {
-    private String replicaId;
+    private ReplicaId replicaId;
 
 
-    public LoginAckMessage( int sequence, int responseCode, String replicaId )
+    public LoginAckMessage( int sequence, int responseCode, ReplicaId replicaId )
     {
         super( sequence, responseCode );
         this.replicaId = replicaId;
@@ -43,7 +44,7 @@
     }
 
 
-    public String getReplicaId()
+    public ReplicaId getReplicaId()
     {
         return replicaId;
     }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/message/LoginMessage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/message/LoginMessage.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/message/LoginMessage.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/message/LoginMessage.java Mon Aug 25 18:00:55 2008
@@ -22,15 +22,16 @@
 
 import org.apache.directory.shared.ldap.util.EqualsBuilder;
 import org.apache.directory.shared.ldap.util.HashCodeBuilder;
+import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.service.protocol.Constants;
 
 
 public class LoginMessage extends BaseMessage
 {
-    private final String replicaId;
+    private final ReplicaId replicaId;
 
 
-    public LoginMessage( int sequence, String replicaId )
+    public LoginMessage( int sequence, ReplicaId replicaId )
     {
         super( sequence );
 
@@ -44,7 +45,7 @@
     }
 
 
-    public String getReplicaId()
+    public ReplicaId getReplicaId()
     {
         return replicaId;
     }

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/ReplicationStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/ReplicationStore.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/ReplicationStore.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/store/ReplicationStore.java Mon Aug 25 18:00:55 2008
@@ -22,6 +22,8 @@
 
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.common.CSNVector;
+import org.apache.directory.mitosis.common.ReplicaId;
+import org.apache.directory.mitosis.common.UUID;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.Operation;
 import org.apache.directory.server.core.DirectoryService;
@@ -29,7 +31,6 @@
 
 import javax.naming.Name;
 import java.util.Set;
-import java.util.UUID;
 
 /**
  * Provides an abstract storage that stores data required to perform
@@ -46,27 +47,24 @@
      * Opens this storage.
      */
     void open( DirectoryService directoryService, ReplicationConfiguration cfg );
-    
 
     /**
      * Closes this storage and releases the resources allocated when it's
      * opened.
      */
     void close();
-    
 
     /**
-     * Returns the ReplicaId of the ReplicaId that this storage
+     * Returns the {@link ReplicaId} of the {@link ReplicaId} that this storage
      * is associated with.
      */
-    String getReplicaId();
-    
+    ReplicaId getReplicaId();
 
     /**
-     * Returns the set of ReplicaIds of the ReplicaIds that
+     * Returns the set of {@link ReplicaId}s of the {@link ReplicaId}s that
      * belongs to the same cluster.
      */
-    Set<String> getKnownReplicaIds();
+    Set<ReplicaId> getKnownReplicaIds();
 
 
     // UUID to DN table operations
@@ -75,14 +73,12 @@
      * Finds the {@link Name} of an entry with the specified {@link UUID}.
      */
     Name getDN( UUID uuid );
-    
 
     /**
      * Associates the specified name and UUID so a user can
      * find an entry's name from a UUID.
      */
     boolean putUUID( UUID uuid, Name dn );
-    
 
     /**
      * Removed the specified UUID mapping from this storage.
@@ -97,7 +93,6 @@
      * Puts the specified operation into this storage.
      */
     void putLog( Operation operation );
-    
 
     /**
      * Queries all operations that is greater than the specified {@link CSN}.
@@ -106,7 +101,6 @@
      *                  itself in the result set.
      */
     ReplicationLogIterator getLogs( CSN fromCSN, boolean inclusive );
-    
 
     /**
      * Queries all operations that is greater than the specified
@@ -116,7 +110,6 @@
      *                  <tt>updateVector</tt> itself in the result set.
      */
     ReplicationLogIterator getLogs( CSNVector updateVector, boolean inclusive );
-    
 
     /**
      * Removes all operations that is less than the specified {@link CSN}.
@@ -126,27 +119,23 @@
      * @return the number of deleted {@link Operation}s
      */
     int removeLogs( CSN toCSN, boolean inclusive );
-    
 
     /**
      * Returns the number of {@link Operation}s logged in this storage.
      */
     int getLogSize();
-    
 
     /**
      * Returns the number of {@link Operation}s logged by
-     * the ReplicaId with the specified ReplicaId
+     * the {@link ReplicaId} with the specified {@link ReplicaId}
      * in this storage .
      */
-    int getLogSize( String replicaId );
-    
+    int getLogSize( ReplicaId replicaId );
 
     /**
      * Calculates the Update Vector (UV) from this storage. 
      */
     CSNVector getUpdateVector();
-    
 
     /**
      * Calculates the Purge Vector (PV) from this storage. 

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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -26,6 +26,7 @@
 import java.sql.Statement;
 
 import org.apache.directory.mitosis.common.CSN;
+import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.common.DefaultCSN;
 import org.apache.directory.mitosis.operation.Operation;
 import org.apache.directory.mitosis.operation.OperationCodec;
@@ -73,7 +74,7 @@
     {
         try
         {
-            String replicaId = rs.getString( 1 );
+            ReplicaId replicaId = new ReplicaId( rs.getString( 1 ) );
             long timestamp = rs.getLong( 2 );
             int operationSequence = rs.getInt( 3 );
             return new DefaultCSN( timestamp, replicaId, operationSequence );

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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -24,6 +24,8 @@
 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.ReplicaId;
+import org.apache.directory.mitosis.common.UUID;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.Operation;
 import org.apache.directory.mitosis.operation.OperationCodec;
@@ -44,8 +46,8 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
-import java.util.UUID;
 
 
 public class DerbyReplicationStore implements ReplicationStore
@@ -60,12 +62,12 @@
 
     private String dbURI;
     private BasicDataSource dataSource;
-    private String replicaId;
+    private ReplicaId replicaId;
     private String tablePrefix = DEFAULT_TABLE_PREFIX;
     private String metadataTableName;
     private String uuidTableName;
     private String logTableName;
-    private Set<String> knownReplicaIds;
+    private Set<ReplicaId> knownReplicaIds;
     private final Object knownReplicaIdsLock = new Object();
     private final OperationCodec operationCodec = new OperationCodec();
 
@@ -214,7 +216,7 @@
             {
                 // If already registered, match it with what user specified.
                 String actualReplicaId = rs.getString( 1 );
-                if ( !replicaId.equalsIgnoreCase( actualReplicaId ) )
+                if ( !replicaId.getId().equalsIgnoreCase( actualReplicaId ) )
                 {
                     throw new ReplicationStoreException( "Replica ID mismatches: " + actualReplicaId + " (expected: "
                         + replicaId + ")" );
@@ -231,7 +233,7 @@
                 // If not registered yet, register with what user specified.
                 ps = con.prepareStatement( "INSERT INTO " + metadataTableName + " (M_KEY, M_VALUE) VALUES (?,?)" );
                 ps.setString( 1, KEY_REPLICA_ID );
-                ps.setString( 2, replicaId );
+                ps.setString( 2, replicaId.getId() );
                 ps.executeUpdate();
             }
 
@@ -246,11 +248,10 @@
             // Get known replica IDs.
             ps = con.prepareStatement( "SELECT DISTINCT CSN_REPLICA_ID FROM " + logTableName );
             rs = ps.executeQuery();
-            knownReplicaIds = new HashSet<String>();
-            
+            knownReplicaIds = new HashSet<ReplicaId>();
             while ( rs.next() )
             {
-                knownReplicaIds.add( rs.getString( 1 ) );
+                knownReplicaIds.add( new ReplicaId( rs.getString( 1 ) ) );
             }
         }
         catch ( Exception e )
@@ -292,15 +293,15 @@
     }
 
 
-    public String getReplicaId()
+    public ReplicaId getReplicaId()
     {
         return replicaId;
     }
 
 
-    public Set<String> getKnownReplicaIds()
+    public Set<ReplicaId> getKnownReplicaIds()
     {
-        return new HashSet<String>( knownReplicaIds );
+        return new HashSet<ReplicaId>( knownReplicaIds );
     }
 
 
@@ -316,7 +317,7 @@
             con.setTransactionIsolation( Connection.TRANSACTION_READ_COMMITTED );
             con.setReadOnly( true );
             ps = con.prepareStatement( "SELECT DN FROM " + uuidTableName + " WHERE UUID=?" );
-            ps.setString( 1, uuid.toString() );
+            ps.setString( 1, uuid.toOctetString() );
             rs = ps.executeQuery();
             if ( rs.next() )
             {
@@ -340,7 +341,7 @@
 
     public boolean putUUID( UUID uuid, Name dn )
     {
-        String uuidString = uuid.toString();
+        String uuidString = uuid.toOctetString();
         Connection con = null;
         PreparedStatement ps = null;
         ResultSet rs = null;
@@ -396,7 +397,7 @@
 
     public boolean removeUUID( UUID uuid )
     {
-        String uuidString = uuid.toString();
+        String uuidString = uuid.toOctetString();
         Connection con = null;
         PreparedStatement ps = null;
 
@@ -440,7 +441,7 @@
             // Check if the specified uuid already exists
             ps = con.prepareStatement( "INSERT INTO " + logTableName
                 + " (CSN_REPLICA_ID, CSN_TIMESTAMP, CSN_OP_SEQ, OPERATION) VALUES(?,?,?,?)" );
-            ps.setString( 1, csn.getReplicaId() );
+            ps.setString( 1, csn.getReplicaId().getId() );
             ps.setLong( 2, csn.getTimestamp() );
             ps.setInt( 3, csn.getOperationSequence() );
             ps.setBytes( 4, encodedOp );
@@ -467,7 +468,7 @@
         {
             synchronized ( knownReplicaIdsLock )
             {
-                Set<String> newKnownReplicaIds = new HashSet<String>( knownReplicaIds );
+                Set<ReplicaId> newKnownReplicaIds = new HashSet<ReplicaId>( knownReplicaIds );
                 newKnownReplicaIds.add( csn.getReplicaId() );
                 knownReplicaIds = newKnownReplicaIds;
             }
@@ -519,17 +520,18 @@
             // Check if the specified uuid already exists
             ps = con.prepareStatement( query );
 
+            Iterator<ReplicaId> i = updateVector.getReplicaIds().iterator();
             int paramIdx = 1;
             
-            for ( String replicaId:updateVector.getReplicaIds() )
+            while ( i.hasNext() )
             {
+                ReplicaId replicaId = i.next();
                 CSN csn = updateVector.getCSN( replicaId );
-                ps.setString( paramIdx++, replicaId );
+                ps.setString( paramIdx++, replicaId.getId() );
                 ps.setLong( paramIdx++, csn.getTimestamp() );
                 ps.setInt( paramIdx++, csn.getOperationSequence() );
                 ps.setLong( paramIdx++, csn.getTimestamp() );
             }
-            
             rs = ps.executeQuery();
 
             return new DerbyReplicationLogIterator( operationCodec, con, ps, rs );
@@ -546,7 +548,7 @@
         CSNVector newUV = new CSNVector();
         synchronized ( knownReplicaIds )
         {
-            for ( String knownReplicaId : knownReplicaIds )
+            for ( ReplicaId knownReplicaId : knownReplicaIds )
             {
                 newUV.setCSN( new DefaultCSN( 0, knownReplicaId, 0 ) );
             }
@@ -576,7 +578,7 @@
                     + " " + "WHERE CSN_REPLICA_ID = ? AND (CSN_TIMESTAMP = ? AND CSN_OP_SEQ >"
                     + ( inclusive ? "=" : "" ) + " ? OR CSN_TIMESTAMP > ?) "
                     + "ORDER BY CSN_TIMESTAMP ASC, CSN_OP_SEQ ASC" );
-            ps.setString( 1, fromCSN.getReplicaId() );
+            ps.setString( 1, fromCSN.getReplicaId().getId() );
             ps.setLong( 2, fromCSN.getTimestamp() );
             ps.setInt( 3, fromCSN.getOperationSequence() );
             ps.setLong( 4, fromCSN.getTimestamp() );
@@ -607,7 +609,7 @@
             ps = con.prepareStatement( "DELETE FROM " + logTableName + " WHERE "
                 + "CSN_REPLICA_ID = ? AND (CSN_TIMESTAMP = ? AND CSN_OP_SEQ <" + ( inclusive ? "=" : "" )
                 + " ? OR CSN_TIMESTAMP < ?)" );
-            ps.setString( 1, toCSN.getReplicaId() );
+            ps.setString( 1, toCSN.getReplicaId().getId() );
             ps.setLong( 2, toCSN.getTimestamp() );
             ps.setInt( 3, toCSN.getOperationSequence() );
             ps.setLong( 4, toCSN.getTimestamp() );
@@ -651,7 +653,7 @@
     }
 
 
-    public int getLogSize( String replicaId )
+    public int getLogSize( ReplicaId replicaId )
     {
         Connection con = null;
         PreparedStatement ps = null;
@@ -663,7 +665,7 @@
             con.setTransactionIsolation( Connection.TRANSACTION_READ_COMMITTED );
             con.setReadOnly( true );
             ps = con.prepareStatement( "SELECT COUNT(*) FROM " + logTableName + " WHERE CSN_REPLICA_ID=?" );
-            ps.setString( 1, replicaId );
+            ps.setString( 1, replicaId.getId() );
             rs = ps.executeQuery();
             rs.next();
             return rs.getInt( 1 );
@@ -708,16 +710,16 @@
             ps = con.prepareStatement( "SELECT CSN_TIMESTAMP, CSN_OP_SEQ FROM " + logTableName
                 + " WHERE CSN_REPLICA_ID=? ORDER BY CSN_TIMESTAMP " + ORDER + ", CSN_OP_SEQ " + ORDER );
 
-            for ( String replicaId:knownReplicaIds )
+            Iterator<ReplicaId> it = knownReplicaIds.iterator();
+            while ( it.hasNext() )
             {
-                ps.setString( 1, replicaId );
+                ReplicaId replicaId = it.next();
+                ps.setString( 1, replicaId.getId() );
                 rs = ps.executeQuery();
-                
                 if ( rs.next() )
                 {
                     result.setCSN( new DefaultCSN( rs.getLong( 1 ), replicaId, rs.getInt( 2 ) ) );
                 }
-                
                 rs.close();
                 rs = null;
                 ps.clearParameters();

Modified: directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/util/OctetString.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/util/OctetString.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/util/OctetString.java (original)
+++ directory/apacheds/trunk/mitosis/src/main/java/org/apache/directory/mitosis/util/OctetString.java Mon Aug 25 18:00:55 2008
@@ -116,6 +116,62 @@
         destination.append( highDigits[v] );
         destination.append( lowDigits[v] );
     }
+
+    /**
+     * Converts the specified binary data into an octet string and returns it.
+     */
+    public static String toString( byte[] src )
+    {
+        final int end = src.length;
+        StringBuffer dst = new StringBuffer( src.length << 1 );
+        for ( int i = 0; i < end; i++ )
+        {
+            dst.append( highDigits[src[i] & 0xff] );
+            dst.append( lowDigits[src[i] & 0xff] );
+        }
+
+        return dst.toString();
+    }
+
+    /**
+     * Converts the specified value into an octet string and returns it.
+     */
+    public static String toString( long value )
+    {
+        StringBuffer dst = new StringBuffer( 16 );
+        append( dst, value );
+        return dst.toString();
+    }
+
+    /**
+     * Converts the specified value into an octet string and returns it.
+     */
+    public static String toString( int value )
+    {
+        StringBuffer dst = new StringBuffer( 8 );
+        append( dst, value );
+        return dst.toString();
+    }
+
+    /**
+     * Converts the specified octet string value into an integer and returns
+     * it.
+     */
+    public static int parseInt( String value )
+    {
+        return Integer.parseInt( value, 16 );
+    }
+
+    /**
+     * Converts the specified octet string value into a long integer and
+     * returns it.
+     */
+    public static long parseLong( String value )
+    {
+        return Long.parseLong( value, 16 );
+    }
+
+
     private OctetString()
     {
     }

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java Mon Aug 25 18:00:55 2008
@@ -22,6 +22,7 @@
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.mitosis.common.Replica;
+import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.DefaultDirectoryService;
@@ -85,7 +86,7 @@
             int replicationPort = AvailablePortFinder.getNextAvailable( lastAvailablePort );
             lastAvailablePort = replicationPort + 1;
 
-            replicas[ i ] = new Replica( names[ i ],
+            replicas[ i ] = new Replica( new ReplicaId( names[ i ] ),
                     new InetSocketAddress( "127.0.0.1", replicationPort ) );
         }
 
@@ -96,7 +97,7 @@
 
         for ( Replica replica : replicas )
         {
-            String replicaId = replica.getId();
+            String replicaId = replica.getId().getId();
             DirectoryService service = new DefaultDirectoryService();
             service.setInstanceId( replicaId );
             File workDir = new File( homeDirectory + File.separator + service.getInstanceId() );

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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -21,6 +21,7 @@
 
 
 import org.apache.directory.mitosis.common.CSNVector;
+import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.common.DefaultCSN;
 import org.apache.directory.mitosis.service.protocol.Constants;
 import org.apache.directory.mitosis.service.protocol.codec.BeginLogEntriesAckMessageDecoder;
@@ -36,15 +37,15 @@
 
     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( new DefaultCSN( System.currentTimeMillis() - 400, new ReplicaId( "replica0" ), 3456 ) );
+        PURGE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() - 300, new ReplicaId( "replica1" ), 9012 ) );
+        PURGE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() - 200, new ReplicaId( "replica2" ), 5678 ) );
+        PURGE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() - 100, new ReplicaId( "replica3" ), 1234 ) );
+
+        UPDATE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() + 000, new ReplicaId( "replica0" ), 1234 ) );
+        UPDATE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() + 100, new ReplicaId( "replica1" ), 5678 ) );
+        UPDATE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() + 200, new ReplicaId( "replica2" ), 9012 ) );
+        UPDATE_VECTOR.setCSN( new DefaultCSN( System.currentTimeMillis() + 300, new ReplicaId( "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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -26,6 +26,7 @@
 import javax.naming.InvalidNameException;
 import javax.naming.NamingException;
 
+import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.common.DefaultCSN;
 import org.apache.directory.mitosis.operation.AddAttributeOperation;
 import org.apache.directory.mitosis.service.protocol.codec.LogEntryMessageDecoder;
@@ -69,7 +70,7 @@
                 1234, 
                 new AddAttributeOperation( 
                     new DefaultCSN( System.currentTimeMillis(),
-                        "testReplica0", 1234 ), 
+                        new ReplicaId( "testReplica0" ), 1234 ), 
                     new LdapDN( "ou=system" ).normalize( oids ),
                     new DefaultServerAttribute( "ou", 
                         service.getRegistries().getAttributeTypeRegistry().lookup( "ou" ), "Test" ) ) ), 

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageCodecTest.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageCodecTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginAckMessageCodecTest.java Mon Aug 25 18:00:55 2008
@@ -20,6 +20,7 @@
 package org.apache.directory.mitosis.service.protocol.codec;
 
 
+import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.service.protocol.codec.LoginAckMessageDecoder;
 import org.apache.directory.mitosis.service.protocol.codec.LoginAckMessageEncoder;
 import org.apache.directory.mitosis.service.protocol.message.LoginAckMessage;
@@ -30,7 +31,7 @@
 
     public LoginAckMessageCodecTest()
     {
-        super( new LoginAckMessage( 1234, 5678, "ReplicaABCD" ), new LoginAckMessageEncoder(),
+        super( new LoginAckMessage( 1234, 5678, new ReplicaId( "ReplicaABCD" ) ), new LoginAckMessageEncoder(),
             new LoginAckMessageDecoder() );
     }
 }

Modified: directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageCodecTest.java?rev=688929&r1=688928&r2=688929&view=diff
==============================================================================
--- directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageCodecTest.java (original)
+++ directory/apacheds/trunk/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LoginMessageCodecTest.java Mon Aug 25 18:00:55 2008
@@ -20,6 +20,7 @@
 package org.apache.directory.mitosis.service.protocol.codec;
 
 
+import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.service.protocol.codec.LoginMessageDecoder;
 import org.apache.directory.mitosis.service.protocol.codec.LoginMessageEncoder;
 import org.apache.directory.mitosis.service.protocol.message.LoginMessage;
@@ -30,7 +31,7 @@
 
     public LoginMessageCodecTest()
     {
-        super( new LoginMessage( 1234, "myReplica0" ), new LoginMessageEncoder(),
+        super( new LoginMessage( 1234, new ReplicaId( "myReplica0" ) ), new LoginMessageEncoder(),
             new LoginMessageDecoder() );
     }
 }

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=688929&r1=688928&r2=688929&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 Mon Aug 25 18:00:55 2008
@@ -29,7 +29,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.UUID;
 
 import javax.naming.Name;
 import javax.naming.ldap.LdapName;
@@ -48,8 +47,12 @@
 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.ReplicaId;
 import org.apache.directory.mitosis.common.DefaultCSN;
 import org.apache.directory.mitosis.common.DefaultCSNFactory;
+import org.apache.directory.mitosis.common.DefaultUUIDFactory;
+import org.apache.directory.mitosis.common.UUID;
+import org.apache.directory.mitosis.common.UUIDFactory;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.AddAttributeOperation;
 import org.apache.directory.mitosis.operation.AddEntryOperation;
@@ -63,11 +66,12 @@
 
 public class DerbyReplicationStoreTest extends TestCase
 {
-    private static final String REPLICA_ID = "TEST_REPLICA";
-    private static final String OTHER_REPLICA_ID = "OTHER_REPLICA";
-    private static final String OTHER_REPLICA_ID_2 = "OTHER_REPLICA_2";
+    private static final ReplicaId REPLICA_ID = new ReplicaId( "TEST_REPLICA" );
+    private static final ReplicaId OTHER_REPLICA_ID = new ReplicaId( "OTHER_REPLICA" );
+    private static final ReplicaId OTHER_REPLICA_ID_2 = new ReplicaId( "OTHER_REPLICA_2" );
     private static final File DB_PATH = new File( "target/testDB" );
 
+    private final UUIDFactory uuidFactory = new DefaultUUIDFactory();
     private final CSNFactory csnFactory = new DefaultCSNFactory();
     private DerbyReplicationStore store;
     private int testCount;
@@ -83,7 +87,7 @@
     }
 
 
-    private void startupDatabase( String replicaId ) throws Exception
+    private void startupDatabase( ReplicaId replicaId ) throws Exception
     {
         // Prepare configuration
         ReplicationConfiguration cfg = new ReplicationConfiguration();
@@ -150,7 +154,7 @@
 
     private void subTestUUID() throws Exception
     {
-        UUID uuid = UUID.randomUUID();
+        UUID uuid = uuidFactory.newInstance();
         Name name = new LdapName( "ou=a, ou=b" );
         Assert.assertTrue( store.putUUID( uuid, name ) );
         Assert.assertEquals( name, store.getDN( uuid ) );
@@ -312,7 +316,7 @@
         store.putLog( new Operation( csnC ) );
         store.putLog( new Operation( csnD ) );
 
-        Set<String> expectedKnownReplicaIds = new HashSet<String>();
+        Set<ReplicaId> expectedKnownReplicaIds = new HashSet<ReplicaId>();
         expectedKnownReplicaIds.add( REPLICA_ID );
         expectedKnownReplicaIds.add( OTHER_REPLICA_ID );
         expectedKnownReplicaIds.add( OTHER_REPLICA_ID_2 );



Mime
View raw message