You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Selcuk AYA <ay...@gmail.com> on 2012/03/14 21:09:42 UTC

Re: svn commit: r1300690 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/log/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/directory/se

please revert this commit.

On Wed, Mar 14, 2012 at 12:06 PM,  <el...@apache.org> wrote:
> Author: elecharny
> Date: Wed Mar 14 19:06:17 2012
> New Revision: 1300690
>
> URL: http://svn.apache.org/viewvc?rev=1300690&view=rev
> Log:
> o Added a type for LogEdit stored into UserLogRecord, in order to be able to read them back from the stream knowing what is the stored data.
> o Created an injectData() method to factorize the serialization of the LogEdit instances
> o Removed the readObject()/writeObject() calls in the IndexChange class
> o Added some Javadoc
> o Minor refactoring
>
> Added:
>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java
>      - copied, changed from r1299595, directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java
> Modified:
>    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java
>    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java
>    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java
>    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/AbstractLogEdit.java
>    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/LogEdit.java
>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLogFileManager.java
>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogFlushManager.java
>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java
>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java
>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java
>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryChange.java
>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java
>
> Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java Wed Mar 14 19:06:17 2012
> @@ -86,7 +86,7 @@ public class LogAnchor implements Extern
>
>     public void resetLogAnchor( LogAnchor logAnchor )
>     {
> -        resetLogAnchor( logAnchor.getLogFileNumber(), logAnchor.getLogFileOffset(), logAnchor.getLogLSN() );
> +        resetLogAnchor( logAnchor.logFileNumber, logAnchor.logFileOffset, logAnchor.logLSN );
>     }
>
>
>
> Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java Wed Mar 14 19:06:17 2012
> @@ -44,6 +44,18 @@ import java.io.ObjectOutput;
>  */
>  public class UserLogRecord implements Externalizable
>  {
> +    /**
> +     * An enum used to distinguished the data type being serialized in the UserLogRecord
> +     */
> +    public enum LogEditType
> +    {
> +        TXN,
> +        DATA;
> +    }
> +
> +    /** The serialized LogEdit type */
> +    private LogEditType dataType;
> +
>     /** array used to hold user log records */
>     private byte[] recordHolder;
>
> @@ -101,12 +113,23 @@ public class UserLogRecord implements Ex
>     @Override
>     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
>     {
> +        // Read the DataType : TXN or DATA
> +        int type = in.read();
> +
> +        dataType = LogEditType.values()[type];
> +
> +        // The data size
>         length = in.readInt();
> -        int dataSize = in.readInt();
>
> -        recordHolder = new byte[dataSize];
> +        // The buffer size
> +        int bufferSize = in.readInt();
> +
> +        recordHolder = new byte[bufferSize];
> +
> +        // The buffer
>         in.readFully( recordHolder );
>
> +        // The position
>         logAnchor = new LogAnchor();
>         logAnchor.readExternal( in );
>     }
> @@ -124,13 +147,29 @@ public class UserLogRecord implements Ex
>     @Override
>     public void writeExternal( ObjectOutput out ) throws IOException
>     {
> +        // The inner data type : TXN or DATA
> +        out.write( dataType.ordinal() );
> +
> +        // The size of the stored data
>         out.writeInt( length );
> +
> +        // The size of the container buffer
>         out.writeInt( recordHolder.length );
> +
> +        // The buffer
>         out.write( recordHolder );
> +
> +        // The position
>         logAnchor.writeExternal( out );
>     }
>
>
> +    public void setType( LogEditType dataType )
> +    {
> +        this.dataType = dataType;
> +    }
> +
> +
>     /**
>      * @see Object#toString()
>      */
>
> Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java Wed Mar 14 19:06:17 2012
> @@ -36,7 +36,6 @@ import org.apache.directory.shared.ldap.
>  import org.apache.directory.shared.ldap.model.name.Dn;
>
>
> -
>  /**
>  *
>  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
> @@ -72,8 +71,7 @@ public interface TxnLogManager
>      * @param entry current version of the entry the txn has
>      * @return
>      */
> -    Entry mergeUpdates(Dn partitionDN, UUID entryID,  Entry entry );
> -
> +    Entry mergeUpdates( Dn partitionDN, UUID entryID, Entry entry );
>
>
>     /**
> @@ -131,7 +129,6 @@ public interface TxnLogManager
>         String attributeOid, boolean forwardIndex, Object onlyValueKey, UUID onlyIDKey ) throws Exception;
>
>
> -
>     /**
>      * Returns an index which a provides a transactionally consistent view over the given index
>      *
>
> Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/AbstractLogEdit.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/AbstractLogEdit.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/AbstractLogEdit.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/AbstractLogEdit.java Wed Mar 14 19:06:17 2012
> @@ -20,7 +20,13 @@
>  package org.apache.directory.server.core.api.txn.logedit;
>
>
> +import java.io.ByteArrayOutputStream;
> +import java.io.ObjectOutputStream;
> +
>  import org.apache.directory.server.core.api.log.LogAnchor;
> +import org.apache.directory.server.core.api.log.UserLogRecord;
> +import org.slf4j.Logger;
> +import org.slf4j.LoggerFactory;
>
>
>  /**
> @@ -29,13 +35,21 @@ import org.apache.directory.server.core.
>  */
>  public abstract class AbstractLogEdit implements LogEdit
>  {
> -    /** position in the wal */
> +    /** A logger for this class */
> +    private static final Logger LOG = LoggerFactory.getLogger( AbstractLogEdit.class );
> +
> +    /** Position in the wal */
>     private transient LogAnchor logAnchor = new LogAnchor();
>
>     /** Transaction under which the change is done */
>     protected long txnID;
>
>
> +    /**
> +     * Create a new instance of AbstractLogEdit
> +     *
> +     * @param txnID The transaction ID to store
> +     */
>     protected AbstractLogEdit( long txnID )
>     {
>         this.txnID = txnID;
> @@ -70,4 +84,44 @@ public abstract class AbstractLogEdit im
>     {
>         txnID = id;
>     }
> +
> +
> +    /**
> +     * {@inheritDoc}
> +     */
> +    public void injectData( UserLogRecord logRecord, UserLogRecord.LogEditType type ) throws Exception
> +    {
> +        logRecord.setType( type );
> +        LOG.debug( "Serializing : " + this );
> +
> +        ObjectOutputStream out = null;
> +        ByteArrayOutputStream bout = null;
> +        byte[] data;
> +
> +        try
> +        {
> +            bout = new ByteArrayOutputStream();
> +            out = new ObjectOutputStream( bout );
> +
> +            // The LogEdit instance
> +            writeExternal( out );
> +
> +            out.flush();
> +            data = bout.toByteArray();
> +        }
> +        finally
> +        {
> +            if ( bout != null )
> +            {
> +                bout.close();
> +            }
> +
> +            if ( out != null )
> +            {
> +                out.close();
> +            }
> +        }
> +
> +        logRecord.setData( data, data.length );
> +    }
>  }
>
> Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/LogEdit.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/LogEdit.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/LogEdit.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/LogEdit.java Wed Mar 14 19:06:17 2012
> @@ -19,15 +19,18 @@
>  */
>  package org.apache.directory.server.core.api.txn.logedit;
>
> -import org.apache.directory.server.core.api.log.LogAnchor;
>
>  import java.io.Externalizable;
>
> +import org.apache.directory.server.core.api.log.LogAnchor;
> +import org.apache.directory.server.core.api.log.UserLogRecord;
> +
> +
>  /**
>  *
>  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
>  */
> -public interface LogEdit extends Externalizable
> +public interface LogEdit extends Externalizable
>  {
>     /**
>      * Returns the position the edit is inserted in the wal.
> @@ -37,11 +40,22 @@ public interface LogEdit extends Externa
>      * @return position of the log edit in the wal
>      */
>     LogAnchor getLogAnchor();
> -
> +
> +
>     /**
>      * Applies the logedit to the underlying partitions
>      *
>      * @param recovery true if at recovery stage
>      */
>     void apply( boolean recovery ) throws Exception;
> +
> +
> +    /**
> +     * Serialize the LogEdit into a UserLogRecord
> +     *
> +     * @param logRecord The UserLogRecord which will contain the serialized LogEdit
> +     * @param type The type of data being written (TXN or DATA)
> +     * @throws Exception If the serialization failed
> +     */
> +    void injectData( UserLogRecord logRecord, UserLogRecord.LogEditType type ) throws Exception;
>  }
>
> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLogFileManager.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLogFileManager.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLogFileManager.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLogFileManager.java Wed Mar 14 19:06:17 2012
> @@ -22,16 +22,16 @@ package org.apache.directory.server.core
>
>  import java.io.EOFException;
>  import java.io.File;
> -import java.io.IOException;
>  import java.io.FileNotFoundException;
> -
> +import java.io.IOException;
>  import java.io.RandomAccessFile;
>
>
>  /**
>  * Creates and manages a LogFile on disk. The file name is the concatenation of a
>  * path on disk, and of a suffix.<br/>
> - * Each log file has a name like <b>logFileName/log_&lt;logFileNumber&gt;.suffix</b>
> + * Each log file has a name like <b>logFileName/log_&lt;logFileNumber&gt;.suffix</b><br/>
> + * This class expose a reader and a writer for the given log file.
>  *
>  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
>  */
>
> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogFlushManager.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogFlushManager.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogFlushManager.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogFlushManager.java Wed Mar 14 19:06:17 2012
> @@ -20,31 +20,29 @@
>  package org.apache.directory.server.core.shared.log;
>
>
> +import java.io.IOException;
>  import java.nio.ByteBuffer;
> -
> +import java.util.concurrent.atomic.AtomicInteger;
> +import java.util.concurrent.locks.Condition;
>  import java.util.concurrent.locks.Lock;
>  import java.util.concurrent.locks.ReentrantLock;
> -import java.util.concurrent.locks.Condition;
> -import java.util.concurrent.atomic.AtomicInteger;
>  import java.util.zip.Adler32;
>  import java.util.zip.Checksum;
>
> +import org.apache.directory.server.core.api.log.InvalidLogException;
>  import org.apache.directory.server.core.api.log.LogAnchor;
>  import org.apache.directory.server.core.api.log.UserLogRecord;
> -import org.apache.directory.server.core.api.log.InvalidLogException;
> -
> -import java.io.IOException;
> -
>  import org.apache.directory.server.core.shared.log.LogFileManager.LogFileWriter;
>  import org.apache.directory.server.i18n.I18n;
>
>
>  /**
> - * Manages the flushing of log to media and scanning of logs. All appends to the log file go through this class.
> + * Manages the flushing of log to media and scanning of logs. All appends to the log file go
> + * through this class.
>  *
>  * Internally it manages a circular  buffer where appends initially go. Appends are first
> - * appended to this in memory circular log. As the in memory circular log fills up or as the user requests
> - * memory buffer is flushed to the underlying media.
> + * appended to this in memory circular log. As the in memory circular log fills up or as the
> + * user requests, memory buffer is flushed to the underlying media.
>  *
>  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
>  */
> @@ -92,7 +90,7 @@ import org.apache.directory.server.i18n.
>
>     /**
>      * Creates a LogFlushManager instance. We define the memory buffer size, and the default maximum
> -     * size for each Log file (this maximul size may be exceeded, if one user record is bigger than
> +     * size for each Log file (this maximum size may be exceeded, if one user record is bigger than
>      * this maximum size. Log file may be smaller too.
>      *
>      * @param logManager The associated LogManager
> @@ -191,7 +189,7 @@ import org.apache.directory.server.i18n.
>                             // Write the data
>                             writeHead.put( userBuffer, 0, length );
>
> -                            // Write the footeer
> +                            // Write the footer
>                             writeFooter( writeHead, ( int ) checksum.getValue() );
>
>                             appendedRecord = true;
>
> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java Wed Mar 14 19:06:17 2012
> @@ -20,9 +20,7 @@
>  package org.apache.directory.server.core.shared.txn;
>
>
> -import java.io.ByteArrayOutputStream;
>  import java.io.IOException;
> -import java.io.ObjectOutputStream;
>  import java.util.Comparator;
>  import java.util.UUID;
>
> @@ -105,32 +103,7 @@ public class DefaultTxnLogManager implem
>         ReadWriteTxn txn = ( ReadWriteTxn ) curTxn;
>         UserLogRecord logRecord = txn.getUserLogRecord();
>
> -        ObjectOutputStream out = null;
> -        ByteArrayOutputStream bout = null;
> -        byte[] data;
> -
> -        try
> -        {
> -            bout = new ByteArrayOutputStream();
> -            out = new ObjectOutputStream( bout );
> -            logEdit.writeExternal( out );
> -            out.flush();
> -            data = bout.toByteArray();
> -        }
> -        finally
> -        {
> -            if ( bout != null )
> -            {
> -                bout.close();
> -            }
> -
> -            if ( out != null )
> -            {
> -                out.close();
> -            }
> -        }
> -
> -        logRecord.setData( data, data.length );
> +        logEdit.injectData( logRecord, UserLogRecord.LogEditType.DATA );
>
>         log( logRecord, sync );
>
>
> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java Wed Mar 14 19:06:17 2012
> @@ -20,9 +20,7 @@
>  package org.apache.directory.server.core.shared.txn;
>
>
> -import java.io.ByteArrayOutputStream;
>  import java.io.IOException;
> -import java.io.ObjectOutputStream;
>  import java.util.HashSet;
>  import java.util.Iterator;
>  import java.util.List;
> @@ -43,6 +41,7 @@ import org.apache.directory.server.core.
>  import org.apache.directory.server.core.api.txn.TxnConflictException;
>  import org.apache.directory.server.core.api.txn.TxnHandle;
>  import org.apache.directory.server.core.api.txn.TxnLogManager;
> +import org.apache.directory.server.core.api.txn.logedit.LogEdit;
>  import org.apache.directory.server.core.shared.txn.logedit.TxnStateChange;
>
>
> @@ -64,7 +63,7 @@ class DefaultTxnManager implements TxnMa
>
>     /** Used to assign start and commit version numbers to writeTxns */
>     private Lock writeTxnsLock = new ReentrantLock();
> -
> +
>     /** Used to order txns in case of conflicts */
>     private ReadWriteLock optimisticLock = new ReentrantReadWriteLock();
>
> @@ -175,6 +174,7 @@ class DefaultTxnManager implements TxnMa
>         syncer = null;
>     }
>
> +
>     /**
>      * {@inheritDoc}
>      */
> @@ -184,19 +184,19 @@ class DefaultTxnManager implements TxnMa
>
>         // Should have a rw txn
>         if ( ( curTxn == null ) ||
> -              !( curTxn instanceof ReadWriteTxn )  )
> +            !( curTxn instanceof ReadWriteTxn ) )
>         {
>             // Cannot start a TXN when a RW txn is ongoing
>             throw new IllegalStateException( "Unexpected txn state when trying txn: " +
>                 curTxn );
>         }
> -
> +
>         // abort current txn and start a new read write txn
> -
> +
>         abortTransaction();
>         return beginReadWriteTxn( true );
>     }
> -
> +
>
>     /**
>      * {@inheritDoc}
> @@ -241,7 +241,7 @@ class DefaultTxnManager implements TxnMa
>         {
>             throw new IOException( "Flushing of txns failed" );
>         }
> -
> +
>         prepareForEndingTxn( txn );
>
>         if ( txn instanceof ReadOnlyTxn )
> @@ -265,23 +265,23 @@ class DefaultTxnManager implements TxnMa
>     public void abortTransaction() throws Exception
>     {
>         Transaction txn = getCurTxn();
> -
> +
>         if ( txn == null )
>         {
> -            throw new IllegalStateException("Trying to abort while there is not txn ");
> +            throw new IllegalStateException( "Trying to abort while there is not txn " );
>         }
> -
> +
>         boolean isExclusive = txn.isExclusive();
>
>         try
>         {
>             prepareForEndingTxn( txn );
> -
> +
>             if ( txn instanceof ReadWriteTxn )
>             {
>                 abortReadWriteTxn( ( ReadWriteTxn ) txn );
>             }
> -
> +
>             txn.abortTxn();
>             setCurTxn( null );
>         }
> @@ -420,7 +420,7 @@ class DefaultTxnManager implements TxnMa
>
>         buildCheckList( txn, lastTxnToCheck );
>
> -        optimisticLock.readLock().lock();
> +        optimisticLock.readLock().lock();
>         setCurTxn( txn );
>
>         //System.out.println( "TRAN: Started " + txn );
> @@ -440,35 +440,11 @@ class DefaultTxnManager implements TxnMa
>         ReadWriteTxn txn = new ReadWriteTxn();
>         UserLogRecord logRecord = txn.getUserLogRecord();
>
> -        TxnStateChange txnRecord = new TxnStateChange( LogAnchor.UNKNOWN_LSN,
> +        LogEdit logEdit = new TxnStateChange( LogAnchor.UNKNOWN_LSN,
>             TxnStateChange.ChangeState.TXN_BEGIN );
> -        ObjectOutputStream out = null;
> -        ByteArrayOutputStream bout = null;
> -        byte[] data;
>
> -        try
> -        {
> -            bout = new ByteArrayOutputStream();
> -            out = new ObjectOutputStream( bout );
> -            txnRecord.writeExternal( out );
> -            out.flush();
> -            data = bout.toByteArray();
> -        }
> -        finally
> -        {
> -            if ( bout != null )
> -            {
> -                bout.close();
> -            }
> +        logEdit.injectData( logRecord, UserLogRecord.LogEditType.TXN );
>
> -            if ( out != null )
> -            {
> -                out.close();
> -            }
> -        }
> -
> -        logRecord.setData( data, data.length );
> -
>         if ( retry == false )
>         {
>             optimisticLock.readLock().lock();
> @@ -506,7 +482,7 @@ class DefaultTxnManager implements TxnMa
>             }
>             while ( lastTxnToCheck != latestVerifiedTxn.get() );
>         }
> -        catch( Exception e )
> +        catch ( Exception e )
>         {
>             if ( txn.isExclusive() == false )
>             {
> @@ -657,34 +633,10 @@ class DefaultTxnManager implements TxnMa
>     {
>         UserLogRecord logRecord = txn.getUserLogRecord();
>
> -        TxnStateChange txnRecord = new TxnStateChange( txn.getStartTime(),
> +        LogEdit logEdit = new TxnStateChange( txn.getStartTime(),
>             TxnStateChange.ChangeState.TXN_COMMIT );
> -        ObjectOutputStream out = null;
> -        ByteArrayOutputStream bout = null;
> -        byte[] data;
>
> -        try
> -        {
> -            bout = new ByteArrayOutputStream();
> -            out = new ObjectOutputStream( bout );
> -            txnRecord.writeExternal( out );
> -            out.flush();
> -            data = bout.toByteArray();
> -        }
> -        finally
> -        {
> -            if ( bout != null )
> -            {
> -                bout.close();
> -            }
> -
> -            if ( out != null )
> -            {
> -                out.close();
> -            }
> -        }
> -
> -        logRecord.setData( data, data.length );
> +        logEdit.injectData( logRecord, UserLogRecord.LogEditType.TXN );
>
>         verifyLock.lock();
>
> @@ -738,34 +690,11 @@ class DefaultTxnManager implements TxnMa
>     {
>         UserLogRecord logRecord = txn.getUserLogRecord();
>
> -        TxnStateChange txnRecord = new TxnStateChange( txn.getStartTime(),
> +        LogEdit logEdit = new TxnStateChange( txn.getStartTime(),
>             TxnStateChange.ChangeState.TXN_ABORT );
> -        ObjectOutputStream out = null;
> -        ByteArrayOutputStream bout = null;
> -        byte[] data;
>
> -        try
> -        {
> -            bout = new ByteArrayOutputStream();
> -            out = new ObjectOutputStream( bout );
> -            out.writeObject( txnRecord );
> -            out.flush();
> -            data = bout.toByteArray();
> -        }
> -        finally
> -        {
> -            if ( bout != null )
> -            {
> -                bout.close();
> -            }
> -
> -            if ( out != null )
> -            {
> -                out.close();
> -            }
> -        }
> +        logEdit.injectData( logRecord, UserLogRecord.LogEditType.TXN );
>
> -        logRecord.setData( data, data.length );
>         txnLogManager.log( logRecord, false );
>     }
>
>
> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java Wed Mar 14 19:06:17 2012
> @@ -72,6 +72,7 @@ public class DataChangeContainer extends
>     public DataChangeContainer( Partition partition )
>     {
>         super( Long.MIN_VALUE );
> +
>         this.partitionDn = partition.getSuffixDn();
>         this.partition = partition;
>     }
>
> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryChange.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryChange.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryChange.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryChange.java Wed Mar 14 19:06:17 2012
> @@ -92,7 +92,7 @@ public class EntryChange implements Entr
>             }
>         }
>
> -        // TODO in reovery mode, check the version of the entry.
> +        // TODO in recovery mode, check the version of the entry.
>         try
>         {
>             AttributeUtils.applyModification( curEntry, redoChange );
>
> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java?rev=1300690&r1=1300689&r2=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java Wed Mar 14 19:06:17 2012
> @@ -62,6 +62,15 @@ public class IndexChange implements Inde
>     }
>
>
> +    /**
> +     * Create a new IndexChange instance.
> +     *
> +     * @param index The changed index
> +     * @param key The index' key
> +     * @param id The entry's UUID
> +     * @param type The change type, Add or Delete
> +     * @param isSystemIndex Tells f the index is a system index or a user index
> +     */
>     public IndexChange( Index<?> index, Object key, UUID id, Type type, boolean isSystemIndex )
>     {
>         this.index = index;
> @@ -155,7 +164,29 @@ public class IndexChange implements Inde
>     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
>     {
>         oid = in.readUTF();
> -        key = in.readObject();
> +        KeyType keyType = KeyType.getType( in.readByte() );
> +
> +        switch ( keyType )
> +        {
> +            case STRING:
> +                key = in.readUTF();
> +                break;
> +
> +            case LONG:
> +                key = in.readLong();
> +                break;
> +
> +            case BYTES:
> +                int length = in.readInt();
> +                key = new byte[length];
> +                in.read( ( byte[] ) key );
> +                break;
> +
> +            case OBJECT:
> +                key = in.readObject();
> +                break;
> +        }
> +
>         id = UUID.fromString( in.readUTF() );
>         type = Type.values()[in.readInt()];
>     }
> @@ -165,7 +196,29 @@ public class IndexChange implements Inde
>     public void writeExternal( ObjectOutput out ) throws IOException
>     {
>         out.writeUTF( oid );
> -        out.writeObject( key );
> +
> +        if ( key instanceof String )
> +        {
> +            out.write( KeyType.STRING.getOrdinal() );
> +            out.writeUTF( ( String ) key );
> +        }
> +        else if ( key instanceof byte[] )
> +        {
> +            out.write( KeyType.BYTES.getOrdinal() );
> +            out.writeInt( ( ( byte[] ) key ).length );
> +            out.write( ( byte[] ) key );
> +        }
> +        else if ( key instanceof Long )
> +        {
> +            out.write( KeyType.LONG.getOrdinal() );
> +            out.writeLong( ( Long ) key );
> +        }
> +        else
> +        {
> +            out.write( KeyType.OBJECT.getOrdinal() );
> +            out.writeObject( key );
> +        }
> +
>         out.writeUTF( id.toString() );
>         out.writeInt( type.ordinal() );
>     }
> @@ -185,6 +238,7 @@ public class IndexChange implements Inde
>         StringBuilder sb = new StringBuilder();
>
>         sb.append( "IndexChange '" );
> +
>         // The index's name
>         sb.append( index.getAttributeId() ).append( "': " );
>
> @@ -201,4 +255,42 @@ public class IndexChange implements Inde
>
>         return sb.toString();
>     }
> +
> +    private enum KeyType
> +    {
> +        STRING(0),
> +        LONG(1),
> +        BYTES(2),
> +        OBJECT(3);
> +
> +        private int value;
> +
> +
> +        private KeyType( int value )
> +        {
> +            this.value = value;
> +        }
> +
> +
> +        private byte getOrdinal()
> +        {
> +            return ( byte ) value;
> +        }
> +
> +
> +        private static KeyType getType( byte value )
> +        {
> +            switch ( value )
> +            {
> +                case 0:
> +                    return STRING;
> +                case 1:
> +                    return LONG;
> +                case 2:
> +                    return BYTES;
> +                default:
> +                    return OBJECT;
> +            }
> +        }
> +    }
>  }
>
> Copied: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java (from r1299595, directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java)
> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java?p2=directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java&p1=directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java&r1=1299595&r2=1300690&rev=1300690&view=diff
> ==============================================================================
> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java (original)
> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java Wed Mar 14 19:06:17 2012
> @@ -28,31 +28,60 @@ import org.apache.directory.server.core.
>
>
>  /**
> + * A class used to store a transaction changeState (either BEGIN, COMMIT or ABORT).
>  *
>  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
>  */
>  public class TxnStateChange extends AbstractLogEdit
>  {
> +    /** SerialVrsionUID as requested for serializable classes */
> +    private static final long serialVersionUID = 1;
> +
> +    /**
> +     * Change State, one of :
> +     * <ul>
> +     * <li>TXN_BEGIN : for a starting transaction</li>
> +     * <li>TXN_COMMIT :  for a validated transaction</li>
> +     * <li>TXN_ABORT : for an aborted transaction</li>
> +     * </ul>
> +     */
> +    public enum ChangeState
> +    {
> +        TXN_BEGIN,
> +        TXN_COMMIT,
> +        TXN_ABORT
> +    }
> +
>     /** State to record for the txn */
>     ChangeState txnState;
>
> -    private static final long serialVersionUID = 1;
> -
>
> -    // For deserialization
> +    /**
> +     * A default constructor used by deserialization
> +     */
>     public TxnStateChange()
>     {
>         super( Long.MIN_VALUE );
>     }
>
>
> +    /**
> +     * Creates a new TxnStateChange instance, with a transaction ID and a ChangeState.
> +     *
> +     * @param txnID The transaction ID
> +     * @param txnState The ChangeState
> +     */
>     public TxnStateChange( long txnID, ChangeState txnState )
>     {
>         super( txnID );
> +
>         this.txnState = txnState;
>     }
>
>
> +    /**
> +     * @return The ChangeState for this transaction
> +     */
>     public ChangeState getTxnState()
>     {
>         return txnState;
> @@ -74,10 +103,12 @@ public class TxnStateChange extends Abst
>         out.writeInt( txnState.ordinal() );
>     }
>
> -    public enum ChangeState
> +
> +    /**
> +     * @see Object#toString()
> +     */
> +    public String toString()
>     {
> -        TXN_BEGIN,
> -        TXN_COMMIT,
> -        TXN_ABORT
> +        return "TxnStateChange[" + txnID + "/" + txnState + "]";
>     }
>  }
>
>

