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

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

Introduction

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

Prototype

public int getJobTrackerPort() 

Source Link

Usage

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

License:Apache License

/**
 * Get the configuration entry for job trackers in a miniMR cluster
 * @param miniMRCluster the mini mr cluster
 * @return the "localhost:port" string used to point to the JT
 *//*from www. j a va2s . co  m*/
protected String getMRClusterConfEntry(MiniMRCluster miniMRCluster) {
    return "localhost:" + miniMRCluster.getJobTrackerPort();
}

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

License:Apache License

/**
 * Test the cluster status probe/* w w w  . jav  a2 s . c o m*/
 * @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();//w  ww  .j  a v a 2  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);
}