Le 11/27/12 10:18 AM, Kiran Ayyagari a écrit : > On Tue, Nov 27, 2012 at 1:58 PM, Emmanuel Lécharny <[email protected]>wrote: > >> Le 11/27/12 8:16 AM, Kiran Ayyagari a écrit : >>> On Mon, Nov 26, 2012 at 11:58 PM, <[email protected]> wrote: >>> >>>> Author: elecharny >>>> Date: Mon Nov 26 18:28:34 2012 >>>> New Revision: 1413771 >>>> >>>> URL: http://svn.apache.org/viewvc?rev=1413771&view=rev >>>> Log: >>>> Improved the serialization >>>> >>>> Modified: >>>> >>>> >> directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventMessage.java >>>> >> directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventMessageSerializer.java >>>> Modified: >>>> >> directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventMessage.java >>>> URL: >>>> >> http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventMessage.java?rev=1413771&r1=1413770&r2=1413771&view=diff >>>> >> ============================================================================== >>>> --- >>>> >> directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventMessage.java >>>> (original) >>>> +++ >>>> >> directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaEventMessage.java >>>> Mon Nov 26 18:28:34 2012 >>>> @@ -78,11 +78,11 @@ public class ReplicaEventMessage >>>> */ >>>> public boolean isEventOlderThan( String csn ) throws Exception >>>> { >>>> - if( csn == null ) >>>> - { >>>> - return false; >>>> - } >>>> - >>>> + if ( csn == null ) >>>> + { >>>> + return false; >>>> + } >>>> + >>>> String entryCsn = entry.get( SchemaConstants.ENTRY_CSN_AT >>>> ).getString(); >>>> >>>> int i = entryCsn.compareTo( csn ); >>>> >>>> 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=1413771&r1=1413770&r2=1413771&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 >>>> Mon Nov 26 18:28:34 2012 >>>> @@ -29,9 +29,7 @@ import java.io.ObjectOutputStream; >>>> >>>> import jdbm.helper.Serializer; >>>> >>>> -import >>>> >> org.apache.directory.server.core.partition.impl.btree.jdbm.EntrySerializer; >>>> -import org.apache.directory.shared.ldap.codec.api.LdapApiService; >>>> -import >> org.apache.directory.shared.ldap.codec.api.LdapApiServiceFactory; >>>> +import org.apache.directory.shared.ldap.model.entry.DefaultEntry; >>>> import org.apache.directory.shared.ldap.model.entry.Entry; >>>> import >> org.apache.directory.shared.ldap.model.message.controls.ChangeType; >>>> import org.apache.directory.shared.ldap.model.name.Dn; >>>> @@ -39,11 +37,12 @@ import org.apache.directory.shared.ldap. >>>> >>>> >>>> /** >>>> - * A Modification serializer/deserializer. >>>> + * A ReplicaEventMessage serializer/deserializer. >>>> + * >>>> * A modification is serialized following this format : <br/> >>>> * <ul> >>>> * <li>byte : EventType</li> >>>> - * <li>int : entry's length in bytes</li> >>>> + * <li>byte[] : the serialized DN</li> >>>> * <li>byte[] : the serialized entry</li> >>>> * </ul> >>>> * >>>> @@ -54,12 +53,7 @@ public class ReplicaEventMessageSerializ >>>> /** The serialVersionUID */ >>>> private static final long serialVersionUID = 1L; >>>> >>>> - /** The internal entry serializer */ >>>> - private transient EntrySerializer entrySerializer; >>>> - >>>> - /** The LDAP codec used to serialize the entries */ >>>> - private transient LdapApiService codec = >>>> LdapApiServiceFactory.getSingleton(); >>>> - >>>> + /** The schemaManager */ >>>> private transient SchemaManager schemaManager; >>>> >>>> >>>> @@ -71,7 +65,6 @@ public class ReplicaEventMessageSerializ >>>> public ReplicaEventMessageSerializer( SchemaManager schemaManager ) >>>> { >>>> this.schemaManager = schemaManager; >>>> - entrySerializer = new EntrySerializer( schemaManager ); >>>> } >>>> >>>> >>>> @@ -88,20 +81,14 @@ public class ReplicaEventMessageSerializ >>>> ByteArrayOutputStream baos = new ByteArrayOutputStream(); >>>> ObjectOutput out = new ObjectOutputStream( baos ); >>>> >>>> + // The change type first >>>> + out.writeByte( changeType.getValue() ); >>>> + >>>> // The entry DN >>>> entry.getDn().writeExternal( out ); >>>> >>>> // The entry >>>> - byte[] data = entrySerializer.serialize( entry ); >>>> - >>>> >>> the reason we have the above code is that we store ClonedServerEntry >>> instances [1] into the replica log >>> instead of DefaultEntry objects, so we need to use the EntrySerializer. >> You can still use the entry.writeExternal() method. A ClonedServerEntry >> is just a plain Entry. >> >> the problem is ClonedServerEntry's write/readExternal() methods throw > IllegalStateException
Yes, it was a mistake I made. The ReplicaEventMessage was receiving a ClonedServerEntry, and not the modified entry for the Add operation. I fixed it but probably forgot to commit the class. It should no works. > >> -- >> Regards, >> Cordialement, >> Emmanuel Lécharny >> www.iktek.com >> >> > -- Regards, Cordialement, Emmanuel Lécharny www.iktek.com