Re: svn commit: r1300690 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/log/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/directory/se

Posted by Emmanuel Lécharny <el...@gmail.com>.
Some more clarifications about the changes :

when we write a LogEdit, we have two cases :
1) we write a ChangeDataContainer
2) we write a Transaction state

In the first case, we serialize the data in the log( LogEdit, sync) 
method using the current transaction logRecord, then we call the log( 
UserLogRecord, sync) method which will write the record in the WAL. In 
the second case, we simply call the log( UserLogRecord, sync) without 
having to grab the current transaction, as we already are dealing with a 
transaction. The places where this is done are :
  DefaultTxnManager.abortReadWriteTxn
  DefaultTxnManager.beginReadWriteTxn
  DefaultTxnManager.commitReadWriteTxn

I created a LogEdit.injectData( userLogRecord, type ) to have one single 
place to manage the serialization of a LogEdit instance 
(ChangeDataContainer ot TxnStateChange) instead of 4, and to be able to 
add some log.debug() in one single place instead of 4. This does not 
change the logic of this part of the code.

Regarding the added type, as I explained in another mail, I did that to 
be sure we can handle cases where we wil have something not expected 
like a sequence of TXN_BEGIN/TXN_COMMIT without any DATA_CONTAINER. Here 
is an exemple of the trace I get with a simple Add request :


