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/11/30 11:04:46 UTC
svn commit: r1208357 - in /directory/apacheds/branches/apacheds-txns:
core-annotations/src/main/java/org/apache/directory/server/core/factory/
core-api/src/main/java/org/apache/directory/server/core/api/
core-api/src/main/java/org/apache/directory/serv...
Author: saya
Date: Wed Nov 30 10:04:45 2011
New Revision: 1208357
URL: http://svn.apache.org/viewvc?rev=1208357&view=rev
Log:
Mostly interface changes.
TODO: schema partition updates its registries and in memory partition during logical operations. This is the reason I couldnt remove interfaces related to modification from the partition interface. It should be possible to do these updates in schema interceptor.
Modified:
directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/InstanceLayout.java
directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/AbstractPartition.java
directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/OperationExecutionManager.java
directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java
directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/index/Index.java
directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.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/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Modified: directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java?rev=1208357&r1=1208356&r2=1208357&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java Wed Nov 30 10:04:45 2011
@@ -31,6 +31,8 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.api.partition.Partition;
import org.apache.directory.server.core.api.schema.SchemaPartition;
import org.apache.directory.server.core.partition.ldif.LdifPartition;
+import org.apache.directory.server.core.shared.partition.OperationExecutionManagerFactory;
+import org.apache.directory.server.core.shared.txn.TxnManagerFactory;
import org.apache.directory.server.i18n.I18n;
import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
@@ -59,6 +61,12 @@ public class DefaultDirectoryServiceFact
/** The partition factory. */
private PartitionFactory partitionFactory;
+
+ /** Default txn log file size */
+ private final static long TXN_LOG_FILE_SIZE = 1 << 27;
+
+ /** Default txn log buffer size */
+ private final static int TXN_LOG_BUFFER_SIZE = 1 << 22;
public DefaultDirectoryServiceFactory()
@@ -224,6 +232,10 @@ public class DefaultDirectoryServiceFact
directoryService.setInstanceId( name );
buildInstanceDirectory( name );
+ // Initialize the txn subsystem and the operation execution manager
+ TxnManagerFactory.init( directoryService.getInstanceLayout().getTxnLogDirectory().getPath(), TXN_LOG_BUFFER_SIZE, TXN_LOG_FILE_SIZE );
+ OperationExecutionManagerFactory.init();
+
// Init the service now
initSchema();
initSystemPartition();
Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/InstanceLayout.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/InstanceLayout.java?rev=1208357&r1=1208356&r2=1208357&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/InstanceLayout.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/InstanceLayout.java Wed Nov 30 10:04:45 2011
@@ -78,6 +78,7 @@ public class InstanceLayout extends Abst
/** Static directory names */
private static final String LOG_NAME = "log";
+ private static final String TXN_LOG_NAME = "txnlog";
private static final String RUN_NAME = "run";
private static final String CONF_NAME = "conf";
private static final String PARTITIONS_NAME = "partitions";
@@ -89,6 +90,9 @@ public class InstanceLayout extends Abst
/** The Log directory */
private File logDir;
+
+ /** The Txn Log directory */
+ private File txnLogDir;
/** The Partitions directory */
private File partitionsDir;
@@ -135,6 +139,7 @@ public class InstanceLayout extends Abst
getInstanceDirectory(),
getConfDirectory(),
getLogDirectory(),
+ getTxnLogDirectory(),
getPartitionsDirectory(),
getRunDirectory()
};
@@ -199,6 +204,22 @@ public class InstanceLayout extends Abst
return logDir;
}
+
+
+ /**
+ * Gets the 'txn log' directory.
+ *
+ * @return the 'txn log' directory
+ */
+ public File getTxnLogDirectory()
+ {
+ if ( txnLogDir == null )
+ {
+ txnLogDir = new File( getInstanceDirectory(), TXN_LOG_NAME );
+ }
+
+ return txnLogDir;
+ }
/**
Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/AbstractPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/AbstractPartition.java?rev=1208357&r1=1208356&r2=1208357&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/AbstractPartition.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/AbstractPartition.java Wed Nov 30 10:04:45 2011
@@ -345,6 +345,14 @@ public abstract class AbstractPartition
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean updateEntryOnDnChange()
+ {
+ return false;
+ }
+
/**
* Check that the operation is done on an initialized store
@@ -357,4 +365,5 @@ public abstract class AbstractPartition
throw new IllegalStateException( I18n.err( I18n.ERR_576, property ) );
}
}
+
}
Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/OperationExecutionManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/OperationExecutionManager.java?rev=1208357&r1=1208356&r2=1208357&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/OperationExecutionManager.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/OperationExecutionManager.java Wed Nov 30 10:04:45 2011
@@ -27,8 +27,12 @@ import java.util.UUID;
import org.apache.directory.server.constants.ApacheSchemaConstants;
import org.apache.directory.server.core.api.entry.ClonedServerEntry;
+import org.apache.directory.server.core.api.entry.ServerSearchResult;
+import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.ListOperationContext;
import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext;
import org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext;
import org.apache.directory.server.core.api.interceptor.context.MoveAndRenameOperationContext;
@@ -253,6 +257,35 @@ public interface OperationExecutionManag
Entry lookup( Partition partition, UUID id ) throws LdapException;
+ /**
+ * Looksups the entry identified in entryContext.
+ *
+ * @param partition partition lookup will be done
+ * @param entryContext operation parameters
+ * @return true if the entry can be found
+ * @throws LdapException
+ */
+ boolean hasEntry( Partition partition, HasEntryOperationContext entryContext ) throws LdapException;
+
+
+
+ /**
+ * A specialized form of one level search used to return a minimal set of
+ * information regarding child entries under a base. Convenience method
+ * used to optimize operations rather than conducting a full search with
+ * retrieval.
+ *
+ * @param partition partition lookup will be done
+ * @param listContext the context containing the distinguished/absolute name for the search/listing
+ * @return a NamingEnumeration containing objects of type {@link ServerSearchResult}
+ * @throws Exception if there are any problems
+ */
+ EntryFilteringCursor list( Partition partition, ListOperationContext listContext ) throws LdapException;
+
+
+ IndexCursor<UUID> list( Partition partition, UUID id ) throws LdapException;
+
+
/**
* Returns the entry id for the given dn
*
@@ -261,6 +294,39 @@ public interface OperationExecutionManag
* @return entry id
* @throws LdapException
*/
- public UUID getEntryId( Partition partition, Dn dn ) throws LdapException;
+ UUID getEntryId( Partition partition, Dn dn ) throws LdapException;
+
+
+ /**
+ * builds the Dn of the entry identified by the given id
+ *
+ * @param partition partition entry lives in
+ * @param id the entry's id
+ * @return the normalized Dn of the entry
+ * @throws Exception
+ */
+ Dn buildEntryDn( Partition partition, UUID id ) throws Exception;
+
+
+ /**
+ * Gets the parent id of the given child id.
+ *
+ * @param partition partition childId lives in.
+ * @param childId id of the entry for which we want to get the parent id.
+ * @return parent id
+ * @throws Exception
+ */
+ public UUID getParentId( Partition partition, UUID childId ) throws Exception;
+
+
+ /**
+ * Returns the child count of the corresponding to the id
+ *
+ * @param partition partition entry lives in
+ * @param id id of the entry
+ * @return child count of the entry
+ * @throws LdapOperationErrorException
+ */
+ public int getChildCount( Partition partition, UUID id ) throws LdapOperationErrorException;
}
Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java?rev=1208357&r1=1208356&r2=1208357&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java Wed Nov 30 10:04:45 2011
@@ -429,6 +429,17 @@ public interface Partition
/**
+ * Normally Dn change of an entry is not recorded in the entry and such
+ * changes do not result in an update of the entry in the partition. However
+ * some partitions might want the Dn change of the entry to be recorded and
+ * the entry to be updated on such a change.
+ *
+ * @return true if a partition wants the entries to be updated on Dn change.
+ */
+ boolean updateEntryOnDnChange();
+
+
+ /**
* Dump the requested index to a given stream
* @param name The index to dump to stdout
* @throws IOException if we can't write the data
Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/index/Index.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/index/Index.java?rev=1208357&r1=1208356&r2=1208357&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/index/Index.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/index/Index.java Wed Nov 30 10:04:45 2011
@@ -257,9 +257,11 @@ public interface Index<K>
boolean reverseLessOrEq( UUID id, K attrVal ) throws Exception;
- public ForwardIndexComparator<K> getForwardIndexEntryComparator();
+
+ ForwardIndexComparator<K> getForwardIndexEntryComparator();
- public ReverseIndexComparator<K> getReverseIndexEntryComparator();
+
+ ReverseIndexComparator<K> getReverseIndexEntryComparator();
void close() throws Exception;
Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java?rev=1208357&r1=1208356&r2=1208357&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java Wed Nov 30 10:04:45 2011
@@ -260,19 +260,6 @@ public final class SchemaPartition exten
// but only if it does not break the server.
synchronizer.add( addContext );
- // Now, write the newly added SchemaObject into the schemaPartition
- try
- {
- wrapped.add( addContext );
- }
- catch ( LdapException e )
- {
- // If something went wrong, we have to unregister the schemaObject
- // from the registries
- // TODO : deregister the newly added element.
- throw e;
- }
-
updateSchemaModificationAttributes( addContext );
}
@@ -296,16 +283,6 @@ public final class SchemaPartition exten
// The SchemaObject always exist when we reach this method.
synchronizer.delete( deleteContext, cascade );
- try
- {
- wrapped.delete( deleteContext );
- }
- catch ( LdapException e )
- {
- // TODO : If something went wrong, what should we do here ?
- throw e;
- }
-
updateSchemaModificationAttributes( deleteContext );
}
@@ -346,12 +323,7 @@ public final class SchemaPartition exten
boolean cascade = modifyContext.hasRequestControl( Cascade.OID );
- boolean hasModification = synchronizer.modify( modifyContext, targetEntry, cascade );
-
- if ( hasModification )
- {
- wrapped.modify( modifyContext );
- }
+ synchronizer.modify( modifyContext, targetEntry, cascade );
if ( !modifyContext.getDn().equals( SCHEMA_MODIFICATION_DN ) )
{
@@ -371,7 +343,6 @@ public final class SchemaPartition exten
LookupOperationContext lookupContext = new LookupOperationContext( session, moveContext.getDn(), SchemaConstants.ALL_ATTRIBUTES_ARRAY );
Entry entry = session.getDirectoryService().getPartitionNexus().lookup( lookupContext );
synchronizer.move( moveContext, entry, cascade );
- wrapped.move( moveContext );
updateSchemaModificationAttributes( moveContext );
}
@@ -386,7 +357,6 @@ public final class SchemaPartition exten
LookupOperationContext lookupContext = new LookupOperationContext( session, moveAndRenameContext.getDn(), SchemaConstants.ALL_ATTRIBUTES_ARRAY );
Entry entry = session.getDirectoryService().getPartitionNexus().lookup( lookupContext );
synchronizer.moveAndRename( moveAndRenameContext, entry, cascade );
- wrapped.moveAndRename( moveAndRenameContext );
updateSchemaModificationAttributes( moveAndRenameContext );
}
@@ -401,9 +371,6 @@ public final class SchemaPartition exten
// First update the registries
synchronizer.rename( renameContext, cascade );
- // Update the schema partition
- wrapped.rename( renameContext );
-
// Update the SSSE operational attributes
updateSchemaModificationAttributes( renameContext );
}
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=1208357&r1=1208356&r2=1208357&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 Nov 30 10:04:45 2011
@@ -22,6 +22,7 @@ package org.apache.directory.server.core
import org.apache.directory.server.core.api.partition.index.Index;
import org.apache.directory.server.core.api.partition.index.IndexCursor;
import org.apache.directory.server.core.api.partition.index.IndexComparator;
+import org.apache.directory.server.core.api.partition.index.IndexEntry;
import org.apache.directory.server.core.api.partition.index.MasterTable;
import org.apache.directory.server.core.api.txn.logedit.LogEdit;
@@ -32,6 +33,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.message.SearchScope;
import java.io.IOException;
+import java.util.Comparator;
import java.util.UUID;
/**
@@ -71,6 +73,44 @@ public interface TxnLogManager
*/
Entry mergeUpdates(Dn partitionDN, UUID entryID, Entry entry );
+
+ /**
+ * Checks all the updates done on the given index for the given key and returns
+ * the latest version of the coressponding id
+ *
+ * @param partitionDN dn of the partition the entry lives in
+ * @param attributeOid oid of the indexed attribute
+ * @param key key to do the lookup on
+ * @param valueComp value comparator
+ * @return id corresponding to the key
+ */
+ UUID mergeForwardLookup(Dn partitionDN, String attributeOid, Object key, UUID curId, Comparator<Object> valueComparator );
+
+
+ /**
+ * Checks all the updates done on the given index for the given id and returns
+ * the latest version of the corressponding value
+ *
+ * @param partitionDN dn of the partition the entry lives in
+ * @param attributeOid oid of the indexed attribute
+ * @param id key to do the lookup on
+ * @return value corresponding to the id
+ */
+ Object mergeReversLookup(Dn partitionDN, String attributeOid, UUID id, Object curValue );
+
+
+ /**
+ * Checks all the updates on the given index entry and returns whether the it exists or not
+ *
+ * @param partitionDN dn of the partition the entry lives in
+ * @param attributeOid oid of the indexed attribute
+ * @param indexEntry entry to do the check for
+ * @param currentlyExists true if the index entry currently exists in the underlying partition
+ * @return true if the given index entry exists
+ */
+ boolean mergeExistence(Dn partitionDN, String attributeOid, IndexEntry<?> indexEntry, boolean currentlyExists );
+
+
/**
* Returns a cursor which provides a transactionally consistent view of the wrapped cursor.
*
Modified: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=1208357&r1=1208356&r2=1208357&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Wed Nov 30 10:04:45 2011
@@ -78,6 +78,7 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.api.schema.SchemaPartition;
import org.apache.directory.server.core.api.subtree.SubentryCache;
import org.apache.directory.server.core.api.subtree.SubtreeEvaluator;
+import org.apache.directory.server.core.api.txn.TxnManager;
import org.apache.directory.server.core.authn.AuthenticationInterceptor;
import org.apache.directory.server.core.authn.ppolicy.PpolicyConfigContainer;
import org.apache.directory.server.core.authz.AciAuthorizationInterceptor;
@@ -97,6 +98,8 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.shared.DefaultCoreSession;
import org.apache.directory.server.core.shared.DefaultDnFactory;
import org.apache.directory.server.core.shared.partition.DefaultPartitionNexus;
+import org.apache.directory.server.core.shared.partition.OperationExecutionManagerFactory;
+import org.apache.directory.server.core.shared.txn.TxnManagerFactory;
import org.apache.directory.server.core.subtree.SubentryInterceptor;
import org.apache.directory.server.core.trigger.TriggerInterceptor;
import org.apache.directory.server.i18n.I18n;
@@ -299,6 +302,7 @@ public class DefaultDirectoryService imp
/** The Subtree evaluator instance */
private SubtreeEvaluator evaluator;
+
/**
* The synchronizer thread. It flush data on disk periodically.
@@ -790,6 +794,14 @@ public class DefaultDirectoryService imp
throw new IOException(I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, instanceLayout.getLogDirectory() ) );
}
}
+
+ if ( !instanceLayout.getTxnLogDirectory().exists() )
+ {
+ if ( !instanceLayout.getTxnLogDirectory().mkdirs() )
+ {
+ throw new IOException(I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, instanceLayout.getLogDirectory() ) );
+ }
+ }
if ( !instanceLayout.getRunDirectory().exists() )
{
@@ -1050,6 +1062,8 @@ public class DefaultDirectoryService imp
Tag latest = changeLog.getLatest();
+
+
if ( null != latest )
{
if ( latest.getRevision() < changeLog.getCurrentRevision() )
@@ -1130,7 +1144,8 @@ public class DefaultDirectoryService imp
throw new IllegalArgumentException( I18n.err( I18n.ERR_314 ) );
}
- Cursor<ChangeLogEvent> cursor = changeLog.getChangeLogStore().findAfter( revision );
+ TxnManager txnManager = TxnManagerFactory.txnManagerInstance();
+ Cursor<ChangeLogEvent> cursor = null;
/*
* BAD, BAD, BAD!!!
@@ -1150,60 +1165,100 @@ public class DefaultDirectoryService imp
try
{
LOG.warn( PARTIAL_IMPL_WARNING );
- cursor.afterLast();
- while ( cursor.previous() ) // apply ldifs in reverse order
+ boolean done = false;
+
+ do
{
- ChangeLogEvent event = cursor.get();
- List<LdifEntry> reverses = event.getReverseLdifs();
+ txnManager.beginTransaction( false );
+
+ cursor = changeLog.getChangeLogStore().findAfter( revision );
- for ( LdifEntry reverse:reverses )
+ try
{
- switch( reverse.getChangeType().getChangeType() )
- {
- case ChangeType.ADD_ORDINAL :
- adminSession.add(
- new DefaultEntry( schemaManager, reverse.getEntry() ), true );
- break;
-
- case ChangeType.DELETE_ORDINAL :
- adminSession.delete( reverse.getDn(), true );
- break;
-
- case ChangeType.MODIFY_ORDINAL :
- List<Modification> mods = reverse.getModifications();
-
- adminSession.modify( reverse.getDn(), mods, true );
- break;
-
- case ChangeType.MODDN_ORDINAL :
- // NO BREAK - both ModDN and ModRDN handling is the same
-
- case ChangeType.MODRDN_ORDINAL :
- Dn forwardDn = event.getForwardLdif().getDn();
- Dn reverseDn = reverse.getDn();
-
- moddn( reverseDn, forwardDn, reverse.isDeleteOldRdn() );
+ cursor.afterLast();
- break;
+ while ( cursor.previous() ) // apply ldifs in reverse order
+ {
+ ChangeLogEvent event = cursor.get();
+ List<LdifEntry> reverses = event.getReverseLdifs();
- default:
- LOG.error( I18n.err( I18n.ERR_75 ) );
- throw new NotImplementedException( I18n.err( I18n.ERR_76, reverse.getChangeType() ) );
+ for ( LdifEntry reverse : reverses )
+ {
+ switch ( reverse.getChangeType().getChangeType() )
+ {
+ case ChangeType.ADD_ORDINAL:
+ adminSession.add(
+ new DefaultEntry( schemaManager, reverse.getEntry() ), true );
+ break;
+
+ case ChangeType.DELETE_ORDINAL:
+ adminSession.delete( reverse.getDn(), true );
+ break;
+
+ case ChangeType.MODIFY_ORDINAL:
+ List<Modification> mods = reverse.getModifications();
+
+ adminSession.modify( reverse.getDn(), mods, true );
+ break;
+
+ case ChangeType.MODDN_ORDINAL:
+ // NO BREAK - both ModDN and ModRDN handling is the same
+
+ case ChangeType.MODRDN_ORDINAL:
+ Dn forwardDn = event.getForwardLdif().getDn();
+ Dn reverseDn = reverse.getDn();
+
+ moddn( reverseDn, forwardDn, reverse.isDeleteOldRdn() );
+
+ break;
+
+ default:
+ LOG.error( I18n.err( I18n.ERR_75 ) );
+ throw new NotImplementedException( I18n.err( I18n.ERR_76, reverse.getChangeType() ) );
+ }
+ }
}
}
+ catch ( Exception e )
+ {
+ txnManager.abortTransaction();
+
+ throw e;
+ }
+
+ txnManager.commitTransaction();
+ done = true;
}
+ while ( !done );
+
}
catch ( IOException e )
{
+ e.printStackTrace();
String message = I18n.err( I18n.ERR_77, revision );
LOG.error( message );
throw new LdapException( message );
}
catch ( Exception e )
{
+ e.printStackTrace();
throw new LdapOperationException( e.getMessage(), e );
}
+ finally
+ {
+ if ( cursor != null )
+ {
+ try
+ {
+ cursor.close();
+ }
+ catch( Exception e )
+ {
+
+ }
+ }
+ }
return changeLog.getCurrentRevision();
}
@@ -1777,7 +1832,7 @@ public class DefaultDirectoryService imp
.getRdnValue( ServerDNConstants.SYSTEM_DN ) );
AddOperationContext addOperationContext = new AddOperationContext( adminSession, systemEntry );
- system.add( addOperationContext );
+ OperationExecutionManagerFactory.instance().add( system, addOperationContext );
}
}