Search in sources :

Example 1 with NodeHealthScriptRunner

use of org.apache.hadoop.util.NodeHealthScriptRunner in project hadoop by apache.

the class TestNodeHealthService method testNodeHealthService.

@Test
public void testNodeHealthService() throws Exception {
    RecordFactory factory = RecordFactoryProvider.getRecordFactory(null);
    NodeHealthStatus healthStatus = factory.newRecordInstance(NodeHealthStatus.class);
    Configuration conf = getConfForNodeHealthScript();
    conf.writeXml(new FileOutputStream(nodeHealthConfigFile));
    conf.addResource(nodeHealthConfigFile.getName());
    writeNodeHealthScriptFile("", true);
    LocalDirsHandlerService dirsHandler = new LocalDirsHandlerService();
    NodeHealthScriptRunner nodeHealthScriptRunner = spy(NodeManager.getNodeHealthScriptRunner(conf));
    NodeHealthCheckerService nodeHealthChecker = new NodeHealthCheckerService(nodeHealthScriptRunner, dirsHandler);
    nodeHealthChecker.init(conf);
    doReturn(true).when(nodeHealthScriptRunner).isHealthy();
    doReturn("").when(nodeHealthScriptRunner).getHealthReport();
    setHealthStatus(healthStatus, nodeHealthChecker.isHealthy(), nodeHealthChecker.getHealthReport(), nodeHealthChecker.getLastHealthReportTime());
    LOG.info("Checking initial healthy condition");
    // Check proper report conditions.
    Assert.assertTrue("Node health status reported unhealthy", healthStatus.getIsNodeHealthy());
    Assert.assertTrue("Node health status reported unhealthy", healthStatus.getHealthReport().equals(nodeHealthChecker.getHealthReport()));
    doReturn(false).when(nodeHealthScriptRunner).isHealthy();
    // update health status
    setHealthStatus(healthStatus, nodeHealthChecker.isHealthy(), nodeHealthChecker.getHealthReport(), nodeHealthChecker.getLastHealthReportTime());
    LOG.info("Checking Healthy--->Unhealthy");
    Assert.assertFalse("Node health status reported healthy", healthStatus.getIsNodeHealthy());
    Assert.assertTrue("Node health status reported healthy", healthStatus.getHealthReport().equals(nodeHealthChecker.getHealthReport()));
    doReturn(true).when(nodeHealthScriptRunner).isHealthy();
    setHealthStatus(healthStatus, nodeHealthChecker.isHealthy(), nodeHealthChecker.getHealthReport(), nodeHealthChecker.getLastHealthReportTime());
    LOG.info("Checking UnHealthy--->healthy");
    // Check proper report conditions.
    Assert.assertTrue("Node health status reported unhealthy", healthStatus.getIsNodeHealthy());
    Assert.assertTrue("Node health status reported unhealthy", healthStatus.getHealthReport().equals(nodeHealthChecker.getHealthReport()));
    // Healthy to timeout transition.
    doReturn(false).when(nodeHealthScriptRunner).isHealthy();
    doReturn(NodeHealthScriptRunner.NODE_HEALTH_SCRIPT_TIMED_OUT_MSG).when(nodeHealthScriptRunner).getHealthReport();
    setHealthStatus(healthStatus, nodeHealthChecker.isHealthy(), nodeHealthChecker.getHealthReport(), nodeHealthChecker.getLastHealthReportTime());
    LOG.info("Checking Healthy--->timeout");
    Assert.assertFalse("Node health status reported healthy even after timeout", healthStatus.getIsNodeHealthy());
    Assert.assertTrue("Node script time out message not propagated", healthStatus.getHealthReport().equals(NodeHealthScriptRunner.NODE_HEALTH_SCRIPT_TIMED_OUT_MSG + NodeHealthCheckerService.SEPARATOR + nodeHealthChecker.getDiskHandler().getDisksHealthReport(false)));
}
Also used : RecordFactory(org.apache.hadoop.yarn.factories.RecordFactory) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) FileOutputStream(java.io.FileOutputStream) NodeHealthScriptRunner(org.apache.hadoop.util.NodeHealthScriptRunner) NodeHealthStatus(org.apache.hadoop.yarn.server.api.records.NodeHealthStatus) Test(org.junit.Test)

Example 2 with NodeHealthScriptRunner

use of org.apache.hadoop.util.NodeHealthScriptRunner in project hadoop by apache.

the class TestNMWebServer method createNodeHealthCheckerService.

private NodeHealthCheckerService createNodeHealthCheckerService(Configuration conf) {
    NodeHealthScriptRunner scriptRunner = NodeManager.getNodeHealthScriptRunner(conf);
    LocalDirsHandlerService dirsHandler = new LocalDirsHandlerService();
    return new NodeHealthCheckerService(scriptRunner, dirsHandler);
}
Also used : NodeHealthCheckerService(org.apache.hadoop.yarn.server.nodemanager.NodeHealthCheckerService) NodeHealthScriptRunner(org.apache.hadoop.util.NodeHealthScriptRunner) LocalDirsHandlerService(org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService)

Example 3 with NodeHealthScriptRunner

use of org.apache.hadoop.util.NodeHealthScriptRunner in project hadoop by apache.

the class TestContainerLogsPage method createNodeHealthCheckerService.

private NodeHealthCheckerService createNodeHealthCheckerService(Configuration conf) {
    NodeHealthScriptRunner scriptRunner = NodeManager.getNodeHealthScriptRunner(conf);
    LocalDirsHandlerService dirsHandler = new LocalDirsHandlerService();
    return new NodeHealthCheckerService(scriptRunner, dirsHandler);
}
Also used : NodeHealthCheckerService(org.apache.hadoop.yarn.server.nodemanager.NodeHealthCheckerService) NodeHealthScriptRunner(org.apache.hadoop.util.NodeHealthScriptRunner) LocalDirsHandlerService(org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService)

Aggregations

NodeHealthScriptRunner (org.apache.hadoop.util.NodeHealthScriptRunner)3 LocalDirsHandlerService (org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService)2 NodeHealthCheckerService (org.apache.hadoop.yarn.server.nodemanager.NodeHealthCheckerService)2 FileOutputStream (java.io.FileOutputStream)1 Configuration (org.apache.hadoop.conf.Configuration)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 RecordFactory (org.apache.hadoop.yarn.factories.RecordFactory)1 NodeHealthStatus (org.apache.hadoop.yarn.server.api.records.NodeHealthStatus)1 Test (org.junit.Test)1