Serializing : TxnStateChange[-9223372036854775808/TXN_BEGIN]
Serializing : TxnStateChange[-9223372036854775804/TXN_COMMIT]

Serializing : TxnStateChange[-9223372036854775808/TXN_BEGIN]
Serializing : DataChangeContainer(ou=system, 
866e5898-6aaa-4e84-96f2-c423bb6ef8b2, -9223372036854775808)
{
     IndexChange '1.3.6.1.4.1.18060.0.4.1.2.50': <ADD, 
866e5898-6aaa-4e84-96f2-c423bb6ef8b2, 
ParentIdAndRdn<96512910-d92d-49c4-ac8a-20d28c4ff57c, 'cn=test'>>
     IndexChange '2.5.4.0': <ADD, 866e5898-6aaa-4e84-96f2-c423bb6ef8b2, 
person>
     IndexChange '2.5.4.0': <ADD, 866e5898-6aaa-4e84-96f2-c423bb6ef8b2, top>
     IndexChange '1.3.6.1.4.1.18060.0.4.1.2.4': <ADD, 
866e5898-6aaa-4e84-96f2-c423bb6ef8b2, 96512910-d92d-49c4-ac8a-20d28c4ff57c>
     IndexChange '1.3.6.1.4.1.18060.0.4.1.2.43': <ADD, 
866e5898-6aaa-4e84-96f2-c423bb6ef8b2, 866e5898-6aaa-4e84-96f2-c423bb6ef8b2>
     IndexChange '1.3.6.1.4.1.4203.666.1.7': <ADD, 
866e5898-6aaa-4e84-96f2-c423bb6ef8b2, 
20120314234251.077000Z#000000#000#000000>
     IndexChange '1.3.6.1.1.16.4': <ADD, 
866e5898-6aaa-4e84-96f2-c423bb6ef8b2, 866e5898-6aaa-4e84-96f2-c423bb6ef8b2>
     EntryAddDelete : ADD
Entry
     dn[n]: cn=test,ou=system
     objectclass: person
     objectclass: top
     cn: test
     sn: TEST
     entryParentId: 96512910-d92d-49c4-ac8a-20d28c4ff57c
     entryUUID: 866e5898-6aaa-4e84-96f2-c423bb6ef8b2
     createTimestamp: 20120314234251Z
     creatorsName: 0.9.2342.19200300.100.1.1=admin,2.5.4.11=system
     entryCSN: 20120314234251.077000Z#000000#000#000000

}
Serializing : TxnStateChange[-9223372036854775802/TXN_COMMIT]


I slightly modified some of the read/writeExternal methods too, 
especially the one that serailize the index. Call it premature 
optimization... At least, those changes are local to those methods.

Hope it helps to understand the changes

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


Re: svn commit: r1300690 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/log/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/directory/se

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 3/14/12 11:56 PM, Selcuk AYA a écrit :
> On Wed, Mar 14, 2012 at 3:51 PM, Emmanuel Lécharny<el...@gmail.com>  wrote:
>> Le 3/14/12 11:32 PM, Selcuk AYA a écrit :
>>
>>> On Wed, Mar 14, 2012 at 3:23 PM, Emmanuel Lécharny<el...@gmail.com>
>>>   wrote:
>>>> Le 3/14/12 10:52 PM, Selcuk AYA a écrit :
>>>>
>>>>> HI All,
>>>>> Sorry for the earlier email. I think I owe some explaination on my
>>>>> part. The reason for my request is purely technical, does not aim at
>>>>> oss spirit or any other spirit for that matter:
>>>>> * There are quite a number of files the txn branch is touching.
>>>>> * There is no file ownership or review process.
>>>>>
>>>>> combined with the timing limitation, it becomes hard for me to track
>>>>> all changes and cleanup if necessary. When I am doing my changes and
>>>>> need to change some existing stuff, I usually try to find the guy who
>>>>> wrote the code and get an ack from him and this usually helps a lot
>>>>> because even things that look stupid might have some reason to be
>>>>> there. Please do the same while changing the txn branch.If this
>>>>> process is followed, we wont have to discuss spirit hurting through
>>>>> reverting code.
>>>> np. We can consider that the branch is your sandbox, and i'll keep it
>>>> alone,
>>>> just let me know.
>>>>
>>>> Look, I'm not trying to collide with what you are doing, Selcuk. Just
>>>> trying
>>>> to add the necessary doco and clarification (ie, logs, formating) to get
>>>> people used with the code. If the code is not finished yet, and can keep
>>>> away from it atm, just say so.
>>>>
>>>> I'm pretty sure we need to communicate more here to avoid such issues :
>>>> - telling what's going on through the exposure of a roadmap
>>>> - being more reactive (like just ack mails even if one does not have time
>>>> to
>>>> give a clear answer)
>>>>
>>>> Regarding the changed code, let me give you some clue about the reason I
>>>> did
>>>> those changes :
>>>> when you log some LogEdit, the records are stored in a file and will have
>>>> to
>>>> be read at some point. The externalizable classes have readExternal()
>>>> methods which expect the byte[] to contain the expected content.
>>>> Currently,
>>>> we can do that if :
>>>> - we have stored only one type of object (like Entry)
>>>> - we have stored mixed data in a specific order, which allows the code to
>>>> deserialize the classes without adding a type.
>>>>
>>>> I guess that the intention was to deserialize data expecting the
>>>> serialized
>>>> structure will always be :
>>>> - TXN_BEGIN
>>>> - a DATA_CONTAINER
>>>> - TXN_COMMIT or TXN_ABORT
>>>>
>>>> Here, I see one issues : in one case, we won't have any DATA_CONTAINER
>>>> (specifically when doing a BIND). We won't then be able to distinguish
>>>> between a TXN_BEGIN/DATA/TXN_COMMIT and a TXN_BEGIN/TXN_COMMIT if we
>>>> don't
>>>> have an extra information, the type.
>>>>
>>>> Unless there is something that can be used to make this distinction...
>>>>
>>>> Can you enlight me here, in cas I'm doing something wrong ?
>>>>
>>> I will have a look at the code your tomorrow morning time and let you
>>> know.
>>
>> ok, fine. I'll try to be connected early (like 08:00 CET / 0:00PDT) so that
>> we can discuss on IRC. Let me know if that's fine for you.
>>
>> I'll crash in 15 minutes.
>>
> usually email communication and waiting around a day for an email
> reply should be fine but OK lets discuss this case on IRC.
Considering the 9h lag, I totally agree. I just suggested that if you'd 
like having a IRC convo to clarify some of the technical point, I'll be 
around, but this is not mandatory. Here, it's totally your call, and 
frankly, I would favor email echanges over IRC.



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


Re: svn commit: r1300690 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/log/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/directory/se

Posted by Selcuk AYA <ay...@gmail.com>.
On Wed, Mar 14, 2012 at 3:51 PM, Emmanuel Lécharny <el...@gmail.com> wrote:
> Le 3/14/12 11:32 PM, Selcuk AYA a écrit :
>
>> On Wed, Mar 14, 2012 at 3:23 PM, Emmanuel Lécharny<el...@gmail.com>
>>  wrote:
>>>
>>> Le 3/14/12 10:52 PM, Selcuk AYA a écrit :
>>>
>>>> HI All,
>>>> Sorry for the earlier email. I think I owe some explaination on my
>>>> part. The reason for my request is purely technical, does not aim at
>>>> oss spirit or any other spirit for that matter:
>>>> * There are quite a number of files the txn branch is touching.
>>>> * There is no file ownership or review process.
>>>>
>>>> combined with the timing limitation, it becomes hard for me to track
>>>> all changes and cleanup if necessary. When I am doing my changes and
>>>> need to change some existing stuff, I usually try to find the guy who
>>>> wrote the code and get an ack from him and this usually helps a lot
>>>> because even things that look stupid might have some reason to be
>>>> there. Please do the same while changing the txn branch.If this
>>>> process is followed, we wont have to discuss spirit hurting through
>>>> reverting code.
>>>
>>> np. We can consider that the branch is your sandbox, and i'll keep it
>>> alone,
>>> just let me know.
>>>
>>> Look, I'm not trying to collide with what you are doing, Selcuk. Just
>>> trying
>>> to add the necessary doco and clarification (ie, logs, formating) to get
>>> people used with the code. If the code is not finished yet, and can keep
>>> away from it atm, just say so.
>>>
>>> I'm pretty sure we need to communicate more here to avoid such issues :
>>> - telling what's going on through the exposure of a roadmap
>>> - being more reactive (like just ack mails even if one does not have time
>>> to
>>> give a clear answer)
>>>
>>> Regarding the changed code, let me give you some clue about the reason I
>>> did
>>> those changes :
>>> when you log some LogEdit, the records are stored in a file and will have
>>> to
>>> be read at some point. The externalizable classes have readExternal()
>>> methods which expect the byte[] to contain the expected content.
>>> Currently,
>>> we can do that if :
>>> - we have stored only one type of object (like Entry)
>>> - we have stored mixed data in a specific order, which allows the code to
>>> deserialize the classes without adding a type.
>>>
>>> I guess that the intention was to deserialize data expecting the
>>> serialized
>>> structure will always be :
>>> - TXN_BEGIN
>>> - a DATA_CONTAINER
>>> - TXN_COMMIT or TXN_ABORT
>>>
>>> Here, I see one issues : in one case, we won't have any DATA_CONTAINER
>>> (specifically when doing a BIND). We won't then be able to distinguish
>>> between a TXN_BEGIN/DATA/TXN_COMMIT and a TXN_BEGIN/TXN_COMMIT if we
>>> don't
>>> have an extra information, the type.
>>>
>>> Unless there is something that can be used to make this distinction...
>>>
>>> Can you enlight me here, in cas I'm doing something wrong ?
>>>
>> I will have a look at the code your tomorrow morning time and let you
>> know.
>
>
> ok, fine. I'll try to be connected early (like 08:00 CET / 0:00PDT) so that
> we can discuss on IRC. Let me know if that's fine for you.
>
> I'll crash in 15 minutes.
>

usually email communication and waiting around a day for an email
reply should be fine but OK lets discuss this case on IRC.

thanks
Selcuk

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

Re: svn commit: r1300690 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/log/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/directory/se

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 3/14/12 11:32 PM, Selcuk AYA a écrit :
> On Wed, Mar 14, 2012 at 3:23 PM, Emmanuel Lécharny<el...@gmail.com>  wrote:
>> Le 3/14/12 10:52 PM, Selcuk AYA a écrit :
>>
>>> HI All,
>>> Sorry for the earlier email. I think I owe some explaination on my
>>> part. The reason for my request is purely technical, does not aim at
>>> oss spirit or any other spirit for that matter:
>>> * There are quite a number of files the txn branch is touching.
>>> * There is no file ownership or review process.
>>>
>>> combined with the timing limitation, it becomes hard for me to track
>>> all changes and cleanup if necessary. When I am doing my changes and
>>> need to change some existing stuff, I usually try to find the guy who
>>> wrote the code and get an ack from him and this usually helps a lot
>>> because even things that look stupid might have some reason to be
>>> there. Please do the same while changing the txn branch.If this
>>> process is followed, we wont have to discuss spirit hurting through
>>> reverting code.
>> np. We can consider that the branch is your sandbox, and i'll keep it alone,
>> just let me know.
>>
>> Look, I'm not trying to collide with what you are doing, Selcuk. Just trying
>> to add the necessary doco and clarification (ie, logs, formating) to get
>> people used with the code. If the code is not finished yet, and can keep
>> away from it atm, just say so.
>>
>> I'm pretty sure we need to communicate more here to avoid such issues :
>> - telling what's going on through the exposure of a roadmap
>> - being more reactive (like just ack mails even if one does not have time to
>> give a clear answer)
>>
>> Regarding the changed code, let me give you some clue about the reason I did
>> those changes :
>> when you log some LogEdit, the records are stored in a file and will have to
>> be read at some point. The externalizable classes have readExternal()
>> methods which expect the byte[] to contain the expected content. Currently,
>> we can do that if :
>> - we have stored only one type of object (like Entry)
>> - we have stored mixed data in a specific order, which allows the code to
>> deserialize the classes without adding a type.
>>
>> I guess that the intention was to deserialize data expecting the serialized
>> structure will always be :
>> - TXN_BEGIN
>> - a DATA_CONTAINER
>> - TXN_COMMIT or TXN_ABORT
>>
>> Here, I see one issues : in one case, we won't have any DATA_CONTAINER
>> (specifically when doing a BIND). We won't then be able to distinguish
>> between a TXN_BEGIN/DATA/TXN_COMMIT and a TXN_BEGIN/TXN_COMMIT if we don't
>> have an extra information, the type.
>>
>> Unless there is something that can be used to make this distinction...
>>
>> Can you enlight me here, in cas I'm doing something wrong ?
>>
> I will have a look at the code your tomorrow morning time and let you know.

