MAPREDUCE-4424. 'mapred job -list' command should show the job name as well. Contributed by Avinash Kujur.
This commit is contained in:
parent
978ef11f26
commit
8041267f02
|
@ -9,6 +9,9 @@ Trunk (Unreleased)
|
||||||
MAPREDUCE-5653. DistCp does not honour config-overrides for
|
MAPREDUCE-5653. DistCp does not honour config-overrides for
|
||||||
mapreduce.[map,reduce].memory.mb (Ratandeep Ratti via aw)
|
mapreduce.[map,reduce].memory.mb (Ratandeep Ratti via aw)
|
||||||
|
|
||||||
|
MAPREDUCE-4424. 'mapred job -list' command should show the job name
|
||||||
|
as well. (Avinash Kujur via aajisaka)
|
||||||
|
|
||||||
NEW FEATURES
|
NEW FEATURES
|
||||||
|
|
||||||
MAPREDUCE-778. Rumen Anonymizer. (Amar Kamat and Chris Douglas via amarrk)
|
MAPREDUCE-778. Rumen Anonymizer. (Amar Kamat and Chris Douglas via amarrk)
|
||||||
|
|
|
@ -616,17 +616,19 @@ public class CLI extends Configured implements Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Private
|
@Private
|
||||||
public static String headerPattern = "%23s\t%10s\t%14s\t%12s\t%12s\t%10s\t%15s\t%15s\t%8s\t%8s\t%10s\t%10s\n";
|
public static String headerPattern = "%23s\t%20s\t%10s\t%14s\t%12s\t%12s" +
|
||||||
|
"\t%10s\t%15s\t%15s\t%8s\t%8s\t%10s\t%10s\n";
|
||||||
@Private
|
@Private
|
||||||
public static String dataPattern = "%23s\t%10s\t%14d\t%12s\t%12s\t%10s\t%15s\t%15s\t%8s\t%8s\t%10s\t%10s\n";
|
public static String dataPattern = "%23s\t%20s\t%10s\t%14d\t%12s\t%12s" +
|
||||||
|
"\t%10s\t%15s\t%15s\t%8s\t%8s\t%10s\t%10s\n";
|
||||||
private static String memPattern = "%dM";
|
private static String memPattern = "%dM";
|
||||||
private static String UNAVAILABLE = "N/A";
|
private static String UNAVAILABLE = "N/A";
|
||||||
|
|
||||||
@Private
|
@Private
|
||||||
public void displayJobList(JobStatus[] jobs, PrintWriter writer) {
|
public void displayJobList(JobStatus[] jobs, PrintWriter writer) {
|
||||||
writer.println("Total jobs:" + jobs.length);
|
writer.println("Total jobs:" + jobs.length);
|
||||||
writer.printf(headerPattern, "JobId", "State", "StartTime", "UserName",
|
writer.printf(headerPattern, "JobId", "JobName", "State", "StartTime",
|
||||||
"Queue", "Priority", "UsedContainers",
|
"UserName", "Queue", "Priority", "UsedContainers",
|
||||||
"RsvdContainers", "UsedMem", "RsvdMem", "NeededMem", "AM info");
|
"RsvdContainers", "UsedMem", "RsvdMem", "NeededMem", "AM info");
|
||||||
for (JobStatus job : jobs) {
|
for (JobStatus job : jobs) {
|
||||||
int numUsedSlots = job.getNumUsedSlots();
|
int numUsedSlots = job.getNumUsedSlots();
|
||||||
|
@ -634,10 +636,11 @@ public class CLI extends Configured implements Tool {
|
||||||
int usedMem = job.getUsedMem();
|
int usedMem = job.getUsedMem();
|
||||||
int rsvdMem = job.getReservedMem();
|
int rsvdMem = job.getReservedMem();
|
||||||
int neededMem = job.getNeededMem();
|
int neededMem = job.getNeededMem();
|
||||||
writer.printf(dataPattern,
|
int jobNameLength = job.getJobName().length();
|
||||||
job.getJobID().toString(), job.getState(), job.getStartTime(),
|
writer.printf(dataPattern, job.getJobID().toString(),
|
||||||
job.getUsername(), job.getQueue(),
|
job.getJobName().substring(0, jobNameLength > 20 ? 20 : jobNameLength),
|
||||||
job.getPriority().name(),
|
job.getState(), job.getStartTime(), job.getUsername(),
|
||||||
|
job.getQueue(), job.getPriority().name(),
|
||||||
numUsedSlots < 0 ? UNAVAILABLE : numUsedSlots,
|
numUsedSlots < 0 ? UNAVAILABLE : numUsedSlots,
|
||||||
numReservedSlots < 0 ? UNAVAILABLE : numReservedSlots,
|
numReservedSlots < 0 ? UNAVAILABLE : numReservedSlots,
|
||||||
usedMem < 0 ? UNAVAILABLE : String.format(memPattern, usedMem),
|
usedMem < 0 ? UNAVAILABLE : String.format(memPattern, usedMem),
|
||||||
|
|
|
@ -531,6 +531,49 @@ public class TestMRJobClient extends ClusterMapReduceTestCase {
|
||||||
verifyJobPriority(jobId, "NORMAL", conf, createJobClient());
|
verifyJobPriority(jobId, "NORMAL", conf, createJobClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test -list option displays job name.
|
||||||
|
* The name is capped to 20 characters for display.
|
||||||
|
*/
|
||||||
|
public void testJobName() throws Exception {
|
||||||
|
Configuration conf = createJobConf();
|
||||||
|
CLI jc = createJobClient();
|
||||||
|
Job job = MapReduceTestUtil.createJob(conf, getInputDir(), getOutputDir(),
|
||||||
|
1, 1, "short_name");
|
||||||
|
job.setJobName("mapreduce");
|
||||||
|
job.setPriority(JobPriority.NORMAL);
|
||||||
|
job.waitForCompletion(true);
|
||||||
|
String jobId = job.getJobID().toString();
|
||||||
|
verifyJobName(jobId, "mapreduce", conf, jc);
|
||||||
|
Job job2 = MapReduceTestUtil.createJob(conf, getInputDir(), getOutputDir(),
|
||||||
|
1, 1, "long_name");
|
||||||
|
job2.setJobName("mapreduce_job_with_long_name");
|
||||||
|
job2.setPriority(JobPriority.NORMAL);
|
||||||
|
job2.waitForCompletion(true);
|
||||||
|
jobId = job2.getJobID().toString();
|
||||||
|
verifyJobName(jobId, "mapreduce_job_with_l", conf, jc);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void verifyJobName(String jobId, String name,
|
||||||
|
Configuration conf, CLI jc) throws Exception {
|
||||||
|
PipedInputStream pis = new PipedInputStream();
|
||||||
|
PipedOutputStream pos = new PipedOutputStream(pis);
|
||||||
|
int exitCode = runTool(conf, jc,
|
||||||
|
new String[] { "-list", "all" }, pos);
|
||||||
|
assertEquals("Exit code", 0, exitCode);
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(pis));
|
||||||
|
String line = null;
|
||||||
|
while ((line = br.readLine()) != null) {
|
||||||
|
LOG.info("line = " + line);
|
||||||
|
if (!line.contains(jobId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assertTrue(line.contains(name));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pis.close();
|
||||||
|
}
|
||||||
|
|
||||||
protected CLI createJobClient() throws IOException {
|
protected CLI createJobClient() throws IOException {
|
||||||
return new CLI();
|
return new CLI();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue