|
From: <tho...@us...> - 2014-04-11 12:13:28
|
Revision: 8105
http://sourceforge.net/p/bigdata/code/8105
Author: thompsonbry
Date: 2014-04-11 12:13:24 +0000 (Fri, 11 Apr 2014)
Log Message:
-----------
Reconciled Martyn's edits and my own on the HA1/HA5 branch prior to merge in of delta from the main branch.
Modified Paths:
--------------
branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3BackupTestCase.java
branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3JournalServerTestCase.java
branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHAJournalServerTestCase.java
branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/TestHA1SnapshotPolicy.java
Modified: branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3BackupTestCase.java
===================================================================
--- branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3BackupTestCase.java 2014-04-11 11:43:06 UTC (rev 8104)
+++ branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3BackupTestCase.java 2014-04-11 12:13:24 UTC (rev 8105)
@@ -43,6 +43,7 @@
import com.bigdata.ha.msg.HARootBlockRequest;
import com.bigdata.journal.CommitCounterUtility;
import com.bigdata.journal.IHABufferStrategy;
+import com.bigdata.journal.IRootBlockView;
import com.bigdata.journal.Journal;
import com.bigdata.rdf.sail.webapp.client.ConnectOptions;
import com.bigdata.rdf.sail.webapp.client.RemoteRepository;
@@ -146,10 +147,12 @@
* The current commit counter on the server. This is the commit point
* that should be restored.
*/
- final long commitCounterM = serverA
- .getRootBlock(new HARootBlockRequest(null/* storeUUID */))
- .getRootBlock().getCommitCounter();
+
+ final IRootBlockView serverARootBlock = serverA.getRootBlock(
+ new HARootBlockRequest(null/* storeUUID */)).getRootBlock();
+ final long commitCounterM = serverARootBlock.getCommitCounter();
+
final File snapshotFile = SnapshotManager.getSnapshotFile(
getSnapshotDirA(), commitCounterN);
@@ -170,40 +173,26 @@
{
final Properties p = new Properties();
- final File aout = out.getAbsoluteFile();
- // log.warn(aout.toString() + " modified: " + aout.lastModified());
-
- p.setProperty(Journal.Options.FILE, aout.toString());
-
- Journal jnl = new Journal(p);
+ p.setProperty(Journal.Options.FILE, out.getAbsoluteFile()
+ .toString());
+
+ Journal jnl = new Journal(p);
+
try {
// Verify snapshot at the expected commit point.
assertEquals(commitCounterN, jnl.getRootBlockView()
.getCommitCounter());
-// {
-// final MessageDigest digest = MessageDigest
-// .getInstance("MD5");
-//
-// // digest of restored journal.
-// ((IHABufferStrategy) (jnl.getBufferStrategy()))
-// .computeDigest(null/* snapshot */, digest);
-//
-// final byte[] digest2 = digest.digest();
-//
-// System.err.println("Pre-restore: " + BytesUtil.toHexString(digest2));
-// }
// Verify journal can be dumped without error.
dumpJournal(jnl);
-
+
/*
* Now roll that journal forward using the HALog directory.
*/
final HARestore rest = new HARestore(jnl, getHALogDirA());
- // System.err.println("Prior: " + jnl.getRootBlockView().toString());
/*
* Note: We can not test where we stop at the specified
* commit point in this method because the Journal state on
@@ -212,7 +201,6 @@
*/
rest.restore(false/* listCommitPoints */, Long.MAX_VALUE/* haltingCommitCounter */);
- // System.err.println("Post: " + jnl.getRootBlockView().toString());
/*
* FIXME For some reason, we need to close and reopen the
* journal before it can be used. See HARestore.
@@ -224,12 +212,18 @@
jnl = new Journal(p);
}
- // System.err.println("Post reopen: " + jnl.getRootBlockView().toString());
+ // Verify can dump journal after restore.
+ dumpJournal(jnl);
- // Verify journal now at the expected commit point.
+ // Verify journal now at the expected commit point.
assertEquals(commitCounterM, jnl.getRootBlockView()
.getCommitCounter());
+ if (!serverARootBlock.equals(jnl.getRootBlockView())) {
+ fail("Root blocks differ: serverA=" + serverARootBlock
+ + ", restored=" + jnl.getRootBlockView());
+ }
+
/*
* Compute digest of the restored journal. The digest should
* agree with the digest of the Journal on A since we rolled
@@ -242,14 +236,17 @@
new HADigestRequest(null/* storeUUID */))
.getDigest();
- final MessageDigest digest = MessageDigest
- .getInstance("MD5");
+ final byte[] digest2;
+ {
+ final MessageDigest digest = MessageDigest
+ .getInstance("MD5");
- // digest of restored journal.
- ((IHABufferStrategy) (jnl.getBufferStrategy()))
- .computeDigest(null/* snapshot */, digest);
+ // digest of restored journal.
+ ((IHABufferStrategy) (jnl.getBufferStrategy()))
+ .computeDigest(null/* snapshot */, digest);
- final byte[] digest2 = digest.digest();
+ digest2 = digest.digest();
+ }
if (!BytesUtil.bytesEqual(digestA, digest2)) {
@@ -259,19 +256,13 @@
final String digest2Str = new BigInteger(1, digest2)
.toString(16);
- System.err.println("Original: " + serverA.getRootBlock(new HARootBlockRequest(null)).getRootBlock().toString());
- System.err.println("Restored: " + jnl.getRootBlockView().toString());
-
fail("Digests differ after restore and replay: expected="
+ digestAStr + ", actual=" + digest2Str);
-
+
}
}
- // Verify can dump journal after restore.
- dumpJournal(jnl);
-
} finally {
if (jnl != null) {
Modified: branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3JournalServerTestCase.java
===================================================================
--- branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3JournalServerTestCase.java 2014-04-11 11:43:06 UTC (rev 8104)
+++ branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3JournalServerTestCase.java 2014-04-11 12:13:24 UTC (rev 8105)
@@ -227,7 +227,7 @@
/**
* {@link UUID}s for the {@link HAJournalServer}s.
*/
- protected UUID serverAId = UUID.randomUUID();
+ private UUID serverAId = UUID.randomUUID();
private UUID serverBId = UUID.randomUUID();
Modified: branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHAJournalServerTestCase.java
===================================================================
--- branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHAJournalServerTestCase.java 2014-04-11 11:43:06 UTC (rev 8104)
+++ branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHAJournalServerTestCase.java 2014-04-11 12:13:24 UTC (rev 8105)
@@ -970,7 +970,7 @@
* Verify the the digest of the journal is equal to the digest of the
* indicated snapshot on the specified service.
* <p>
- * Note: This can only succeed if the journal is at the specififed commit
+ * Note: This can only succeed if the journal is at the specified commit
* point. If there are concurrent writes on the journal, then it's digest
* will no longer be consistent with the snapshot.
*
Modified: branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/TestHA1SnapshotPolicy.java
===================================================================
--- branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/TestHA1SnapshotPolicy.java 2014-04-11 11:43:06 UTC (rev 8104)
+++ branches/BIGDATA_MGC_HA1_HA5/bigdata-jini/src/test/com/bigdata/journal/jini/ha/TestHA1SnapshotPolicy.java 2014-04-11 12:13:24 UTC (rev 8105)
@@ -17,6 +17,10 @@
import com.bigdata.journal.Journal;
import com.bigdata.rdf.sail.webapp.client.RemoteRepository;
+/**
+ * Test suite for the restore of the HA1 Journal from a snapshot and transaction
+ * logs.
+ */
public class TestHA1SnapshotPolicy extends AbstractHA3BackupTestCase {
public TestHA1SnapshotPolicy() {
@@ -437,8 +441,8 @@
*/
public void testA_snapshot_multipleTx_restore_validate() throws Exception {
- final int N1 = 7; //7; // #of transactions to run before the snapshot.
- final int N2 = 8; //8; // #of transactions to run after the snapshot.
+ final int N1 = 7; // #of transactions to run before the snapshot.
+ final int N2 = 8; // #of transactions to run after the snapshot.
// Start service.
final HAGlue serverA = startA();
@@ -458,13 +462,13 @@
// Now run N transactions.
for (int i = 0; i < N1; i++) {
+
+ simpleTransaction();
- simpleTransaction();
-
}
-
- final long commitCounterN1 = N1 + 1;
+ final long commitCounterN1 = N1 + 1;
+
awaitCommitCounter(commitCounterN1, serverA);
/*
@@ -477,7 +481,7 @@
// Snapshot directory is empty.
assertEquals(1, recursiveCount(getSnapshotDirA(),SnapshotManager.SNAPSHOT_FILTER));
-
+
// request snapshot on A.
final Future<IHASnapshotResponse> ft = serverA
.takeSnapshot(new HASnapshotRequest(0/* percentLogSize */));
@@ -503,6 +507,19 @@
}
+ {
+ // Snapshot directory contains just the expected snapshot
+ assertExpectedSnapshots(getSnapshotDirA(),
+ new long[] { commitCounterN1 });
+
+ /*
+ * Now, get the snapshot that we took above, decompress it, and then
+ * roll it forward and verify it against the current committed
+ * journal.
+ */
+ doRestoreA(serverA, commitCounterN1);
+ }
+
// Now run M transactions.
for (int i = 0; i < N2; i++) {
@@ -514,7 +531,6 @@
awaitCommitCounter(commitCounterN2, serverA);
-
// Snapshot directory contains just the expected snapshot
assertExpectedSnapshots(getSnapshotDirA(), new long[]{commitCounterN1});
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|