ok, fine. I'll try to be connected early (like 08:00 CET / 0:00PDT) so 
that we can discuss on IRC. Let me know if that's fine for you.

I'll crash in 15 minutes.


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


Re: svn commit: r1300690 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/log/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/directory/se

Posted by Selcuk AYA <ay...@gmail.com>.
On Wed, Mar 14, 2012 at 3:23 PM, Emmanuel Lécharny <el...@gmail.com> wrote:
> Le 3/14/12 10:52 PM, Selcuk AYA a écrit :
>
>> HI All,
>> Sorry for the earlier email. I think I owe some explaination on my
>> part. The reason for my request is purely technical, does not aim at
>> oss spirit or any other spirit for that matter:
>> * There are quite a number of files the txn branch is touching.
>> * There is no file ownership or review process.
>>
>> combined with the timing limitation, it becomes hard for me to track
>> all changes and cleanup if necessary. When I am doing my changes and
>> need to change some existing stuff, I usually try to find the guy who
>> wrote the code and get an ack from him and this usually helps a lot
>> because even things that look stupid might have some reason to be
>> there. Please do the same while changing the txn branch.If this
>> process is followed, we wont have to discuss spirit hurting through
>> reverting code.
>
> np. We can consider that the branch is your sandbox, and i'll keep it alone,
> just let me know.
>
> Look, I'm not trying to collide with what you are doing, Selcuk. Just trying
> to add the necessary doco and clarification (ie, logs, formating) to get
> people used with the code. If the code is not finished yet, and can keep
> away from it atm, just say so.
>
> I'm pretty sure we need to communicate more here to avoid such issues :
> - telling what's going on through the exposure of a roadmap
> - being more reactive (like just ack mails even if one does not have time to
> give a clear answer)
>
> Regarding the changed code, let me give you some clue about the reason I did
> those changes :
> when you log some LogEdit, the records are stored in a file and will have to
> be read at some point. The externalizable classes have readExternal()
> methods which expect the byte[] to contain the expected content. Currently,
> we can do that if :
> - we have stored only one type of object (like Entry)
> - we have stored mixed data in a specific order, which allows the code to
> deserialize the classes without adding a type.
>
> I guess that the intention was to deserialize data expecting the serialized
> structure will always be :
> - TXN_BEGIN
> - a DATA_CONTAINER
> - TXN_COMMIT or TXN_ABORT
>
> Here, I see one issues : in one case, we won't have any DATA_CONTAINER
> (specifically when doing a BIND). We won't then be able to distinguish
> between a TXN_BEGIN/DATA/TXN_COMMIT and a TXN_BEGIN/TXN_COMMIT if we don't
> have an extra information, the type.
>
> Unless there is something that can be used to make this distinction...
>
> Can you enlight me here, in cas I'm doing something wrong ?
>

I will have a look at the code your tomorrow morning time and let you know.


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

Re: svn commit: r1300690 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/log/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/directory/se

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 3/14/12 10:52 PM, Selcuk AYA a écrit :
> HI All,
> Sorry for the earlier email. I think I owe some explaination on my
> part. The reason for my request is purely technical, does not aim at
> oss spirit or any other spirit for that matter:
> * There are quite a number of files the txn branch is touching.
> * There is no file ownership or review process.
>
> combined with the timing limitation, it becomes hard for me to track
> all changes and cleanup if necessary. When I am doing my changes and
> need to change some existing stuff, I usually try to find the guy who
> wrote the code and get an ack from him and this usually helps a lot
> because even things that look stupid might have some reason to be
> there. Please do the same while changing the txn branch.If this
> process is followed, we wont have to discuss spirit hurting through
> reverting code.
np. We can consider that the branch is your sandbox, and i'll keep it 
alone, just let me know.

Look, I'm not trying to collide with what you are doing, Selcuk. Just 
trying to add the necessary doco and clarification (ie, logs, formating) 
to get people used with the code. If the code is not finished yet, and 
can keep away from it atm, just say so.

I'm pretty sure we need to communicate more here to avoid such issues :
- telling what's going on through the exposure of a roadmap
- being more reactive (like just ack mails even if one does not have 
time to give a clear answer)

Regarding the changed code, let me give you some clue about the reason I 
did those changes :
when you log some LogEdit, the records are stored in a file and will 
have to be read at some point. The externalizable classes have 
readExternal() methods which expect the byte[] to contain the expected 
content. Currently, we can do that if :
- we have stored only one type of object (like Entry)
- we have stored mixed data in a specific order, which allows the code 
to deserialize the classes without adding a type.

I guess that the intention was to deserialize data expecting the 
serialized structure will always be :
- TXN_BEGIN
- a DATA_CONTAINER
- TXN_COMMIT or TXN_ABORT

Here, I see one issues : in one case, we won't have any DATA_CONTAINER 
(specifically when doing a BIND). We won't then be able to distinguish 
between a TXN_BEGIN/DATA/TXN_COMMIT and a TXN_BEGIN/TXN_COMMIT if we 
don't have an extra information, the type.

Unless there is something that can be used to make this distinction...

Can you enlight me here, in cas I'm doing something wrong ?

Thanks !


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


Re: svn commit: r1300690 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/log/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/directory/se

Posted by Selcuk AYA <ay...@gmail.com>.
HI All,
Sorry for the earlier email. I think I owe some explaination on my
part. The reason for my request is purely technical, does not aim at
oss spirit or any other spirit for that matter:
* There are quite a number of files the txn branch is touching.
* There is no file ownership or review process.

combined with the timing limitation, it becomes hard for me to track
all changes and cleanup if necessary. When I am doing my changes and
need to change some existing stuff, I usually try to find the guy who
wrote the code and get an ack from him and this usually helps a lot
because even things that look stupid might have some reason to be
there. Please do the same while changing the txn branch.If this
process is followed, we wont have to discuss spirit hurting through
reverting code.

thanks
Selcuk

On Wed, Mar 14, 2012 at 2:48 PM, Alex Karasulu <ak...@apache.org> wrote:
>
>
> On Wed, Mar 14, 2012 at 10:41 PM, Kiran Ayyagari <ka...@apache.org>
> wrote:
>>
>> Selcuk,
>>
>>    I have seen you asking several times on this list for reverting
>> commits,
>>    this seems to be a bit derogatory in OSS spirit and team work.
>
>
> It can certainly be misinterpreted this way. I think we just need more
> communication about why one may need a revert.
>
> Revert requests are OK. There's nothing wrong with that and any committer
> can veto a change but they just need to provide reasons. I think we just
> need to help people understand this.
>
> Selcuk I'm sure meant no harm and can provide more reasoning.
>
>>
>>    Go ahead and make your changes on top of these if you wish to apply
>>    your fix, commits need not be reverted for this.
>>
>
> That's also another option but let's just communicate about whatever
> difficulties or problems a commit might introduce. If someone is having
> problems as a result of commits let's get those reasons out there on the
> list.
>
> I have a feeling the code is starting to move before some of the work can be
> finished on it and that might produce discomfort. But we're not mind readers
> so we need to communicate this.
>
>>
>> On Thu, Mar 15, 2012 at 1:39 AM, Selcuk AYA <ay...@gmail.com> wrote:
>> > please revert this commit.
>> >
>
>
> --
> Best Regards,
> -- Alex
>

Re: svn commit: r1300690 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/log/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/directory/se

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 3/14/12 10:48 PM, Alex Karasulu a écrit :
> On Wed, Mar 14, 2012 at 10:41 PM, Kiran Ayyagari<ka...@apache.org>wrote:
>
>> Selcuk,
>>
>>     I have seen you asking several times on this list for reverting commits,
>>     this seems to be a bit derogatory in OSS spirit and team work.
>>
> It can certainly be misinterpreted this way. I think we just need more
> communication about why one may need a revert.
>
> Revert requests are OK. There's nothing wrong with that and any committer
> can veto a change but they just need to provide reasons. I think we just
> need to help people understand this.
>
> Selcuk I'm sure meant no harm and can provide more reasoning.

I'm pretty sure that there are some misunderstanding or langage mismatch 
here, both of us not being english natives does not help for sure.
>
>
>>     Go ahead and make your changes on top of these if you wish to apply
>>     your fix, commits need not be reverted for this.
>>
>>
> That's also another option but let's just communicate about whatever
> difficulties or problems a commit might introduce. If someone is having
> problems as a result of commits let's get those reasons out there on the
> list.

I have no problem reverting things. Pride has no place in a community 
like ours. I just need good reasons for reverting.
>
> I have a feeling the code is starting to move before some of the work can
> be finished on it and that might produce discomfort. But we're not mind
> readers so we need to communicate this.
+1

I just have to add that communication is the key here. When I commit 
something, I do it with extreme caution, which does not protect me 
against errors. When I don't get something I ask questions. When I ask 
questions, I'm also expecting answers, and my commits are not a sign 
that I don't want to wait. Actually, my commit was not necessarely 
related to the questsions I have asked, but more related to my 
understanding of the current code. If this collide with some change 
someone is doing at the same time, how am I suppose to know it ? Simply 
by communicating about the ongoing work on the mailing list.

The key to a successful project is collaboration. I can understand that 
Selcuk needs a safe place to work without being perturbated by external 
commits that make it more difficult for him to keep going, but then, a 
branch is not the right place to work. We have sandboxes, which are 
dedicated, and by no mean I will commit in someone else sandbox.

With the branch, the idea is to keep going all together to get the txn 
layer working, with all the needed documentation and with people being 
able to fix it even if Selcuk is not around to fix things.

I hope that we can move on now. No harm. We are big boys...

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


Re: svn commit: r1300690 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/log/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/directory/se

Posted by Alex Karasulu <ak...@apache.org>.
On Wed, Mar 14, 2012 at 10:41 PM, Kiran Ayyagari <ka...@apache.org>wrote:

