directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1157413 - in /directory/apacheds/trunk: protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ server-integ/src/test/java/org/apache/directory/server/replication/
Date Sat, 13 Aug 2011 19:40:53 GMT
Author: kayyagari
Date: Sat Aug 13 19:40:53 2011
New Revision: 1157413

URL: http://svn.apache.org/viewvc?rev=1157413&view=rev
Log:
o fixed the event message serialization (this was causing the rebbot test failure)
o changed the order of event message content serialization to avoid if-else block during deserialization
o use replica journal log cursor instead of the tuple cursor

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventLog.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventMessageSerializer.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplRequestHandler.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventLog.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventLog.java?rev=1157413&r1=1157412&r2=1157413&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventLog.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventLog.java
Sat Aug 13 19:40:53 2011
@@ -403,11 +403,9 @@ public class ReplicaEventLog implements 
      * @return A cursor on top of the queue
      * @throws Exception If the cursor can't be created
      */
-    public Cursor<Tuple<String, ReplicaEventMessage>> getCursor( String consumerCsn
) throws Exception
+    public ReplicaJournalCursor getCursor( String consumerCsn ) throws Exception
     {
-        Cursor<Tuple<String, ReplicaEventMessage>> cursor = journal.cursor( consumerCsn
);
-        
-        return cursor;
+        return new ReplicaJournalCursor( journal, consumerCsn );
     }
 
 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventMessageSerializer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventMessageSerializer.java?rev=1157413&r1=1157412&r2=1157413&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventMessageSerializer.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventMessageSerializer.java
Sat Aug 13 19:40:53 2011
@@ -61,6 +61,8 @@ public class ReplicaEventMessageSerializ
     /** The LDAP codec used to serialize the entries */
     private transient LdapApiService codec = LdapApiServiceFactory.getSingleton();
 
+    private transient SchemaManager schemaManager;
+    
     /**
      * Creates a new instance of ReplicaEventMessageSerializer.
      *
@@ -68,6 +70,7 @@ public class ReplicaEventMessageSerializ
      */
     public ReplicaEventMessageSerializer( SchemaManager schemaManager )
     {
+        this.schemaManager = schemaManager;
         entrySerializer = new EntrySerializer( schemaManager );
     }
 
@@ -86,14 +89,20 @@ public class ReplicaEventMessageSerializ
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        // The change type
-        out.writeByte( changeType.getValue() );
-        
         // The entry DN
         entry.getDn().writeExternal( out );
         
         // The entry
-        entry.writeExternal( out );
+        byte[] data = entrySerializer.serialize( entry );
+
+        // Entry's length
+        out.writeInt( data.length );
+        
+        // Entry's data
+        out.write( data );
+
+        // The change type
+        out.writeByte( changeType.getValue() );
         
         // The moddn control if any (only if it's a MODDN operation)
         if ( changeType == ChangeType.MODDN )
@@ -117,7 +126,7 @@ public class ReplicaEventMessageSerializ
                     break;
             }
         }
-        
+
         out.flush();
 
         return baos.toByteArray();
@@ -135,22 +144,27 @@ public class ReplicaEventMessageSerializ
     {
         ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( bytes ) );
 
-        // Read the changeType
-        byte type = in.readByte();
-        ChangeType changeType = ChangeType.getChangeType( type );
         ReplicaEventMessage replicaEventMessage = null;
 
         try
         {
             // The Entry's DN
-            Dn entryDn = new Dn();
+            Dn entryDn = new Dn( schemaManager );
             entryDn.readExternal( in );
 
-            // Read the Entry
-            Entry entry = new DefaultEntry();
-            entry.readExternal( in );
-            entry.setDn( entryDn );
+            // The Entry's length
+            int length = in.readInt();
+            byte[] data = new byte[length];
             
+            // The entry itself
+            in.read( data );
+            Entry entry = ( Entry ) entrySerializer.deserialize( data );
+            entry.setDn( entryDn );
+
+            // Read the changeType
+            byte type = in.readByte();
+            ChangeType changeType = ChangeType.getChangeType( type );
+
             if ( changeType == ChangeType.MODDN )
             {
                 type = in.readByte();

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplRequestHandler.java?rev=1157413&r1=1157412&r2=1157413&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplRequestHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplRequestHandler.java
Sat Aug 13 19:40:53 2011
@@ -273,13 +273,12 @@ public class SyncReplRequestHandler impl
         // do the search from the log
         String lastSentCsn = clientMsgLog.getLastSentCsn();
 
-        Cursor<Tuple<String, ReplicaEventMessage>> cursor = clientMsgLog.getCursor(
consumerCsn );
+        ReplicaJournalCursor cursor = clientMsgLog.getCursor( consumerCsn );
         //int i = 0;
         
         while ( cursor.next() )
         {
-            Tuple<String, ReplicaEventMessage> tuple = cursor.get();
-            ReplicaEventMessage replicaEventMessage = tuple.getValue();
+            ReplicaEventMessage replicaEventMessage = cursor.get();
             Entry entry = replicaEventMessage.getEntry();
             LOG.debug( "received message from the queue {}", entry );
             //i++;

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java?rev=1157413&r1=1157412&r2=1157413&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
Sat Aug 13 19:40:53 2011
@@ -386,7 +386,6 @@ public class ClientServerReplicationIT
     
     
     @Test
-    @Ignore
     public void testRebootConsumer() throws Exception
     {
         System.out.println( "----> 1 testRebootConsumer started --------------------------------"
);



Mime
View raw message