Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 12624 invoked from network); 28 Oct 2008 10:25:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Oct 2008 10:25:18 -0000 Received: (qmail 50984 invoked by uid 500); 28 Oct 2008 10:25:23 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 50949 invoked by uid 500); 28 Oct 2008 10:25:22 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 50940 invoked by uid 99); 28 Oct 2008 10:25:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Oct 2008 03:25:22 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Tue, 28 Oct 2008 10:24:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2D4CC238889D; Tue, 28 Oct 2008 03:24:57 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r708510 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/store/raw/log/LogFactory.java impl/store/raw/RawStore.java impl/store/raw/log/LogToFile.java impl/store/raw/log/ReadOnly.java Date: Tue, 28 Oct 2008 10:24:55 -0000 To: derby-commits@db.apache.org From: jorgenlo@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081028102457.2D4CC238889D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jorgenlo Date: Tue Oct 28 03:24:48 2008 New Revision: 708510 URL: http://svn.apache.org/viewvc?rev=708510&view=rev Log: DERBY-3890: Replication: NPE for startSlave of encrypted database Removes NPE for replication of encrypted databases by setting RawStoreFactory in LogFactory before calling SlaveFactory#startSlave. Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java?rev=708510&r1=708509&r2=708510&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java Tue Oct 28 03:24:48 2008 @@ -63,19 +63,22 @@ public Logger getLogger(); /** + Make log factory aware of which raw store factory it belongs to + */ + public void setRawStoreFactory(RawStoreFactory rsf); + + /** Recover the database to a consistent state using the log. Each implementation of the log factory has its own recovery algorithm, please see the implementation for a description of the specific recovery algorithm it uses. - @param rawStoreFactory - the raw store @param dataFactory - the data factory @param transactionFactory - the transaction factory @exception StandardException - encounter exception while recovering. */ - public void recover(RawStoreFactory rawStoreFactory, - DataFactory dataFactory, + public void recover(DataFactory dataFactory, TransactionFactory transactionFactory) throws StandardException; Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java?rev=708510&r1=708509&r2=708510&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java Tue Oct 28 03:24:48 2008 @@ -314,6 +314,11 @@ dataFactory.setDatabaseEncrypted(); } + // RawStoreFactory is used by LogFactory.recover() and by + // SlaveFactory.startSlave (for the SlaveFactory case, it is + // only used if the database is encrypted) + logFactory.setRawStoreFactory(this); + // If SlaveFactory is to be booted, the boot has to happen // before logFactory.recover since that method will be blocked // when in replication slave mode. @@ -331,7 +336,7 @@ // no need to tell log factory which raw store factory it belongs to // since this is passed into the log factory for recovery // after the factories are loaded, recover the database - logFactory.recover(this, dataFactory, xactFactory); + logFactory.recover(dataFactory, xactFactory); // if user requested to encrpty an unecrypted database or encrypt with // new alogorithm then do that now. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java?rev=708510&r1=708509&r2=708510&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java Tue Oct 28 03:24:48 2008 @@ -409,7 +409,7 @@ private long logWrittenFromLastCheckPoint = 0; // keeps track of the amout of log written between checkpoints private RawStoreFactory rawStoreFactory; - // use this only after recovery is finished + // use this only when in slave mode or after recovery is finished protected DataFactory dataFactory; // use this only after revocery is finished @@ -644,6 +644,13 @@ } /** + Make log factory aware of which raw store factory it belongs to + */ + public void setRawStoreFactory(RawStoreFactory rsf) { + rawStoreFactory = rsf; + } + + /** Recover the rawStore to a consistent state using the log.

@@ -666,20 +673,17 @@ @exception StandardException Standard Derby error policy */ public void recover( - RawStoreFactory rsf, DataFactory df, TransactionFactory tf) throws StandardException { if (SanityManager.DEBUG) { - SanityManager.ASSERT(rsf != null, "raw store factory == null"); SanityManager.ASSERT(df != null, "data factory == null"); } checkCorrupt(); - rawStoreFactory = rsf; dataFactory = df; // initialize the log writer only after the rawstorefactory is available, @@ -889,7 +893,7 @@ // open a transaction that is used for redo and rollback RawTransaction recoveryTransaction = tf.startTransaction( - rsf, + rawStoreFactory, ContextService.getFactory().getCurrentContextManager(), AccessFactoryGlobals.USER_TRANS_NAME); @@ -1210,7 +1214,7 @@ "In recovery undo, rollback inflight transactions"); } - tf.rollbackAllTransactions(recoveryTransaction, rsf); + tf.rollbackAllTransactions(recoveryTransaction, rawStoreFactory); if (SanityManager.DEBUG) { @@ -1249,7 +1253,7 @@ tf.getTransactionTable()); } - tf.handlePreparedXacts(rsf); + tf.handlePreparedXacts(rawStoreFactory); if (SanityManager.DEBUG) { @@ -1301,7 +1305,7 @@ needCheckpoint = false; } - if (needCheckpoint && !checkpoint(rsf, df, tf, false)) + if (needCheckpoint && !checkpoint(rawStoreFactory, df, tf, false)) flush(logFileNumber, endPosition); } Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java?rev=708510&r1=708509&r2=708510&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java Tue Oct 28 03:24:48 2008 @@ -76,12 +76,15 @@ return null; } + /** Not applicable in readonly databases */ + public void setRawStoreFactory(RawStoreFactory rsf) { + } + /** MT - not needed, no work is done @exception StandardException Standard Derby Error Policy */ - public void recover(RawStoreFactory rawStoreFactory, - DataFactory dataFactory, + public void recover(DataFactory dataFactory, TransactionFactory transactionFactory) throws StandardException {