ZanderXu commented on code in PR #4518:
URL: https://github.com/apache/hadoop/pull/4518#discussion_r930567622
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/server/TestJournal.java:
##########
@@ -535,4 +538,43 @@ public void
testFormatNonEmptyStorageDirectoriesWhenforceOptionIsTrue()
fail("Format should be success with force option.");
}
}
+
+ @Test
+ public void testMultiInProgressSegment() throws Exception {
+ journal.newEpoch(FAKE_NSINFO, 1);
+
+ // Start a segment at txid 1, and write a batch of 3 txns.
+ journal.startLogSegment(makeRI(1), 1,
+ NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION);
+ journal.journal(makeRI(2), 1, 1, 3,
+ QJMTestUtil.createTxnData(1, 3));
+
+ GenericTestUtils.assertExists(
+ journal.getStorage().getInProgressEditLog(1));
+
+ // Try to start new segment at txid 6, this should abort old segment and
+ // then succeed, allowing us to write txid 6-9.
+ journal.startLogSegment(makeRI(3), 6,
+ NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION);
+ journal.journal(makeRI(4), 6, 6, 3,
+ QJMTestUtil.createTxnData(6, 3));
+
+ // The old segment should *not* be finalized.
+ GenericTestUtils.assertExists(
+ journal.getStorage().getInProgressEditLog(1));
+ GenericTestUtils.assertExists(
+ journal.getStorage().getInProgressEditLog(6));
+
+ try {
+ RemoteEditLogManifest remoteEditLogManifest =
+ journal.getEditLogManifest(1, true);
+ assertNotNull(remoteEditLogManifest);
+ assertEquals(1, remoteEditLogManifest.getLogs().size());
+ RemoteEditLog remoteEditLog = remoteEditLogManifest.getLogs().get(0);
+ assertTrue(remoteEditLog.isInProgress());
+ assertEquals(6, remoteEditLog.getStartTxId());
+ } catch (IOException e) {
+ fail();
+ }
Review Comment:
@jojochuang Thanks for your review. I have remove it in the latest patch.
Please help me review it again. Thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]