From commits-return-34246-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Sun Jun 17 01:50:30 2012 Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AAFAE9A0A for ; Sun, 17 Jun 2012 01:50:30 +0000 (UTC) Received: (qmail 65412 invoked by uid 500); 17 Jun 2012 01:50:30 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 65358 invoked by uid 500); 17 Jun 2012 01:50:30 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 65342 invoked by uid 99); 17 Jun 2012 01:50:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Jun 2012 01:50:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Jun 2012 01:50:22 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2FAC1238899C for ; Sun, 17 Jun 2012 01:50:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1351037 - 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/schema/ core-api/src/main/java/org/apache/directory/serve... Date: Sun, 17 Jun 2012 01:49:58 -0000 To: commits@directory.apache.org From: saya@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120617015000.2FAC1238899C@eris.apache.org> Author: saya Date: Sun Jun 17 01:49:57 2012 New Revision: 1351037 URL: http://svn.apache.org/viewvc?rev=1351037&view=rev Log: Changes to implement crash recovery. Has been tested with a couple of tests doing service shutdown/startup. Will implement a test specific for this. Added: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnLogManagerInternal.java Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/Log.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-api/src/main/java/org/apache/directory/server/core/api/txn/TxnManager.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-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLog.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/log/LogManager.java directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/OperationExecutionManagerFactory.java directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/AbstractTransaction.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/Transaction.java directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnManagerFactory.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/TxnStateChange.java directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java directory/apacheds/branches/apacheds-txns/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java directory/apacheds/branches/apacheds-txns/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java directory/apacheds/branches/apacheds-txns/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/Log.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/Log.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/Log.java (original) +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/Log.java Sun Jun 17 01:49:57 2012 @@ -72,16 +72,23 @@ public interface Log * @return A scanner to read the logs one by one */ LogScanner beginScan(); - - + + /** - * Advances the min needed position in the logs. Logging subsystem uses this - * information to get rid of unneeded - * - * @param newAnchor The new position + * Advances the checkpoint in the logs + * + * @param checkPoint min needed position the caller needs in the logs. */ - void advanceMinNeededLogPosition( LogAnchor newAnchor ); + void advanceCheckPoint( LogAnchor checkPoint ); + + /** + * Return the current checkpoint anchor + * + * @return the current checkpoint anchor + */ + LogAnchor getCheckPoint(); + /** * Synchronizes the log up to the given LSN. If LSN is equal to unknown 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=1351037&r1=1351036&r2=1351037&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 Sun Jun 17 01:49:57 2012 @@ -365,7 +365,7 @@ public final class SchemaPartition exten if ( entry == null ) { LookupOperationContext lookupCtx = new LookupOperationContext( modifyContext.getSession(), modifyContext.getDn() ); - entry = wrapped.lookup( lookupCtx ); + entry = modifyContext.getSession().getDirectoryService().getPartitionNexus().lookup( lookupCtx );; modifyContext.setEntry( entry ); } 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=1351037&r1=1351036&r2=1351037&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 Sun Jun 17 01:49:57 2012 @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.Comparator; import java.util.UUID; +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.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexComparator; Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnManager.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnManager.java (original) +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnManager.java Sun Jun 17 01:49:57 2012 @@ -19,6 +19,7 @@ */ package org.apache.directory.server.core.api.txn; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.shared.ldap.model.exception.LdapException; @@ -131,5 +132,11 @@ public interface TxnManager * @return TRUE if txn needs to do logical data reinit */ boolean prepareForLogicalDataReinit(); + + + /** + * Recovers the given partition + */ + void recoverPartition( Partition partition ); } 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=1351037&r1=1351036&r2=1351037&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 Sun Jun 17 01:49:57 2012 @@ -32,6 +32,12 @@ import org.apache.directory.server.core. */ public interface LogEdit extends Externalizable { + public enum EditType + { + DATA_CHANGE, + TXN_MARKER + } + /** * Returns the position the edit is inserted in the wal. * Log anchor is initialized is set after the edit is serialized and inserted into Modified: directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java (original) +++ directory/apacheds/branches/apacheds-txns/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java Sun Jun 17 01:49:57 2012 @@ -34,6 +34,7 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.integ.FrameworkRunner; import org.apache.directory.server.core.integ.IntegrationUtils; import org.apache.directory.shared.ldap.model.entry.Attribute; +import org.apache.directory.shared.ldap.model.entry.DefaultEntry; import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.exception.LdapAuthenticationException; import org.apache.directory.shared.ldap.model.message.ModifyRequest; @@ -93,6 +94,7 @@ public class SimpleAuthenticationIT exte performAdminAccountChecks( entry ); assertTrue( ArrayUtils.isEquals( entry.get( "userPassword" ).get().getBytes(), Strings .getBytesUtf8("secret") ) ); + connection.close(); getService().shutdown(); @@ -103,6 +105,9 @@ public class SimpleAuthenticationIT exte performAdminAccountChecks( entry ); assertTrue( ArrayUtils.isEquals( entry.get( "userPassword" ).get().getBytes(), Strings .getBytesUtf8("secret") ) ); + + + connection.close(); } Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLog.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLog.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLog.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/DefaultLog.java Sun Jun 17 01:49:57 2012 @@ -106,19 +106,33 @@ public class DefaultLog implements Log return logScanner; } - + /** * {@inheritDoc} */ - public void advanceMinNeededLogPosition( LogAnchor newAnchor ) + public void advanceCheckPoint( LogAnchor checkPoint ) { - logManager.advanceMinLogAnchor( newAnchor ); + if ( checkPoint == null ) + { + return; + } + + logManager.advanceCheckPoint( checkPoint ); } /** * {@inheritDoc} */ + public LogAnchor getCheckPoint() + { + return logManager.getCheckPoint(); + } + + + /** + * {@inheritDoc} + */ public void sync( long uptoLSN ) throws IOException, InvalidLogException { logFlushManager.sync( uptoLSN ); 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=1351037&r1=1351036&r2=1351037&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 Sun Jun 17 01:49:57 2012 @@ -109,6 +109,8 @@ import org.apache.directory.server.i18n. this.logManager = logManager; logBuffer = new LogBuffer( logBufferSize, currentLogFile ); + + logLSN = logManager.getInitialLsn(); } Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogManager.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogManager.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/log/LogManager.java Sun Jun 17 01:49:57 2012 @@ -90,6 +90,9 @@ import org.apache.directory.server.i18n. /** The Checksum used */ private Checksum checksum = new Adler32(); + + /** Max lsn in the log after recovery */ + private long initialLsn = Long.MIN_VALUE ; /** @@ -163,6 +166,9 @@ import org.apache.directory.server.i18n. { scanner.close(); } + + initialLsn = logRecord.getLogAnchor().getLogLSN(); + System.out.println(" Log manager inital lsn " + initialLsn); long lastGoodLogFileNumber = scanner.getLastGoodFileNumber(); long lastGoodLogFileOffset = scanner.getLastGoodOffset(); @@ -227,6 +233,8 @@ import org.apache.directory.server.i18n. createNextLogFile( true ); } } + + return; } /* @@ -267,6 +275,15 @@ import org.apache.directory.server.i18n. /** + * + * @return return the max lsn in the log after recovery + */ + public long getInitialLsn() + { + return initialLsn; + } + + /** * Called by LogFlushManager to switch to the next file. * * Note:Currently we do a checkpoint and delete unnecessary log files when we switch to a new file. Some @@ -298,44 +315,55 @@ import org.apache.directory.server.i18n. return writer; } - - /** - * @return The anchor associated with the last valid checkpoint. - */ - /* Package protected */LogAnchor getMinLogAnchor() - { - minLogAnchorLock.lock(); - LogAnchor anchor = new LogAnchor(); - anchor.resetLogAnchor( minLogAnchor ); - minLogAnchorLock.unlock(); - - return anchor; - } - - /** * Called when the logging subsystem is notified about the minimum position * in the log files that is needed. Log manager uses this information to advance * its checkpoint and delete unnecessary log files. * - * @param newLogAnchor min needed log anchor + * @param newCheckPoint min needed log anchor */ - public void advanceMinLogAnchor( LogAnchor newLogAnchor ) + public void advanceCheckPoint( LogAnchor newCheckPoint ) { - if ( newLogAnchor == null ) + if ( newCheckPoint == null ) { return; } minLogAnchorLock.lock(); - if ( anchorComparator.compare( minLogAnchor, newLogAnchor ) < 0 ) + if ( anchorComparator.compare( minLogAnchor, newCheckPoint ) < 0 ) + { + minLogAnchor.resetLogAnchor( newCheckPoint ); + } + + try { - minLogAnchor.resetLogAnchor( newLogAnchor ); + writeControlFile(); + } + catch ( IOException e ) + { + // Ignore } minLogAnchorLock.unlock(); } + + /** + * + * @return the current with the checkpoint log achor + */ + public LogAnchor getCheckPoint() + { + LogAnchor anchor = new LogAnchor(); + + minLogAnchorLock.lock(); + + anchor.resetLogAnchor( minLogAnchor ); + + minLogAnchorLock.unlock(); + + return anchor; + } /** @@ -359,15 +387,10 @@ import org.apache.directory.server.i18n. */ private void writeControlFile() throws IOException { - // Copy the min log file anchor - minLogAnchorLock.lock(); - controlFileRecord.minNeededLogFile = minLogAnchor.getLogFileNumber(); controlFileRecord.minNeededLogFileOffset = minLogAnchor.getLogFileOffset(); controlFileRecord.minNeededLSN = minLogAnchor.getLogLSN(); - - minLogAnchorLock.unlock(); - + if ( controlFileRecord.minNeededLogFile > controlFileRecord.minExistingLogFile ) { deleteUnnecessaryLogFiles( controlFileRecord.minExistingLogFile, controlFileRecord.minNeededLogFile ); Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java Sun Jun 17 01:49:57 2012 @@ -504,6 +504,7 @@ public class DefaultOperationExecutionMa } catch ( Exception e ) { + e.printStackTrace(); throw new LdapOperationErrorException( e.getMessage(), e ); } } Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/OperationExecutionManagerFactory.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/OperationExecutionManagerFactory.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/OperationExecutionManagerFactory.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/OperationExecutionManagerFactory.java Sun Jun 17 01:49:57 2012 @@ -33,17 +33,31 @@ public class OperationExecutionManagerFa { /** Operation Manager instance */ private OperationExecutionManager executionManager; + + private TxnManagerFactory txnManagerFactory; + + private boolean inited = false; public OperationExecutionManagerFactory( TxnManagerFactory txnManagerFactory ) { - executionManager = new DefaultOperationExecutionManager( txnManagerFactory ); + this.txnManagerFactory = txnManagerFactory; + + this.init(); } + public void init() + { + if ( inited ) + return; + + executionManager = new DefaultOperationExecutionManager( txnManagerFactory ); + } + public void shutdown() { - //do nothing; + inited = false; } Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/AbstractTransaction.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/AbstractTransaction.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/AbstractTransaction.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/AbstractTransaction.java Sun Jun 17 01:49:57 2012 @@ -61,6 +61,12 @@ abstract class AbstractTransaction imple /** version of the logical data vseen by this txn */ private long myLogicalDataVersion; + + public void setTxnId( long id ) + { + this.id = id; + } + public boolean isOptimisticLockHeld() { return isOptimisticLockHeld; @@ -100,6 +106,7 @@ abstract class AbstractTransaction imple id = counter.getAndIncrement(); } + /** * {@inheritDoc} 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=1351037&r1=1351036&r2=1351037&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 Sun Jun 17 01:49:57 2012 @@ -44,7 +44,7 @@ import org.apache.directory.shared.ldap. * * @author Apache Directory Project */ -public class DefaultTxnLogManager implements TxnLogManager +public class DefaultTxnLogManager implements TxnLogManagerInternal { /** Write ahead log */ private Log wal; @@ -103,13 +103,13 @@ public class DefaultTxnLogManager implem ReadWriteTxn txn = ( ReadWriteTxn ) curTxn; UserLogRecord logRecord = txn.getUserLogRecord(); + ( ( AbstractLogEdit ) logEdit ).setTxnID( txn.getId() ); logEdit.injectData( logRecord, UserLogRecord.LogEditType.DATA ); + + logEdit.getLogAnchor().resetLogAnchor( logRecord.getLogAnchor() ); log( logRecord, sync ); - logEdit.getLogAnchor().resetLogAnchor( logRecord.getLogAnchor() ); - ( ( AbstractLogEdit ) logEdit ).setTxnID( txn.getId() ); - txn.addLogEdit( logEdit ); } @@ -265,6 +265,10 @@ public class DefaultTxnLogManager implem addDnSet( baseDn, scope, false ); } + public Log getWAL() + { + return wal; + } private void addDnSet( Dn baseDn, SearchScope scope, boolean read ) { 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=1351037&r1=1351036&r2=1351037&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 Sun Jun 17 01:49:57 2012 @@ -20,7 +20,9 @@ package org.apache.directory.server.core.shared.txn; +import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.ObjectInputStream; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -35,15 +37,22 @@ import java.util.concurrent.locks.ReadWr import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import org.apache.directory.server.core.api.log.Log; import org.apache.directory.server.core.api.log.LogAnchor; +import org.apache.directory.server.core.api.log.LogScanner; import org.apache.directory.server.core.api.log.UserLogRecord; import org.apache.directory.server.core.api.partition.Partition; +import org.apache.directory.server.core.api.schema.SchemaPartition; 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.api.txn.logedit.LogEdit.EditType; +import org.apache.directory.server.core.shared.txn.logedit.DataChangeContainer; import org.apache.directory.server.core.shared.txn.logedit.TxnStateChange; +import org.apache.directory.server.core.shared.txn.logedit.TxnStateChange.ChangeState; import org.apache.directory.shared.ldap.model.exception.LdapException; +import org.apache.directory.shared.ldap.model.name.Dn; /** @@ -55,6 +64,9 @@ class DefaultTxnManager implements TxnMa { /** wal log manager */ private TxnLogManager txnLogManager; + + /** Write ahead log */ + private Log wal; /** List of committed txns in commit LSN order */ private ConcurrentLinkedQueue committedQueue = new ConcurrentLinkedQueue(); @@ -86,8 +98,14 @@ class DefaultTxnManager implements TxnMa /** Flush lock */ private Lock flushLock = new ReentrantLock(); - /** Number of flushes */ + /** Number of flushed txns */ + private int numFlushedTxns; + + /** Number of flushed */ private int numFlushes; + + /** Take a checkpoint every 1000 flushes ~100 secs */ + private final static int DEFAULT_FLUSH_ROUNDS = 1000; /** Flush Condition object */ private Condition flushCondition = flushLock.newCondition(); @@ -107,7 +125,16 @@ class DefaultTxnManager implements TxnMa private AtomicInteger pending = new AtomicInteger(); /** Logical data version number */ - private long logicalDataVersion = 0; + private long logicalDataVersion; + + /** Initial scan point into the logs */ + private LogAnchor initialScanPoint; + + /** Initial set of committed txns */ + private HashSet txnsToRecover = new HashSet(); + + /** last flushed log anchor */ + private LogAnchor lastFlushedLogAnchor; /** Per thread txn context */ static final ThreadLocal txnVar = @@ -130,41 +157,66 @@ class DefaultTxnManager implements TxnMa * @param idComparator * @param idSerializer */ - public void init( TxnLogManager txnLogManager ) + public void init( TxnLogManagerInternal txnLogManager ) { this.txnLogManager = txnLogManager; + wal = txnLogManager.getWAL(); flushInterval = DEFAULT_FLUSH_INTERVAL; + + + committedQueue.clear(); + latestFlushedTxnLSN.set( LogAnchor.UNKNOWN_LSN ); + txnsToRecover.clear(); + logicalDataVersion = 0; + lastFlushedLogAnchor = new LogAnchor(); - dummyTxn.commitTxn( LogAnchor.UNKNOWN_LSN ); + initialScanPoint = wal.getCheckPoint(); + lastFlushedLogAnchor.resetLogAnchor( initialScanPoint ); + + dummyTxn.commitTxn( initialScanPoint.getLogLSN() ); latestCommittedTxn.set( dummyTxn ); latestVerifiedTxn.set( dummyTxn ); committedQueue.offer( dummyTxn ); + + getTxnsToReover(); - syncer = new LogSyncer(); - syncer.setDaemon( true ); - syncer.start(); + if ( syncer == null ) + { + syncer = new LogSyncer(); + syncer.setDaemon( true ); + syncer.start(); + } } public void shutdown() { + System.out.println("in shutdown"); syncer.interrupt(); try { - syncer.join(); + syncer.join(); } catch ( InterruptedException e ) { - // Ignore + //Ignore } + // Do a best effort last flush flushLock.lock(); try { - flushTxns(); + ReadWriteTxn latestCommitted = latestCommittedTxn.get(); + long latestFlushedLsn = latestFlushedTxnLSN.get(); + + System.out.println("latest committed txn " + latestCommitted.getCommitTime() + + " latest flushed " + latestFlushedLsn); + //flushTxns(); + + //advanceCheckPoint( lastFlushedLogAnchor ); } catch ( Exception e ) { @@ -174,7 +226,7 @@ class DefaultTxnManager implements TxnMa { flushLock.unlock(); } - + syncer = null; } @@ -616,6 +668,7 @@ class DefaultTxnManager implements TxnMa { txnLogManager.log( logRecord, false ); txn.startTxn( logRecord.getLogAnchor().getLogLSN(), logicalDataVersion ); + txn.setTxnId( logRecord.getLogAnchor().getLogLSN() ); do { @@ -852,6 +905,8 @@ class DefaultTxnManager implements TxnMa */ private void flushTxns() throws Exception { + UserLogRecord lastLogRecord = null; + // If flushing failed already, dont do anything anymore if ( flushFailed ) { @@ -879,6 +934,8 @@ class DefaultTxnManager implements TxnMa txnToFlush.flushLogEdits( flushedToPartitions ); latestFlushedTxnLSN.set( txnToFlush.getCommitTime() ); + + lastLogRecord = txnToFlush.getUserLogRecord(); } if ( txnToFlush == latestCommitted ) @@ -887,7 +944,7 @@ class DefaultTxnManager implements TxnMa break; } - numFlushes++; + numFlushedTxns++; // if ( numFlushes % 100 == 0 ) // { @@ -919,11 +976,147 @@ class DefaultTxnManager implements TxnMa { partitionIt.next().sync(); } + + numFlushes++; + + if ( lastLogRecord != null ) + { + lastFlushedLogAnchor.resetLogAnchor(lastLogRecord.getLogAnchor()); + } + + if (numFlushes % DEFAULT_FLUSH_ROUNDS == 0 ) + { + advanceCheckPoint( lastFlushedLogAnchor ); + } } + + + private void advanceCheckPoint( LogAnchor checkPoint ) + { + wal.advanceCheckPoint(checkPoint); + } + + + private void getTxnsToReover() + { + LogScanner logScanner = wal.beginScan( initialScanPoint ); + UserLogRecord logRecord = new UserLogRecord(); + byte userRecord[]; + + System.out.println(" Get txns to recover " + initialScanPoint.getLogLSN() ); + + try + { + while ( logScanner.getNextRecord( logRecord ) ) + { + userRecord = logRecord.getDataBuffer(); + ObjectInputStream in = buildStream( userRecord ); + + EditType editType = EditType.values()[in.read()]; + + + if (editType == EditType.TXN_MARKER) + { + TxnStateChange stateChange = new TxnStateChange(); + stateChange.readExternal(in); + + if ( stateChange.getTxnState() == ChangeState.TXN_COMMIT ) + { + System.out.println("Adding txn " + stateChange.getTxnID() + " to the tobe recovered txns"); + txnsToRecover.add( new Long( stateChange.getTxnID() ) ); + } + } + } + } + catch ( Exception e ) + { + e.printStackTrace(); + // Ignore + } + } + + + // Walk over the txn log records from the latest checkpoint and apply the + // log records to the partition + public void recoverPartition( Partition partition ) + { + Dn partitionSuffix = partition.getSuffixDn(); + + System.out.println("Recover partition " + partitionSuffix); + + LogScanner logScanner = wal.beginScan( initialScanPoint ); + UserLogRecord logRecord = new UserLogRecord(); + byte userRecord[]; + + boolean recoveredChanges = false; + + try + { + while ( logScanner.getNextRecord( logRecord ) ) + { + userRecord = logRecord.getDataBuffer(); + ObjectInputStream in = buildStream( userRecord ); + + EditType editType = EditType.values()[in.read()]; + + if (editType == EditType.DATA_CHANGE) + { + DataChangeContainer dataChangeContainer = new DataChangeContainer(); + dataChangeContainer.readExternal(in); + + System.out.println("Data change container for " + dataChangeContainer.getPartitionDn() + + " txn id " + dataChangeContainer.getTxnID() ); + + // If this change is for the partition we are tyring to recover + // and belongs to a txn that committed, then + Long txnID = new Long( dataChangeContainer.getTxnID() ); + + if ( txnsToRecover.contains( txnID ) ) + { + if( dataChangeContainer.getPartitionDn().equals( partitionSuffix ) ) + { + System.out.println("Apply change to partition " + partitionSuffix); + dataChangeContainer.setPartition( partition ); + dataChangeContainer.apply( true ); + recoveredChanges = true; + } + } + } + } + + if ( recoveredChanges && partition instanceof SchemaPartition ) + { + ( (SchemaPartition) partition ).getSchemaManager().reloadAllEnabled(); + } + } + catch ( Exception e ) + { + e.printStackTrace(); + // Ignore for now + } + } + + + private ObjectInputStream buildStream( byte[] buffer ) throws IOException + { + ObjectInputStream oIn = null; + ByteArrayInputStream in = new ByteArrayInputStream( buffer ); + + try + { + oIn = new ObjectInputStream( in ); + + return oIn; + } + catch ( IOException ioe ) + { + throw ioe; + } + } class LogSyncer extends Thread - { + { @Override public void run() { @@ -931,8 +1124,8 @@ class DefaultTxnManager implements TxnMa try { - while ( !this.isInterrupted() ) - { + while ( true ) + { flushCondition.await( flushInterval, TimeUnit.MILLISECONDS ); flushTxns(); } Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/Transaction.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/Transaction.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/Transaction.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/Transaction.java Sun Jun 17 01:49:57 2012 @@ -37,6 +37,12 @@ import org.apache.directory.shared.ldap. /** Package protected */ interface Transaction extends TxnHandle { + /** + * Set the txn id. Used to change the txn id to the log lsn + * @param id new txn id + */ + void setTxnId( long id ); + /** * returns TRUE if optimisticLock held, false otherwise * Added: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnLogManagerInternal.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnLogManagerInternal.java?rev=1351037&view=auto ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnLogManagerInternal.java (added) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnLogManagerInternal.java Sun Jun 17 01:49:57 2012 @@ -0,0 +1,13 @@ +package org.apache.directory.server.core.shared.txn; + +import org.apache.directory.server.core.api.log.Log; +import org.apache.directory.server.core.api.txn.TxnLogManager; + +interface TxnLogManagerInternal extends TxnLogManager +{ + /** + * + * @return return the wal log manager used by the txnlogmanager + */ + Log getWAL(); +} Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnManagerFactory.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnManagerFactory.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnManagerFactory.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/TxnManagerFactory.java Sun Jun 17 01:49:57 2012 @@ -39,12 +39,22 @@ public class TxnManagerFactory private TxnManagerInternal txnManager; /** The only txn log manager */ - private TxnLogManager txnLogManager; + private TxnLogManagerInternal txnLogManager; + + /** WAL */ + private Log log; /** log suffix */ private String LOG_SUFFIX = "log"; private boolean inited; + + + private String logFolderPath; + + private int logBufferSize; + + private long logFileSize; /** @@ -59,25 +69,39 @@ public class TxnManagerFactory public TxnManagerFactory( String logFolderPath, int logBufferSize, long logFileSize ) throws IOException { - Log log = new DefaultLog(); - - try - { - log.init( logFolderPath, LOG_SUFFIX, logBufferSize, logFileSize ); - } - catch ( InvalidLogException e ) - { - throw new IOException( e ); - } + this.logFolderPath = logFolderPath; + this.logBufferSize = logBufferSize; + this.logFileSize = logFileSize; + + log = new DefaultLog(); txnManager = new DefaultTxnManager(); txnLogManager = new DefaultTxnLogManager( log, this ); - - ( ( DefaultTxnManager ) txnManager ).init( txnLogManager ); - - inited = true; - + + this.init(); + } + + + public void init() throws IOException + { + if ( inited ) + { + return; + } + + try + { + log.init( logFolderPath, LOG_SUFFIX, logBufferSize, logFileSize ); + } + catch ( InvalidLogException e ) + { + throw new IOException( e ); + } + + ( ( DefaultTxnManager ) txnManager ).init(txnLogManager); + + inited = true; } 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=1351037&r1=1351036&r2=1351037&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 Sun Jun 17 01:49:57 2012 @@ -97,6 +97,11 @@ public class DataChangeContainer extends { return partition; } + + public void setPartition( Partition partition ) + { + this.partition = partition; + } public UUID getEntryID() @@ -154,18 +159,23 @@ public class DataChangeContainer extends { EntryModification entryModification = ( EntryModification ) change; - curEntry = entryModification.applyModification( partition, curEntry, entryID, changeLsn, false ); + curEntry = entryModification.applyModification( partition, curEntry, entryID, changeLsn, recovery ); } else { IndexModification indexModification = ( IndexModification ) change; - indexModification.applyModification( partition, false ); + indexModification.applyModification( partition, recovery ); } } if ( curEntry != null ) { MasterTable master = partition.getMasterTable(); + + if ( !curEntry.isSchemaAware() ) + { + curEntry.apply( partition.getSchemaManager() ); + } master.put( entryID, curEntry ); } else @@ -312,6 +322,8 @@ public class DataChangeContainer extends { DataChange change; + out.write(EditType.DATA_CHANGE.ordinal()); + if ( entryID != null ) { out.writeBoolean( true ); Modified: 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?rev=1351037&r1=1351036&r2=1351037&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 Sun Jun 17 01:49:57 2012 @@ -99,6 +99,8 @@ public class TxnStateChange extends Abst @Override public void writeExternal( ObjectOutput out ) throws IOException { + out.write(EditType.TXN_MARKER.ordinal()); + out.writeLong( txnID ); out.write( txnState.ordinal() ); } 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=1351037&r1=1351036&r2=1351037&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 Sun Jun 17 01:49:57 2012 @@ -1358,11 +1358,16 @@ public class DefaultDirectoryService imp txnManagerFactory = new TxnManagerFactory( getInstanceLayout().getTxnLogDirectory().getPath(), TXN_LOG_BUFFER_SIZE, TXN_LOG_FILE_SIZE ); } - + + txnManagerFactory.init(); + + if ( executionManagerFactory == null ) { executionManagerFactory = new OperationExecutionManagerFactory( txnManagerFactory ); } + + executionManagerFactory.init(); initialize(); showSecurityWarnings(); @@ -1417,7 +1422,7 @@ public class DefaultDirectoryService imp { return; } - + // -------------------------------------------------------------------- // Shutdown the txnManager // 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=1351037&r1=1351036&r2=1351037&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 Sun Jun 17 01:49:57 2012 @@ -184,7 +184,7 @@ public class JdbmIndex extends Abstra String path = new File( this.wkDirPath, attributeType.getOid() ).getAbsolutePath(); BaseRecordManager base = new BaseRecordManager( path ); - base.disableTransactions(); + //base.disableTransactions(); this.recMan = new SnapshotRecordManager( base, DEFAULT_INDEX_CACHE_SIZE ); try Modified: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.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/JdbmPartition.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java (original) +++ directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java Sun Jun 17 01:49:57 2012 @@ -135,7 +135,7 @@ public class JdbmPartition extends Abstr // First, check if the file storing the data exists String path = partitionDir.getPath() + File.separator + "master"; BaseRecordManager baseRecordManager = new BaseRecordManager( path ); - baseRecordManager.disableTransactions(); + //baseRecordManager.disableTransactions(); if ( cacheSize < 0 ) { @@ -188,6 +188,9 @@ public class JdbmPartition extends Abstr deleteUnusedIndexFiles( allIndices, allIndexDbFiles ); + // Apply the txn logs + txnManagerFactory.txnManagerInstance().recoverPartition( this ); + // We are done ! initialized = true; } Modified: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.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/JdbmRdnIndex.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java (original) +++ directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java Sun Jun 17 01:49:57 2012 @@ -96,7 +96,7 @@ public class JdbmRdnIndex extends Jdb //System.out.println( "IDX Created index " + path ); BaseRecordManager base = new BaseRecordManager( path ); - base.disableTransactions(); + //base.disableTransactions(); this.recMan = new SnapshotRecordManager( base, cacheSize ); try Modified: directory/apacheds/branches/apacheds-txns/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java (original) +++ directory/apacheds/branches/apacheds-txns/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java Sun Jun 17 01:49:57 2012 @@ -156,6 +156,9 @@ public class LdifPartition extends Abstr if ( suffixDirectory.exists() ) { loadEntries( partitionDir ); + + // Apply the txn logs + txnManagerFactory.txnManagerInstance().recoverPartition( this ); } else { @@ -195,7 +198,7 @@ public class LdifPartition extends Abstr // And add this entry to the underlying partition AddOperationContext addContext = new AddOperationContext( schemaManager, contextEntry ); - add( addContext ); + executionManager.add( this, addContext ); } } } Modified: directory/apacheds/branches/apacheds-txns/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java (original) +++ directory/apacheds/branches/apacheds-txns/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java Sun Jun 17 01:49:57 2012 @@ -125,6 +125,9 @@ public class SingleFileLdifPartition ext super.doInit(); loadEntries(); + + // Apply the txn logs + txnManagerFactory.txnManagerInstance().recoverPartition( this ); } } Modified: directory/apacheds/branches/apacheds-txns/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java?rev=1351037&r1=1351036&r2=1351037&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java (original) +++ directory/apacheds/branches/apacheds-txns/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java Sun Jun 17 01:49:57 2012 @@ -166,7 +166,7 @@ public class ApacheDsService LOG.info( "using partition dir {}", partitionsDir.getAbsolutePath() ); txnManagerFactory = new TxnManagerFactory( instanceLayout.getTxnLogDirectory().getPath(), - DirectoryService.TXN_LOG_BUFFER_SIZE, DirectoryService.TXN_LOG_FILE_SIZE ); + DirectoryService.TXN_LOG_BUFFER_SIZE, DirectoryService.TXN_LOG_FILE_SIZE ); executionManagerFactory = new OperationExecutionManagerFactory( txnManagerFactory ); initSchemaManager( instanceLayout );