Search in sources :

Example 1 with CheckpointSignature

use of org.apache.hadoop.hdfs.server.namenode.CheckpointSignature in project hadoop by apache.

the class TestPBHelper method testConvertCheckpointSignature.

@Test
public void testConvertCheckpointSignature() {
    CheckpointSignature s = new CheckpointSignature(getStorageInfo(NodeType.NAME_NODE), "bpid", 100, 1);
    CheckpointSignatureProto sProto = PBHelper.convert(s);
    CheckpointSignature s1 = PBHelper.convert(sProto);
    assertEquals(s.getBlockpoolID(), s1.getBlockpoolID());
    assertEquals(s.getClusterID(), s1.getClusterID());
    assertEquals(s.getCTime(), s1.getCTime());
    assertEquals(s.getCurSegmentTxId(), s1.getCurSegmentTxId());
    assertEquals(s.getLayoutVersion(), s1.getLayoutVersion());
    assertEquals(s.getMostRecentCheckpointTxId(), s1.getMostRecentCheckpointTxId());
    assertEquals(s.getNamespaceID(), s1.getNamespaceID());
}
Also used : CheckpointSignatureProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.CheckpointSignatureProto) CheckpointSignature(org.apache.hadoop.hdfs.server.namenode.CheckpointSignature) Test(org.junit.Test)

Example 2 with CheckpointSignature

use of org.apache.hadoop.hdfs.server.namenode.CheckpointSignature in project hadoop by apache.

the class TestBootstrapStandby method testSharedEditsMissingLogs.

/**
   * Test for the case where the shared edits dir doesn't have
   * all of the recent edit logs.
   */
@Test
public void testSharedEditsMissingLogs() throws Exception {
    removeStandbyNameDirs();
    CheckpointSignature sig = nn0.getRpcServer().rollEditLog();
    assertEquals(3, sig.getCurSegmentTxId());
    // Should have created edits_1-2 in shared edits dir
    URI editsUri = cluster.getSharedEditsDir(0, maxNNCount - 1);
    File editsDir = new File(editsUri);
    File currentDir = new File(editsDir, "current");
    File editsSegment = new File(currentDir, NNStorage.getFinalizedEditsFileName(1, 2));
    GenericTestUtils.assertExists(editsSegment);
    GenericTestUtils.assertExists(currentDir);
    // Delete the segment.
    assertTrue(editsSegment.delete());
    // Trying to bootstrap standby should now fail since the edit
    // logs aren't available in the shared dir.
    LogCapturer logs = GenericTestUtils.LogCapturer.captureLogs(LogFactory.getLog(BootstrapStandby.class));
    try {
        assertEquals(BootstrapStandby.ERR_CODE_LOGS_UNAVAILABLE, forceBootstrap(1));
    } finally {
        logs.stopCapturing();
    }
    GenericTestUtils.assertMatches(logs.getOutput(), "FATAL.*Unable to read transaction ids 1-3 from the configured shared");
}
Also used : LogCapturer(org.apache.hadoop.test.GenericTestUtils.LogCapturer) URI(java.net.URI) File(java.io.File) CheckpointSignature(org.apache.hadoop.hdfs.server.namenode.CheckpointSignature) Test(org.junit.Test)

Aggregations

CheckpointSignature (org.apache.hadoop.hdfs.server.namenode.CheckpointSignature)2 Test (org.junit.Test)2 File (java.io.File)1 URI (java.net.URI)1 CheckpointSignatureProto (org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.CheckpointSignatureProto)1 LogCapturer (org.apache.hadoop.test.GenericTestUtils.LogCapturer)1