You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by sa...@apache.org on 2011/10/18 15:11:43 UTC
svn commit: r1185638 [2/2] - in /directory/apacheds/branches/apacheds-txns:
core-api/src/main/java/org/apache/directory/server/core/partition/index/
core-api/src/main/java/org/apache/directory/server/core/txn/
core-api/src/main/java/org/apache/director...
Added: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/EntryAddDelete.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/EntryAddDelete.java?rev=1185638&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/EntryAddDelete.java (added)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/EntryAddDelete.java Tue Oct 18 13:11:42 2011
@@ -0,0 +1,64 @@
+
+package org.apache.directory.server.core.txn.logedit;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.apache.directory.shared.ldap.model.entry.DefaultModification;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
+
+public class EntryAddDelete<ID> extends AbstractDataChange<ID>
+{
+ /** Added or deleted entry */
+ private Entry entry;
+
+ /** Type of change */
+ Type type;
+
+ // For externalizable
+ public EntryAddDelete( )
+ {
+
+ }
+
+ public EntryAddDelete( Entry entry, Type type )
+ {
+ this.entry = entry;
+ this.type = type;
+ }
+
+ public Entry getChangedEntry()
+ {
+ return entry;
+ }
+
+ public Type getType()
+ {
+ return type;
+ }
+
+ @Override
+ public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+ {
+ entry = new DefaultEntry();
+ entry.readExternal( in );
+ type = Type.values()[in.readInt()];
+ }
+
+
+ @Override
+ public void writeExternal( ObjectOutput out ) throws IOException
+ {
+ entry.writeExternal( out );
+ out.writeInt( type.ordinal() );
+ }
+
+ public enum Type
+ {
+ ADD,
+ DELETE
+ }
+
+}
Added: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/EntryChange.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/EntryChange.java?rev=1185638&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/EntryChange.java (added)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/EntryChange.java Tue Oct 18 13:11:42 2011
@@ -0,0 +1,62 @@
+
+package org.apache.directory.server.core.txn.logedit;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.apache.directory.shared.ldap.model.entry.Modification;
+import org.apache.directory.shared.ldap.model.entry.DefaultModification;
+
+public class EntryChange<ID> extends AbstractDataChange<ID>
+{
+ /** redo change */
+ private Modification redoChange;
+
+ /** undo change */
+ private Modification undoChange;
+
+ //For externalizable
+ public EntryChange()
+ {
+
+ }
+
+ public EntryChange( Modification redo, Modification undo )
+ {
+ redoChange = redo;
+ undoChange = undo;
+ }
+
+ public Modification getRedoChange()
+ {
+ return redoChange;
+ }
+
+ public Modification getUndoChange()
+ {
+ return undoChange;
+ }
+
+ @Override
+ public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+ {
+ redoChange = new DefaultModification();
+
+ redoChange.readExternal( in );
+
+ undoChange = new DefaultModification();
+
+ undoChange.readExternal( in );
+
+ }
+
+
+ @Override
+ public void writeExternal( ObjectOutput out ) throws IOException
+ {
+ redoChange.writeExternal( out );
+ undoChange.writeExternal( out );
+ }
+
+}
Added: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/IndexChange.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/IndexChange.java?rev=1185638&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/IndexChange.java (added)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/IndexChange.java Tue Oct 18 13:11:42 2011
@@ -0,0 +1,115 @@
+
+package org.apache.directory.server.core.txn.logedit;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.apache.directory.server.core.partition.index.Index;
+import org.apache.directory.server.core.partition.index.Serializer;
+import org.apache.directory.server.core.txn.TxnManagerFactory;
+
+import org.apache.directory.shared.ldap.model.entry.Value;
+
+public class IndexChange<ID> extends AbstractDataChange<ID>
+{
+ /** Index this change is done on */
+ private transient Index<?, ?, ID> index;
+
+ /** oid of the attribute the index is on */
+ private String oid;
+
+ /** key of the forward index */
+ private Value<?> key;
+
+ /** if for the index */
+ private ID id;
+
+ /** Change type */
+ Type type;
+
+ // For externalizable
+ public IndexChange()
+ {
+
+ }
+
+ public IndexChange( Index<?, ?, ID> index, String oid, Value<?> key, ID id, Type type )
+ {
+ this.index = index;
+ this.oid = oid;
+ this.key = key;
+ this.id = id;
+ this.type = type;
+ }
+
+
+ public String getOID()
+ {
+ return this.oid;
+ }
+
+ public Index<?, ?, ID> getIndex()
+ {
+ return index;
+ }
+
+
+ public Value<?> getKey()
+ {
+ return key;
+ }
+
+ public ID getID()
+ {
+ return id;
+ }
+
+ public Type getType()
+ {
+ return type;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+ {
+ Serializer idSerializer = TxnManagerFactory.txnManagerInstance().getIDSerializer();
+
+ oid = in.readUTF();
+ key = (Value<?>) in.readObject();
+
+ int len = in.readInt();
+ byte[] buf = new byte[len];
+ in.readFully( buf );
+ id = (ID)idSerializer.deserialize( buf );
+
+ type = Type.values()[in.readInt()];
+ }
+
+
+ @Override
+ public void writeExternal( ObjectOutput out ) throws IOException
+ {
+ Serializer idSerializer = TxnManagerFactory.txnManagerInstance().getIDSerializer();
+
+ out.writeUTF( oid );
+ out.writeObject( key );
+
+ byte[] buf = idSerializer.serialize( id );
+ out.writeInt( buf.length );
+ out.write( buf );
+
+ out.writeInt( type.ordinal() );
+ }
+
+
+
+ public enum Type
+ {
+ ADD,
+ DELETE
+ }
+
+
+}
Added: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/TxnStateChange.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/TxnStateChange.java?rev=1185638&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/TxnStateChange.java (added)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/txn/logedit/TxnStateChange.java Tue Oct 18 13:11:42 2011
@@ -0,0 +1,62 @@
+
+package org.apache.directory.server.core.txn.logedit;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+public class TxnStateChange<ID> extends AbstractLogEdit<ID>
+{
+ /** ID of the txn associated with this change */
+ long txnID;
+
+ /** State to record for the txn */
+ State txnState;
+
+ private static final long serialVersionUID = 1;
+
+ // For deserialization
+ public TxnStateChange()
+ {
+
+ }
+
+ public TxnStateChange( long txnID, State txnState )
+ {
+ this.txnID = txnID;
+ this.txnState = txnState;
+ }
+
+ public long getTxnID()
+ {
+ return this.txnID;
+ }
+
+ public State getTxnState()
+ {
+ return this.txnState;
+ }
+
+ @Override
+ public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+ {
+ txnID = in.readLong();
+ txnState = State.values()[in.readInt()];
+ }
+
+
+ @Override
+ public void writeExternal( ObjectOutput out ) throws IOException
+ {
+ out.writeLong( txnID );
+ out.writeInt( txnState.ordinal() );
+ }
+
+ public enum State
+ {
+ TXN_BEGIN,
+ TXN_COMMIT,
+ TXN_ABORT
+ }
+
+}
Modified: directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogFlushScanTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogFlushScanTest.java?rev=1185638&r1=1185637&r2=1185638&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogFlushScanTest.java (original)
+++ directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogFlushScanTest.java Tue Oct 18 13:11:42 2011
@@ -352,5 +352,6 @@ public class LogFlushScanTest
assertTrue( failed == false );
}
}
-
+
+
}
Modified: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=1185638&r1=1185637&r2=1185638&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original)
+++ directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Tue Oct 18 13:11:42 2011
@@ -33,8 +33,10 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.partition.impl.btree.LongComparator;
import org.apache.directory.server.i18n.I18n;
import org.apache.directory.server.core.partition.index.AbstractIndex;
+import org.apache.directory.server.core.partition.index.ForwardIndexComparator;
import org.apache.directory.server.core.partition.index.Index;
import org.apache.directory.server.core.partition.index.IndexCursor;
+import org.apache.directory.server.core.partition.index.ReverseIndexComparator;
import org.apache.directory.shared.ldap.model.cursor.Cursor;
import org.apache.directory.shared.ldap.model.cursor.Tuple;
import org.apache.directory.shared.ldap.model.entry.BinaryValue;
@@ -101,6 +103,12 @@ public class JdbmIndex<K, O> extends Abs
/** a custom working directory path when specified in configuration */
protected File wkDirPath;
+
+ /** Forward index entry comparator */
+ protected ForwardIndexComparator<K,Long> fIndexEntryComparator;
+
+ /** Reverse index entry comparator */
+ protected ReverseIndexComparator<K,Long> rIndexEntryComparator;
/*
@@ -245,6 +253,9 @@ public class JdbmIndex<K, O> extends Abs
reverse = new JdbmTable<Long, K>( schemaManager, attributeType.getOid() + REVERSE_BTREE, numDupLimit, recMan,
LongComparator.INSTANCE, comp, LongSerializer.INSTANCE, null );
}
+
+ fIndexEntryComparator = new ForwardIndexComparator( comp, LongComparator.INSTANCE );
+ rIndexEntryComparator = new ReverseIndexComparator( comp, LongComparator.INSTANCE );
}
@@ -644,6 +655,15 @@ public class JdbmIndex<K, O> extends Abs
return reverse.isDupsEnabled();
}
+ public ForwardIndexComparator<K,Long> getForwardIndexEntryComparator()
+ {
+ return this.fIndexEntryComparator;
+ }
+
+ public ReverseIndexComparator<K,Long> getReverseIndexEntryComparator()
+ {
+ return this.rIndexEntryComparator;
+ }
/**
* @see Object#toString()
Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java?rev=1185638&r1=1185637&r2=1185638&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java (original)
+++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java Tue Oct 18 13:11:42 2011
@@ -27,6 +27,9 @@ import org.apache.directory.server.core.
import org.apache.directory.server.i18n.I18n;
import org.apache.directory.server.core.partition.index.AbstractIndex;
import org.apache.directory.server.core.partition.index.IndexCursor;
+import org.apache.directory.server.core.partition.index.ForwardIndexComparator;
+import org.apache.directory.server.core.partition.index.ReverseIndexComparator;
+import org.apache.directory.server.core.partition.index.Table;
import org.apache.directory.shared.ldap.model.cursor.Cursor;
import org.apache.directory.shared.ldap.model.cursor.Tuple;
import org.apache.directory.shared.ldap.model.entry.BinaryValue;
@@ -46,7 +49,14 @@ public class AvlIndex<K, O> extends Abst
{
protected Normalizer normalizer;
protected AvlTable<K, Long> forward;
- protected AvlTable<Long, K> reverse;
+ protected AvlTable<Long, K> reverse;
+
+ /** Forward index entry comparator */
+ protected ForwardIndexComparator<K,Long> fIndexEntryComparator;
+
+ /** Reverse index entry comparator */
+ protected ReverseIndexComparator<K,Long> rIndexEntryComparator;
+
public AvlIndex()
@@ -107,6 +117,9 @@ public class AvlIndex<K, O> extends Abst
{
reverse = new AvlTable<Long, K>( attributeType.getName(), LongComparator.INSTANCE, comp, true );
}
+
+ fIndexEntryComparator = new ForwardIndexComparator( comp, LongComparator.INSTANCE );
+ rIndexEntryComparator = new ReverseIndexComparator( comp, LongComparator.INSTANCE );
}
@@ -429,7 +442,16 @@ public class AvlIndex<K, O> extends Abst
return reverse.isDupsEnabled();
}
+ public ForwardIndexComparator<K,Long> getForwardIndexEntryComparator()
+ {
+ return this.fIndexEntryComparator;
+ }
+ public ReverseIndexComparator<K,Long> getReverseIndexEntryComparator()
+ {
+ return this.rIndexEntryComparator;
+ }
+
/**
* {@inheritDoc}
*/