You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Kiran Ayyagari <ka...@apache.org> on 2012/11/27 08:16:48 UTC

Re: svn commit: r1413771 - in /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication: ReplicaEventMessage.java ReplicaEventMessageSerializer.java

On Mon, Nov 26, 2012 at 11:58 PM, <el...@apache.org> 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.

[1] ClonedServerEntry objects hold the appropriate content to be send out
to clients (after filtering attributes etc..)

> -        // Entry's length
> -        out.writeInt( data.length );
> -
> -        // Entry's data
> -        out.write( data );
> -
> -        // The change type
> -        out.writeByte( changeType.getValue() );
> +        entry.writeExternal( out );
>
>          out.flush();
>
> @@ -124,25 +111,19 @@ public class ReplicaEventMessageSerializ
>
>          try
>          {
> +            // The changeType
> +            byte type = in.readByte();
> +            ChangeType changeType = ChangeType.getChangeType( type );
> +
>              // The Entry's DN
>              Dn entryDn = new Dn( schemaManager );
>              entryDn.readExternal( in );
>
> -            // The Entry's length
> -            int length = in.readInt();
> -
> -            byte[] data = new byte[length];
> -
> -            // The entry itself
> -            in.readFully( data );
> -
> -            Entry entry = ( Entry ) entrySerializer.deserialize( data );
> +            // The Entry
> +            Entry entry = new DefaultEntry( schemaManager );
> +            entry.readExternal( in );
>              entry.setDn( entryDn );
>
> -            // Read the changeType
> -            byte type = in.readByte();
> -            ChangeType changeType = ChangeType.getChangeType( type );
> -
>              // And create a ReplicaEventMessage
>              replicaEventMessage = new ReplicaEventMessage( changeType,
> entry );
>          }
>
>
>


-- 
Kiran Ayyagari
http://keydap.com

Re: svn commit: r1413771 - in /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication: ReplicaEventMessage.java ReplicaEventMessageSerializer.java

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 11/27/12 10:18 AM, Kiran Ayyagari a écrit :
> On Tue, Nov 27, 2012 at 1:58 PM, Emmanuel Lécharny <el...@gmail.com>wrote:
>
>> Le 11/27/12 8:16 AM, Kiran Ayyagari a écrit :
>>> On Mon, Nov 26, 2012 at 11:58 PM, <el...@apache.org> 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 


Re: svn commit: r1413771 - in /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication: ReplicaEventMessage.java ReplicaEventMessageSerializer.java

Posted by Kiran Ayyagari <ka...@apache.org>.
On Tue, Nov 27, 2012 at 1:58 PM, Emmanuel Lécharny <el...@gmail.com>wrote:

> Le 11/27/12 8:16 AM, Kiran Ayyagari a écrit :
> > On Mon, Nov 26, 2012 at 11:58 PM, <el...@apache.org> 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

>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>


-- 
Kiran Ayyagari
http://keydap.com

Re: svn commit: r1413771 - in /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication: ReplicaEventMessage.java ReplicaEventMessageSerializer.java

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 11/27/12 8:16 AM, Kiran Ayyagari a écrit :
> On Mon, Nov 26, 2012 at 11:58 PM, <el...@apache.org> 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.


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com