Search in sources :

Example 6 with NewEpochResponseProto

use of org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos.NewEpochResponseProto in project hadoop by apache.

the class TestJournal method testEpochHandling.

@Test(timeout = 10000)
public void testEpochHandling() throws Exception {
    assertEquals(0, journal.getLastPromisedEpoch());
    NewEpochResponseProto newEpoch = journal.newEpoch(FAKE_NSINFO, 1);
    assertFalse(newEpoch.hasLastSegmentTxId());
    assertEquals(1, journal.getLastPromisedEpoch());
    journal.newEpoch(FAKE_NSINFO, 3);
    assertFalse(newEpoch.hasLastSegmentTxId());
    assertEquals(3, journal.getLastPromisedEpoch());
    try {
        journal.newEpoch(FAKE_NSINFO, 3);
        fail("Should have failed to promise same epoch twice");
    } catch (IOException ioe) {
        GenericTestUtils.assertExceptionContains("Proposed epoch 3 <= last promise 3", ioe);
    }
    try {
        journal.startLogSegment(makeRI(1), 12345L, NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION);
        fail("Should have rejected call from prior epoch");
    } catch (IOException ioe) {
        GenericTestUtils.assertExceptionContains("epoch 1 is less than the last promised epoch 3", ioe);
    }
    try {
        journal.journal(makeRI(1), 12345L, 100L, 0, new byte[0]);
        fail("Should have rejected call from prior epoch");
    } catch (IOException ioe) {
        GenericTestUtils.assertExceptionContains("epoch 1 is less than the last promised epoch 3", ioe);
    }
}
Also used : NewEpochResponseProto(org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos.NewEpochResponseProto) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

NewEpochResponseProto (org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos.NewEpochResponseProto)6 Test (org.junit.Test)3 IOException (java.io.IOException)2 GetJournalStateResponseProto (org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocolProtos.GetJournalStateResponseProto)1 EditLogFile (org.apache.hadoop.hdfs.server.namenode.FileJournalManager.EditLogFile)1