Search in sources :

Example 6 with ClientProtocol

use of org.apache.hadoop.mapreduce.protocol.ClientProtocol in project hadoop by apache.

the class TestJob method testUnexpectedJobStatus.

@Test
public void testUnexpectedJobStatus() throws Exception {
    Cluster cluster = mock(Cluster.class);
    JobID jobid = new JobID("1014873536921", 6);
    ClientProtocol clientProtocol = mock(ClientProtocol.class);
    when(cluster.getClient()).thenReturn(clientProtocol);
    JobStatus status = new JobStatus(jobid, 0f, 0f, 0f, 0f, State.RUNNING, JobPriority.DEFAULT, "root", "testUnexpectedJobStatus", "job file", "tracking URL");
    when(clientProtocol.getJobStatus(jobid)).thenReturn(status);
    Job job = Job.getInstance(cluster, status, new JobConf());
    // ensurer job status is RUNNING
    Assert.assertNotNull(job.getStatus());
    Assert.assertTrue(job.getStatus().getState() == State.RUNNING);
    // when updating job status, job client could not retrieve
    // job status, and status reset to null
    when(clientProtocol.getJobStatus(jobid)).thenReturn(null);
    try {
        job.updateStatus();
    } catch (IOException e) {
        Assert.assertTrue(e != null && e.getMessage().contains("Job status not available"));
    }
    try {
        ControlledJob cj = new ControlledJob(job, null);
        Assert.assertNotNull(cj.toString());
    } catch (NullPointerException e) {
        Assert.fail("job API fails with NPE");
    }
}
Also used : IOException(java.io.IOException) ClientProtocol(org.apache.hadoop.mapreduce.protocol.ClientProtocol) ControlledJob(org.apache.hadoop.mapreduce.lib.jobcontrol.ControlledJob) ControlledJob(org.apache.hadoop.mapreduce.lib.jobcontrol.ControlledJob) JobConf(org.apache.hadoop.mapred.JobConf) Test(org.junit.Test)

Example 7 with ClientProtocol

use of org.apache.hadoop.mapreduce.protocol.ClientProtocol in project hadoop by apache.

the class TestYarnClientProtocolProvider method testClusterWithYarnClientProtocolProvider.

@Test
public void testClusterWithYarnClientProtocolProvider() throws Exception {
    Configuration conf = new Configuration(false);
    Cluster cluster = null;
    try {
        cluster = new Cluster(conf);
    } catch (Exception e) {
        throw new Exception("Failed to initialize a local runner w/o a cluster framework key", e);
    }
    try {
        assertTrue("client is not a LocalJobRunner", cluster.getClient() instanceof LocalJobRunner);
    } finally {
        if (cluster != null) {
            cluster.close();
        }
    }
    try {
        conf = new Configuration();
        conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);
        cluster = new Cluster(conf);
        ClientProtocol client = cluster.getClient();
        assertTrue("client is a YARNRunner", client instanceof YARNRunner);
    } catch (IOException e) {
    } finally {
        if (cluster != null) {
            cluster.close();
        }
    }
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YARNRunner(org.apache.hadoop.mapred.YARNRunner) IOException(java.io.IOException) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol) ClientProtocol(org.apache.hadoop.mapreduce.protocol.ClientProtocol) IOException(java.io.IOException) LocalJobRunner(org.apache.hadoop.mapred.LocalJobRunner) Test(org.junit.Test)

Aggregations

ClientProtocol (org.apache.hadoop.mapreduce.protocol.ClientProtocol)7 IOException (java.io.IOException)4 Test (org.junit.Test)3 Configuration (org.apache.hadoop.conf.Configuration)2 JobConf (org.apache.hadoop.mapred.JobConf)2 JobID (org.apache.hadoop.mapreduce.JobID)2 ControlledJob (org.apache.hadoop.mapreduce.lib.jobcontrol.ControlledJob)2 IgniteHadoopClientProtocolProvider (org.apache.ignite.hadoop.mapreduce.IgniteHadoopClientProtocolProvider)2 FileNotFoundException (java.io.FileNotFoundException)1 LocalJobRunner (org.apache.hadoop.mapred.LocalJobRunner)1 YARNRunner (org.apache.hadoop.mapred.YARNRunner)1 ClientProtocolProvider (org.apache.hadoop.mapreduce.protocol.ClientProtocolProvider)1 ApplicationClientProtocol (org.apache.hadoop.yarn.api.ApplicationClientProtocol)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 Before (org.junit.Before)1