conf.setInt(JournalConfigKeys.DFS_QJOURNAL_WRITE_TXNS_TIMEOUT_KEY,
WRITE_TXID_TIMEOUT);
setUp(conf, null, "testJournalNodeHang");
// Get the current journal port.
JournalNode jn = getStandbyTailingJN();
DFSTestUtil.createFile(fs, new Path("/test"), 1024, (short) 1, 0);
handler.simulateJournalHang = true;
// Ensure we can still write.
DFSTestUtil.createFile(fs, new Path("/test1"), 1024, (short) 1, 0);
// Ensure we can still do checkpoints.
handler.doCheckpoint();
DFSTestUtil.createFile(fs, new Path("/test2"), 1024, (short) 1, 0);
// Verify the JN is lagging.
assertFalse(cluster.getPrimaryAvatar(0).avatar.getLastWrittenTxId() == jn
.getJournal((MiniAvatarCluster.JID + "/zero").getBytes())
.getHighestWrittenTxId());
// Ensure we can failover.
cluster.failOver();
cluster.restartStandby();
// Ensure we can write after failover.
DFSTestUtil.createFile(fs, new Path("/test3"), 1024, (short) 1, 0);
// Ensure we can still do checkpoints.
handler.doCheckpoint();
// Ensure that we did end up hanging a journal node.
DFSTestUtil.createFile(fs, new Path("/test4"), 1024, (short) 1, 0);
assertTrue(handler.journalFailures > 0);
assertFalse(cluster.getPrimaryAvatar(0).avatar.getLastWrittenTxId() == jn
.getJournal((MiniAvatarCluster.JID + "/one").getBytes())
.getHighestWrittenTxId());
handler.simulateJournalHang = false;
}