Search in sources :

Example 1 with MockNameNodeResourceChecker

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

the class TestDFSZKFailoverController method testThreadDumpCaptureAfterNNStateChange.

/**
   * Test that thread dump is captured after NN state changes.
   */
@Test(timeout = 60000)
public void testThreadDumpCaptureAfterNNStateChange() throws Exception {
    MockNameNodeResourceChecker mockResourceChecker = new MockNameNodeResourceChecker(conf);
    mockResourceChecker.setResourcesAvailable(false);
    cluster.getNameNode(0).getNamesystem().setNNResourceChecker(mockResourceChecker);
    waitForHAState(0, HAServiceState.STANDBY);
    while (!thr1.zkfc.isThreadDumpCaptured()) {
        Thread.sleep(1000);
    }
}
Also used : MockNameNodeResourceChecker(org.apache.hadoop.hdfs.server.namenode.MockNameNodeResourceChecker) Test(org.junit.Test)

Example 2 with MockNameNodeResourceChecker

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

the class TestNNHealthCheck method doNNHealthCheckTest.

private void doNNHealthCheckTest() throws IOException {
    MockNameNodeResourceChecker mockResourceChecker = new MockNameNodeResourceChecker(conf);
    cluster.getNameNode(0).getNamesystem().setNNResourceChecker(mockResourceChecker);
    NNHAServiceTarget haTarget = new NNHAServiceTarget(conf, DFSUtil.getNamenodeNameServiceId(conf), "nn1");
    final String expectedTargetString;
    if (conf.get(DFS_NAMENODE_LIFELINE_RPC_ADDRESS_KEY + "." + DFSUtil.getNamenodeNameServiceId(conf) + ".nn1") != null) {
        expectedTargetString = haTarget.getHealthMonitorAddress().toString();
    } else {
        expectedTargetString = haTarget.getAddress().toString();
    }
    assertTrue("Expected haTarget " + haTarget + " containing " + expectedTargetString, haTarget.toString().contains(expectedTargetString));
    HAServiceProtocol rpc = haTarget.getHealthMonitorProxy(conf, conf.getInt(HA_HM_RPC_TIMEOUT_KEY, HA_HM_RPC_TIMEOUT_DEFAULT));
    // Should not throw error, which indicates healthy.
    rpc.monitorHealth();
    mockResourceChecker.setResourcesAvailable(false);
    try {
        // Should throw error - NN is unhealthy.
        rpc.monitorHealth();
        fail("Should not have succeeded in calling monitorHealth");
    } catch (HealthCheckFailedException hcfe) {
        GenericTestUtils.assertExceptionContains("The NameNode has no resources available", hcfe);
    } catch (RemoteException re) {
        GenericTestUtils.assertExceptionContains("The NameNode has no resources available", re.unwrapRemoteException(HealthCheckFailedException.class));
    }
}
Also used : MockNameNodeResourceChecker(org.apache.hadoop.hdfs.server.namenode.MockNameNodeResourceChecker) HAServiceProtocol(org.apache.hadoop.ha.HAServiceProtocol) NNHAServiceTarget(org.apache.hadoop.hdfs.tools.NNHAServiceTarget) RemoteException(org.apache.hadoop.ipc.RemoteException) HealthCheckFailedException(org.apache.hadoop.ha.HealthCheckFailedException)

Aggregations

MockNameNodeResourceChecker (org.apache.hadoop.hdfs.server.namenode.MockNameNodeResourceChecker)2 HAServiceProtocol (org.apache.hadoop.ha.HAServiceProtocol)1 HealthCheckFailedException (org.apache.hadoop.ha.HealthCheckFailedException)1 NNHAServiceTarget (org.apache.hadoop.hdfs.tools.NNHAServiceTarget)1 RemoteException (org.apache.hadoop.ipc.RemoteException)1 Test (org.junit.Test)1