> Selcuk,
>
>    I have seen you asking several times on this list for reverting commits,
>    this seems to be a bit derogatory in OSS spirit and team work.
>

It can certainly be misinterpreted this way. I think we just need more
communication about why one may need a revert.

Revert requests are OK. There's nothing wrong with that and any committer
can veto a change but they just need to provide reasons. I think we just
need to help people understand this.

Selcuk I'm sure meant no harm and can provide more reasoning.


>    Go ahead and make your changes on top of these if you wish to apply
>    your fix, commits need not be reverted for this.
>
>
That's also another option but let's just communicate about whatever
difficulties or problems a commit might introduce. If someone is having
problems as a result of commits let's get those reasons out there on the
list.

I have a feeling the code is starting to move before some of the work can
be finished on it and that might produce discomfort. But we're not mind
readers so we need to communicate this.


> On Thu, Mar 15, 2012 at 1:39 AM, Selcuk AYA <ay...@gmail.com> wrote:
> > please revert this commit.
> >
>

-- 
Best Regards,
-- Alex

Re: svn commit: r1300690 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/log/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/directory/se

Posted by Kiran Ayyagari <ka...@apache.org>.
Selcuk,

    I have seen you asking several times on this list for reverting commits,
    this seems to be a bit derogatory in OSS spirit and team work.
    Go ahead and make your changes on top of these if you wish to apply
    your fix, commits need not be reverted for this.

