MAPREDUCE-3479. JobClient#getJob cannot find local jobs.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1209791 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6b2cbe1198
commit
72e9ec7a45
|
@ -226,6 +226,8 @@ Release 0.23.1 - Unreleased
|
|||
MAPREDUCE-3453. RM web ui application details page shows RM cluster about
|
||||
information. (Jonathan Eagles via sseth)
|
||||
|
||||
MAPREDUCE-3479. JobClient#getJob cannot find local jobs. (tomwhite)
|
||||
|
||||
Release 0.23.0 - 2011-11-01
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.mapred;
|
||||
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestJobClientGetJob {
|
||||
|
||||
private static Path TEST_ROOT_DIR =
|
||||
new Path(System.getProperty("test.build.data","/tmp"));
|
||||
|
||||
private Path createTempFile(String filename, String contents)
|
||||
throws IOException {
|
||||
Path path = new Path(TEST_ROOT_DIR, filename);
|
||||
Configuration conf = new Configuration();
|
||||
FSDataOutputStream os = FileSystem.getLocal(conf).create(path);
|
||||
os.writeBytes(contents);
|
||||
os.close();
|
||||
return path;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testGetRunningJobFromJobClient() throws Exception {
|
||||
JobConf conf = new JobConf();
|
||||
conf.set("mapreduce.framework.name", "local");
|
||||
FileInputFormat.addInputPath(conf, createTempFile("in", "hello"));
|
||||
FileOutputFormat.setOutputPath(conf,
|
||||
new Path(TEST_ROOT_DIR, getClass().getSimpleName()));
|
||||
JobClient jc = new JobClient(conf);
|
||||
RunningJob runningJob = jc.submitJob(conf);
|
||||
assertNotNull("Running job", runningJob);
|
||||
// Check that the running job can be retrieved by ID
|
||||
RunningJob newRunningJob = jc.getJob(runningJob.getID());
|
||||
assertNotNull("New running job", newRunningJob);
|
||||
}
|
||||
|
||||
}
|
|
@ -584,6 +584,10 @@ public class JobClient extends CLI {
|
|||
return job;
|
||||
}
|
||||
});
|
||||
// update our Cluster instance with the one created by Job for submission
|
||||
// (we can't pass our Cluster instance to Job, since Job wraps the config
|
||||
// instance, and the two configs would then diverge)
|
||||
cluster = job.getCluster();
|
||||
return new NetworkedJob(job);
|
||||
} catch (InterruptedException ie) {
|
||||
throw new IOException("interrupted", ie);
|
||||
|
|
|
@ -436,6 +436,11 @@ public class Job extends JobContextImpl implements JobContext {
|
|||
updateStatus();
|
||||
return status.isRetired();
|
||||
}
|
||||
|
||||
@Private
|
||||
public Cluster getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
/** Only for mocks in unit tests. */
|
||||
@Private
|
||||
|
|
Loading…
Reference in New Issue