You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by jo...@apache.org on 2008/10/28 11:24:55 UTC
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
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.
<P>
@@ -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
{