On Thu, Mar 15, 2012 at 1:39 AM, Selcuk AYA <ay...@gmail.com> wrote:
> please revert this commit.
>
> On Wed, Mar 14, 2012 at 12:06 PM,  <el...@apache.org> wrote:
>> Author: elecharny
>> Date: Wed Mar 14 19:06:17 2012
>> New Revision: 1300690
>>
>> URL: http://svn.apache.org/viewvc?rev=1300690&view=rev
>> Log:
>> o Added a type for LogEdit stored into UserLogRecord, in order to be able to read them back from the stream knowing what is the stored data.
>> o Created an injectData() method to factorize the serialization of the LogEdit instances
>> o Removed the readObject()/writeObject() calls in the IndexChange class
>> o Added some Javadoc
>> o Minor refactoring
>>
>> Added:
>>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java
>>      - copied, changed from r1299595, directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java
>> Modified:
>>    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java
>>    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java
>>    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java
>>    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/AbstractLogEdit.java
>>    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/LogEdit.java
>>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLogFileManager.java
>>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogFlushManager.java
>>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java
>>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java
>>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java
>>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryChange.java
>>    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java Wed Mar 14 19:06:17 2012
>> @@ -86,7 +86,7 @@ public class LogAnchor implements Extern
>>
>>     public void resetLogAnchor( LogAnchor logAnchor )
>>     {
>> -        resetLogAnchor( logAnchor.getLogFileNumber(), logAnchor.getLogFileOffset(), logAnchor.getLogLSN() );
>> +        resetLogAnchor( logAnchor.logFileNumber, logAnchor.logFileOffset, logAnchor.logLSN );
>>     }
>>
>>
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java Wed Mar 14 19:06:17 2012
>> @@ -44,6 +44,18 @@ import java.io.ObjectOutput;
>>  */
>>  public class UserLogRecord implements Externalizable
>>  {
>> +    /**
>> +     * An enum used to distinguished the data type being serialized in the UserLogRecord
>> +     */
>> +    public enum LogEditType
>> +    {
>> +        TXN,
>> +        DATA;
>> +    }
>> +
>> +    /** The serialized LogEdit type */
>> +    private LogEditType dataType;
>> +
>>     /** array used to hold user log records */
>>     private byte[] recordHolder;
>>
>> @@ -101,12 +113,23 @@ public class UserLogRecord implements Ex
>>     @Override
>>     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
>>     {
>> +        // Read the DataType : TXN or DATA
>> +        int type = in.read();
>> +
>> +        dataType = LogEditType.values()[type];
>> +
>> +        // The data size
>>         length = in.readInt();
>> -        int dataSize = in.readInt();
>>
>> -        recordHolder = new byte[dataSize];
>> +        // The buffer size
>> +        int bufferSize = in.readInt();
>> +
>> +        recordHolder = new byte[bufferSize];
>> +
>> +        // The buffer
>>         in.readFully( recordHolder );
>>
>> +        // The position
>>         logAnchor = new LogAnchor();
>>         logAnchor.readExternal( in );
>>     }
>> @@ -124,13 +147,29 @@ public class UserLogRecord implements Ex
>>     @Override
>>     public void writeExternal( ObjectOutput out ) throws IOException
>>     {
>> +        // The inner data type : TXN or DATA
>> +        out.write( dataType.ordinal() );
>> +
>> +        // The size of the stored data
>>         out.writeInt( length );
>> +
>> +        // The size of the container buffer
>>         out.writeInt( recordHolder.length );
>> +
>> +        // The buffer
>>         out.write( recordHolder );
>> +
>> +        // The position
>>         logAnchor.writeExternal( out );
>>     }
>>
>>
>> +    public void setType( LogEditType dataType )
>> +    {
>> +        this.dataType = dataType;
>> +    }
>> +
>> +
>>     /**
>>      * @see Object#toString()
>>      */
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java Wed Mar 14 19:06:17 2012
>> @@ -36,7 +36,6 @@ import org.apache.directory.shared.ldap.
>>  import org.apache.directory.shared.ldap.model.name.Dn;
>>
>>
>> -
>>  /**
>>  *
>>  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
>> @@ -72,8 +71,7 @@ public interface TxnLogManager
>>      * @param entry current version of the entry the txn has
>>      * @return
>>      */
>> -    Entry mergeUpdates(Dn partitionDN, UUID entryID,  Entry entry );
>> -
>> +    Entry mergeUpdates( Dn partitionDN, UUID entryID, Entry entry );
>>
>>
>>     /**
>> @@ -131,7 +129,6 @@ public interface TxnLogManager
>>         String attributeOid, boolean forwardIndex, Object onlyValueKey, UUID onlyIDKey ) throws Exception;
>>
>>
>> -
>>     /**
>>      * Returns an index which a provides a transactionally consistent view over the given index
>>      *
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/AbstractLogEdit.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/AbstractLogEdit.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/AbstractLogEdit.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/AbstractLogEdit.java Wed Mar 14 19:06:17 2012
>> @@ -20,7 +20,13 @@
>>  package org.apache.directory.server.core.api.txn.logedit;
>>
>>
>> +import java.io.ByteArrayOutputStream;
>> +import java.io.ObjectOutputStream;
>> +
>>  import org.apache.directory.server.core.api.log.LogAnchor;
>> +import org.apache.directory.server.core.api.log.UserLogRecord;
>> +import org.slf4j.Logger;
>> +import org.slf4j.LoggerFactory;
>>
>>
>>  /**
>> @@ -29,13 +35,21 @@ import org.apache.directory.server.core.
>>  */
>>  public abstract class AbstractLogEdit implements LogEdit
>>  {
>> -    /** position in the wal */
>> +    /** A logger for this class */
>> +    private static final Logger LOG = LoggerFactory.getLogger( AbstractLogEdit.class );
>> +
>> +    /** Position in the wal */
>>     private transient LogAnchor logAnchor = new LogAnchor();
>>
>>     /** Transaction under which the change is done */
>>     protected long txnID;
>>
>>
>> +    /**
>> +     * Create a new instance of AbstractLogEdit
>> +     *
>> +     * @param txnID The transaction ID to store
>> +     */
>>     protected AbstractLogEdit( long txnID )
>>     {
>>         this.txnID = txnID;
>> @@ -70,4 +84,44 @@ public abstract class AbstractLogEdit im
>>     {
>>         txnID = id;
>>     }
>> +
>> +
>> +    /**
>> +     * {@inheritDoc}
>> +     */
>> +    public void injectData( UserLogRecord logRecord, UserLogRecord.LogEditType type ) throws Exception
>> +    {
>> +        logRecord.setType( type );
>> +        LOG.debug( "Serializing : " + this );
>> +
>> +        ObjectOutputStream out = null;
>> +        ByteArrayOutputStream bout = null;
>> +        byte[] data;
>> +
>> +        try
>> +        {
>> +            bout = new ByteArrayOutputStream();
>> +            out = new ObjectOutputStream( bout );
>> +
>> +            // The LogEdit instance
>> +            writeExternal( out );
>> +
>> +            out.flush();
>> +            data = bout.toByteArray();
>> +        }
>> +        finally
>> +        {
>> +            if ( bout != null )
>> +            {
>> +                bout.close();
>> +            }
>> +
>> +            if ( out != null )
>> +            {
>> +                out.close();
>> +            }
>> +        }
>> +
>> +        logRecord.setData( data, data.length );
>> +    }
>>  }
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/LogEdit.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/LogEdit.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/LogEdit.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/LogEdit.java Wed Mar 14 19:06:17 2012
>> @@ -19,15 +19,18 @@
>>  */
>>  package org.apache.directory.server.core.api.txn.logedit;
>>
>> -import org.apache.directory.server.core.api.log.LogAnchor;
>>
>>  import java.io.Externalizable;
>>
>> +import org.apache.directory.server.core.api.log.LogAnchor;
>> +import org.apache.directory.server.core.api.log.UserLogRecord;
>> +
>> +
>>  /**
>>  *
>>  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
>>  */
>> -public interface LogEdit extends Externalizable
>> +public interface LogEdit extends Externalizable
>>  {
>>     /**
>>      * Returns the position the edit is inserted in the wal.
>> @@ -37,11 +40,22 @@ public interface LogEdit extends Externa
>>      * @return position of the log edit in the wal
>>      */
>>     LogAnchor getLogAnchor();
>> -
>> +
>> +
>>     /**
>>      * Applies the logedit to the underlying partitions
>>      *
>>      * @param recovery true if at recovery stage
>>      */
>>     void apply( boolean recovery ) throws Exception;
>> +
>> +
>> +    /**
>> +     * Serialize the LogEdit into a UserLogRecord
>> +     *
>> +     * @param logRecord The UserLogRecord which will contain the serialized LogEdit
>> +     * @param type The type of data being written (TXN or DATA)
>> +     * @throws Exception If the serialization failed
>> +     */
>> +    void injectData( UserLogRecord logRecord, UserLogRecord.LogEditType type ) throws Exception;
>>  }
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLogFileManager.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLogFileManager.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLogFileManager.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLogFileManager.java Wed Mar 14 19:06:17 2012
>> @@ -22,16 +22,16 @@ package org.apache.directory.server.core
>>
>>  import java.io.EOFException;
>>  import java.io.File;
>> -import java.io.IOException;
>>  import java.io.FileNotFoundException;
>> -
>> +import java.io.IOException;
>>  import java.io.RandomAccessFile;
>>
>>
>>  /**
>>  * Creates and manages a LogFile on disk. The file name is the concatenation of a
>>  * path on disk, and of a suffix.<br/>
>> - * Each log file has a name like <b>logFileName/log_&lt;logFileNumber&gt;.suffix</b>
>> + * Each log file has a name like <b>logFileName/log_&lt;logFileNumber&gt;.suffix</b><br/>
>> + * This class expose a reader and a writer for the given log file.
>>  *
>>  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
>>  */
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogFlushManager.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogFlushManager.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogFlushManager.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogFlushManager.java Wed Mar 14 19:06:17 2012
>> @@ -20,31 +20,29 @@
>>  package org.apache.directory.server.core.shared.log;
>>
>>
>> +import java.io.IOException;
>>  import java.nio.ByteBuffer;
>> -
>> +import java.util.concurrent.atomic.AtomicInteger;
>> +import java.util.concurrent.locks.Condition;
>>  import java.util.concurrent.locks.Lock;
>>  import java.util.concurrent.locks.ReentrantLock;
>> -import java.util.concurrent.locks.Condition;
>> -import java.util.concurrent.atomic.AtomicInteger;
>>  import java.util.zip.Adler32;
>>  import java.util.zip.Checksum;
>>
>> +import org.apache.directory.server.core.api.log.InvalidLogException;
>>  import org.apache.directory.server.core.api.log.LogAnchor;
>>  import org.apache.directory.server.core.api.log.UserLogRecord;
>> -import org.apache.directory.server.core.api.log.InvalidLogException;
>> -
>> -import java.io.IOException;
>> -
>>  import org.apache.directory.server.core.shared.log.LogFileManager.LogFileWriter;
>>  import org.apache.directory.server.i18n.I18n;
>>
>>
>>  /**
>> - * Manages the flushing of log to media and scanning of logs. All appends to the log file go through this class.
>> + * Manages the flushing of log to media and scanning of logs. All appends to the log file go
>> + * through this class.
>>  *
>>  * Internally it manages a circular  buffer where appends initially go. Appends are first
>> - * appended to this in memory circular log. As the in memory circular log fills up or as the user requests
>> - * memory buffer is flushed to the underlying media.
>> + * appended to this in memory circular log. As the in memory circular log fills up or as the
>> + * user requests, memory buffer is flushed to the underlying media.
>>  *
>>  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
>>  */
>> @@ -92,7 +90,7 @@ import org.apache.directory.server.i18n.
>>
>>     /**
>>      * Creates a LogFlushManager instance. We define the memory buffer size, and the default maximum
>> -     * size for each Log file (this maximul size may be exceeded, if one user record is bigger than
>> +     * size for each Log file (this maximum size may be exceeded, if one user record is bigger than
>>      * this maximum size. Log file may be smaller too.
>>      *
>>      * @param logManager The associated LogManager
>> @@ -191,7 +189,7 @@ import org.apache.directory.server.i18n.
>>                             // Write the data
>>                             writeHead.put( userBuffer, 0, length );
>>
>> -                            // Write the footeer
>> +                            // Write the footer
>>                             writeFooter( writeHead, ( int ) checksum.getValue() );
>>
>>                             appendedRecord = true;
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java Wed Mar 14 19:06:17 2012
>> @@ -20,9 +20,7 @@
>>  package org.apache.directory.server.core.shared.txn;
>>
>>
>> -import java.io.ByteArrayOutputStream;
>>  import java.io.IOException;
>> -import java.io.ObjectOutputStream;
>>  import java.util.Comparator;
>>  import java.util.UUID;
>>
>> @@ -105,32 +103,7 @@ public class DefaultTxnLogManager implem
>>         ReadWriteTxn txn = ( ReadWriteTxn ) curTxn;
>>         UserLogRecord logRecord = txn.getUserLogRecord();
>>
>> -        ObjectOutputStream out = null;
>> -        ByteArrayOutputStream bout = null;
>> -        byte[] data;
>> -
>> -        try
>> -        {
>> -            bout = new ByteArrayOutputStream();
>> -            out = new ObjectOutputStream( bout );
>> -            logEdit.writeExternal( out );
>> -            out.flush();
>> -            data = bout.toByteArray();
>> -        }
>> -        finally
>> -        {
>> -            if ( bout != null )
>> -            {
>> -                bout.close();
>> -            }
>> -
>> -            if ( out != null )
>> -            {
>> -                out.close();
>> -            }
>> -        }
>> -
>> -        logRecord.setData( data, data.length );
>> +        logEdit.injectData( logRecord, UserLogRecord.LogEditType.DATA );
>>
>>         log( logRecord, sync );
>>
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java Wed Mar 14 19:06:17 2012
>> @@ -20,9 +20,7 @@
>>  package org.apache.directory.server.core.shared.txn;
>>
>>
>> -import java.io.ByteArrayOutputStream;
>>  import java.io.IOException;
>> -import java.io.ObjectOutputStream;
>>  import java.util.HashSet;
>>  import java.util.Iterator;
>>  import java.util.List;
>> @@ -43,6 +41,7 @@ import org.apache.directory.server.core.
>>  import org.apache.directory.server.core.api.txn.TxnConflictException;
>>  import org.apache.directory.server.core.api.txn.TxnHandle;
>>  import org.apache.directory.server.core.api.txn.TxnLogManager;
>> +import org.apache.directory.server.core.api.txn.logedit.LogEdit;
>>  import org.apache.directory.server.core.shared.txn.logedit.TxnStateChange;
>>
>>
>> @@ -64,7 +63,7 @@ class DefaultTxnManager implements TxnMa
>>
>>     /** Used to assign start and commit version numbers to writeTxns */
>>     private Lock writeTxnsLock = new ReentrantLock();
>> -
>> +
>>     /** Used to order txns in case of conflicts */
>>     private ReadWriteLock optimisticLock = new ReentrantReadWriteLock();
>>
>> @@ -175,6 +174,7 @@ class DefaultTxnManager implements TxnMa
>>         syncer = null;
>>     }
>>
>> +
>>     /**
>>      * {@inheritDoc}
>>      */
>> @@ -184,19 +184,19 @@ class DefaultTxnManager implements TxnMa
>>
>>         // Should have a rw txn
>>         if ( ( curTxn == null ) ||
>> -              !( curTxn instanceof ReadWriteTxn )  )
>> +            !( curTxn instanceof ReadWriteTxn ) )
>>         {
>>             // Cannot start a TXN when a RW txn is ongoing
>>             throw new IllegalStateException( "Unexpected txn state when trying txn: " +
>>                 curTxn );
>>         }
>> -
>> +
>>         // abort current txn and start a new read write txn
>> -
>> +
>>         abortTransaction();
>>         return beginReadWriteTxn( true );
>>     }
>> -
>> +
>>
>>     /**
>>      * {@inheritDoc}
>> @@ -241,7 +241,7 @@ class DefaultTxnManager implements TxnMa
>>         {
>>             throw new IOException( "Flushing of txns failed" );
>>         }
>> -
>> +
>>         prepareForEndingTxn( txn );
>>
>>         if ( txn instanceof ReadOnlyTxn )
>> @@ -265,23 +265,23 @@ class DefaultTxnManager implements TxnMa
>>     public void abortTransaction() throws Exception
>>     {
>>         Transaction txn = getCurTxn();
>> -
>> +
>>         if ( txn == null )
>>         {
>> -            throw new IllegalStateException("Trying to abort while there is not txn ");
>> +            throw new IllegalStateException( "Trying to abort while there is not txn " );
>>         }
>> -
>> +
>>         boolean isExclusive = txn.isExclusive();
>>
>>         try
>>         {
>>             prepareForEndingTxn( txn );
>> -
>> +
>>             if ( txn instanceof ReadWriteTxn )
>>             {
>>                 abortReadWriteTxn( ( ReadWriteTxn ) txn );
>>             }
>> -
>> +
>>             txn.abortTxn();
>>             setCurTxn( null );
>>         }
>> @@ -420,7 +420,7 @@ class DefaultTxnManager implements TxnMa
>>
>>         buildCheckList( txn, lastTxnToCheck );
>>
>> -        optimisticLock.readLock().lock();
>> +        optimisticLock.readLock().lock();
>>         setCurTxn( txn );
>>
>>         //System.out.println( "TRAN: Started " + txn );
>> @@ -440,35 +440,11 @@ class DefaultTxnManager implements TxnMa
>>         ReadWriteTxn txn = new ReadWriteTxn();
>>         UserLogRecord logRecord = txn.getUserLogRecord();
>>
>> -        TxnStateChange txnRecord = new TxnStateChange( LogAnchor.UNKNOWN_LSN,
>> +        LogEdit logEdit = new TxnStateChange( LogAnchor.UNKNOWN_LSN,
>>             TxnStateChange.ChangeState.TXN_BEGIN );
>> -        ObjectOutputStream out = null;
>> -        ByteArrayOutputStream bout = null;
>> -        byte[] data;
>>
>> -        try
>> -        {
>> -            bout = new ByteArrayOutputStream();
>> -            out = new ObjectOutputStream( bout );
>> -            txnRecord.writeExternal( out );
>> -            out.flush();
>> -            data = bout.toByteArray();
>> -        }
>> -        finally
>> -        {
>> -            if ( bout != null )
>> -            {
>> -                bout.close();
>> -            }
>> +        logEdit.injectData( logRecord, UserLogRecord.LogEditType.TXN );
>>
>> -            if ( out != null )
>> -            {
>> -                out.close();
>> -            }
>> -        }
>> -
>> -        logRecord.setData( data, data.length );
>> -
>>         if ( retry == false )
>>         {
>>             optimisticLock.readLock().lock();
>> @@ -506,7 +482,7 @@ class DefaultTxnManager implements TxnMa
>>             }
>>             while ( lastTxnToCheck != latestVerifiedTxn.get() );
>>         }
>> -        catch( Exception e )
>> +        catch ( Exception e )
>>         {
>>             if ( txn.isExclusive() == false )
>>             {
>> @@ -657,34 +633,10 @@ class DefaultTxnManager implements TxnMa
>>     {
>>         UserLogRecord logRecord = txn.getUserLogRecord();
>>
>> -        TxnStateChange txnRecord = new TxnStateChange( txn.getStartTime(),
>> +        LogEdit logEdit = new TxnStateChange( txn.getStartTime(),
>>             TxnStateChange.ChangeState.TXN_COMMIT );
>> -        ObjectOutputStream out = null;
>> -        ByteArrayOutputStream bout = null;
>> -        byte[] data;
>>
>> -        try
>> -        {
>> -            bout = new ByteArrayOutputStream();
>> -            out = new ObjectOutputStream( bout );
>> -            txnRecord.writeExternal( out );
>> -            out.flush();
>> -            data = bout.toByteArray();
>> -        }
>> -        finally
>> -        {
>> -            if ( bout != null )
>> -            {
>> -                bout.close();
>> -            }
>> -
>> -            if ( out != null )
>> -            {
>> -                out.close();
>> -            }
>> -        }
>> -
>> -        logRecord.setData( data, data.length );
>> +        logEdit.injectData( logRecord, UserLogRecord.LogEditType.TXN );
>>
>>         verifyLock.lock();
>>
>> @@ -738,34 +690,11 @@ class DefaultTxnManager implements TxnMa
>>     {
>>         UserLogRecord logRecord = txn.getUserLogRecord();
>>
>> -        TxnStateChange txnRecord = new TxnStateChange( txn.getStartTime(),
>> +        LogEdit logEdit = new TxnStateChange( txn.getStartTime(),
>>             TxnStateChange.ChangeState.TXN_ABORT );
>> -        ObjectOutputStream out = null;
>> -        ByteArrayOutputStream bout = null;
>> -        byte[] data;
>>
>> -        try
>> -        {
>> -            bout = new ByteArrayOutputStream();
>> -            out = new ObjectOutputStream( bout );
>> -            out.writeObject( txnRecord );
>> -            out.flush();
>> -            data = bout.toByteArray();
>> -        }
>> -        finally
>> -        {
>> -            if ( bout != null )
>> -            {
>> -                bout.close();
>> -            }
>> -
>> -            if ( out != null )
>> -            {
>> -                out.close();
>> -            }
>> -        }
>> +        logEdit.injectData( logRecord, UserLogRecord.LogEditType.TXN );
>>
>> -        logRecord.setData( data, data.length );
>>         txnLogManager.log( logRecord, false );
>>     }
>>
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java Wed Mar 14 19:06:17 2012
>> @@ -72,6 +72,7 @@ public class DataChangeContainer extends
>>     public DataChangeContainer( Partition partition )
>>     {
>>         super( Long.MIN_VALUE );
>> +
>>         this.partitionDn = partition.getSuffixDn();
>>         this.partition = partition;
>>     }
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryChange.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryChange.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryChange.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryChange.java Wed Mar 14 19:06:17 2012
>> @@ -92,7 +92,7 @@ public class EntryChange implements Entr
>>             }
>>         }
>>
>> -        // TODO in reovery mode, check the version of the entry.
>> +        // TODO in recovery mode, check the version of the entry.
>>         try
>>         {
>>             AttributeUtils.applyModification( curEntry, redoChange );
>>
>> Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java?rev=1300690&r1=1300689&r2=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java Wed Mar 14 19:06:17 2012
>> @@ -62,6 +62,15 @@ public class IndexChange implements Inde
>>     }
>>
>>
>> +    /**
>> +     * Create a new IndexChange instance.
>> +     *
>> +     * @param index The changed index
>> +     * @param key The index' key
>> +     * @param id The entry's UUID
>> +     * @param type The change type, Add or Delete
>> +     * @param isSystemIndex Tells f the index is a system index or a user index
>> +     */
>>     public IndexChange( Index<?> index, Object key, UUID id, Type type, boolean isSystemIndex )
>>     {
>>         this.index = index;
>> @@ -155,7 +164,29 @@ public class IndexChange implements Inde
>>     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
>>     {
>>         oid = in.readUTF();
>> -        key = in.readObject();
>> +        KeyType keyType = KeyType.getType( in.readByte() );
>> +
>> +        switch ( keyType )
>> +        {
>> +            case STRING:
>> +                key = in.readUTF();
>> +                break;
>> +
>> +            case LONG:
>> +                key = in.readLong();
>> +                break;
>> +
>> +            case BYTES:
>> +                int length = in.readInt();
>> +                key = new byte[length];
>> +                in.read( ( byte[] ) key );
>> +                break;
>> +
>> +            case OBJECT:
>> +                key = in.readObject();
>> +                break;
>> +        }
>> +
>>         id = UUID.fromString( in.readUTF() );
>>         type = Type.values()[in.readInt()];
>>     }
>> @@ -165,7 +196,29 @@ public class IndexChange implements Inde
>>     public void writeExternal( ObjectOutput out ) throws IOException
>>     {
>>         out.writeUTF( oid );
>> -        out.writeObject( key );
>> +
>> +        if ( key instanceof String )
>> +        {
>> +            out.write( KeyType.STRING.getOrdinal() );
>> +            out.writeUTF( ( String ) key );
>> +        }
>> +        else if ( key instanceof byte[] )
>> +        {
>> +            out.write( KeyType.BYTES.getOrdinal() );
>> +            out.writeInt( ( ( byte[] ) key ).length );
>> +            out.write( ( byte[] ) key );
>> +        }
>> +        else if ( key instanceof Long )
>> +        {
>> +            out.write( KeyType.LONG.getOrdinal() );
>> +            out.writeLong( ( Long ) key );
>> +        }
>> +        else
>> +        {
>> +            out.write( KeyType.OBJECT.getOrdinal() );
>> +            out.writeObject( key );
>> +        }
>> +
>>         out.writeUTF( id.toString() );
>>         out.writeInt( type.ordinal() );
>>     }
>> @@ -185,6 +238,7 @@ public class IndexChange implements Inde
>>         StringBuilder sb = new StringBuilder();
>>
>>         sb.append( "IndexChange '" );
>> +
>>         // The index's name
>>         sb.append( index.getAttributeId() ).append( "': " );
>>
>> @@ -201,4 +255,42 @@ public class IndexChange implements Inde
>>
>>         return sb.toString();
>>     }
>> +
>> +    private enum KeyType
>> +    {
>> +        STRING(0),
>> +        LONG(1),
>> +        BYTES(2),
>> +        OBJECT(3);
>> +
>> +        private int value;
>> +
>> +
>> +        private KeyType( int value )
>> +        {
>> +            this.value = value;
>> +        }
>> +
>> +
>> +        private byte getOrdinal()
>> +        {
>> +            return ( byte ) value;
>> +        }
>> +
>> +
>> +        private static KeyType getType( byte value )
>> +        {
>> +            switch ( value )
>> +            {
>> +                case 0:
>> +                    return STRING;
>> +                case 1:
>> +                    return LONG;
>> +                case 2:
>> +                    return BYTES;
>> +                default:
>> +                    return OBJECT;
>> +            }
>> +        }
>> +    }
>>  }
>>
>> Copied: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java (from r1299595, directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java)
>> URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java?p2=directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java&p1=directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java&r1=1299595&r2=1300690&rev=1300690&view=diff
>> ==============================================================================
>> --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java (original)
>> +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/TxnStateChange.java Wed Mar 14 19:06:17 2012
>> @@ -28,31 +28,60 @@ import org.apache.directory.server.core.
>>
>>
>>  /**
>> + * A class used to store a transaction changeState (either BEGIN, COMMIT or ABORT).
>>  *
>>  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
>>  */
>>  public class TxnStateChange extends AbstractLogEdit
>>  {
>> +    /** SerialVrsionUID as requested for serializable classes */
>> +    private static final long serialVersionUID = 1;
>> +
>> +    /**
>> +     * Change State, one of :
>> +     * <ul>
>> +     * <li>TXN_BEGIN : for a starting transaction</li>
>> +     * <li>TXN_COMMIT :  for a validated transaction</li>
>> +     * <li>TXN_ABORT : for an aborted transaction</li>
>> +     * </ul>
>> +     */
>> +    public enum ChangeState
>> +    {
>> +        TXN_BEGIN,
>> +        TXN_COMMIT,
>> +        TXN_ABORT
>> +    }
>> +
>>     /** State to record for the txn */
>>     ChangeState txnState;
>>
>> -    private static final long serialVersionUID = 1;
>> -
>>
>> -    // For deserialization
>> +    /**
>> +     * A default constructor used by deserialization
>> +     */
>>     public TxnStateChange()
>>     {
>>         super( Long.MIN_VALUE );
>>     }
>>
>>
>> +    /**
>> +     * Creates a new TxnStateChange instance, with a transaction ID and a ChangeState.
>> +     *
>> +     * @param txnID The transaction ID
>> +     * @param txnState The ChangeState
>> +     */
>>     public TxnStateChange( long txnID, ChangeState txnState )
>>     {
>>         super( txnID );
>> +
>>         this.txnState = txnState;
>>     }
>>
>>
>> +    /**
>> +     * @return The ChangeState for this transaction
>> +     */
>>     public ChangeState getTxnState()
>>     {
>>         return txnState;
>> @@ -74,10 +103,12 @@ public class TxnStateChange extends Abst
>>         out.writeInt( txnState.ordinal() );
>>     }
>>
>> -    public enum ChangeState
>> +
>> +    /**
>> +     * @see Object#toString()
>> +     */
>> +    public String toString()
>>     {
>> -        TXN_BEGIN,
>> -        TXN_COMMIT,
>> -        TXN_ABORT
>> +        return "TxnStateChange[" + txnID + "/" + txnState + "]";
>>     }
>>  }
>>
>>



-- 
Kiran Ayyagari