Example usage for org.apache.hadoop.mapred MiniMRCluster waitUntilIdle

List of usage examples for org.apache.hadoop.mapred MiniMRCluster waitUntilIdle

Introduction

In this page you can find the example usage for org.apache.hadoop.mapred MiniMRCluster waitUntilIdle.

Prototype

public void waitUntilIdle() 

Source Link

Usage

From source file:org.apache.ambari.servicemonitor.unit.JTClusterStatusProbeTest.java

License:Apache License

/**
 * Test the cluster status probe//from   www  .  java  2 s .c om
 * @throws Throwable
 */
@Test
public void testProbeMiniNN() throws Throwable {
    createDFSCluster();
    MiniMRCluster miniMRCluster = createMRCluster();
    JobConf conf = new JobConf();
    //once the cluster is up 
    miniMRCluster.waitUntilIdle();
    int port = miniMRCluster.getJobTrackerPort();
    assertTrue("MiniMR Cluster port not yet set, current value" + port, port > 0);
    injectMRClusterEntry(conf, miniMRCluster);
    Probe probe = new JTClusterStatusProbe(conf);
    probe.init();
    int startupShutdownTime = NN_STARTUP_SHUTDOWN_TIME;
    SleepTimer sleepTimer = new SleepTimer(100, startupShutdownTime);
    ProbeStatus status;
    do {
        status = probe.ping(true);
    } while (!status.isSuccess() && sleepTimer.sleep());
    assertSuccess(status);
    //now up, kill the cluster
    destroyMRCluster();
    //now spin waiting for the cluster to die

    log.info("Starting ping cycle waiting for cluster shutdown");
    do {
        status = probe.ping(true);
        log.info("Ping outcome: " + status);
    } while (status.isSuccess() && sleepTimer.sleep());
    //here the NN should have failed
    assertFailure(status);
}

From source file:org.apache.ambari.servicemonitor.unit.JTSafeModeProbeTest.java

License:Apache License

@Test
public void testProbeMiniNN() throws Throwable {
    createDFSCluster();/*from   w w w. j ava2 s .c o m*/
    MiniMRCluster miniMRCluster = createMRCluster();
    JobConf conf = new JobConf();
    //once the cluster is up 
    miniMRCluster.waitUntilIdle();
    int port = miniMRCluster.getJobTrackerPort();
    assertTrue("MiniMR Cluster port not yet set, current value" + port, port > 0);
    injectMRClusterEntry(conf, miniMRCluster);
    JTSafeModeProbe probe = new JTSafeModeProbe(conf);
    probe.init();
    int startupShutdownTime = NN_STARTUP_SHUTDOWN_TIME;
    SleepTimer sleepTimer = new SleepTimer(100, startupShutdownTime);
    ProbeStatus status;
    do {
        status = probe.ping(true);
    } while (!status.isSuccess() && sleepTimer.sleep());
    assertSuccess(status);
    //now up, kill the cluster
    destroyMRCluster();
    //now spin waiting for the cluster to die

    log.info("Starting ping cycle waiting for cluster shutdown");
    do {
        status = probe.ping(true);
        log.info("Ping outcome: " + status);
    } while (status.isSuccess() && sleepTimer.sleep());
    //here the NN should have failed
    assertFailure(status);
}