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");
}
}
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();
}
}
}
Aggregations