Java 类org.apache.hadoop.mapreduce.tools.CLI 实例源码

项目:hadoop    文件:TestMRJobClient.java   
/**
 * test fail task
 */
private void testfailTask(Configuration conf) throws Exception {
  Job job = runJobInBackGround(conf);
  CLI jc = createJobClient();
  TaskID tid = new TaskID(job.getJobID(), TaskType.MAP, 0);
  TaskAttemptID taid = new TaskAttemptID(tid, 1);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // TaskAttemptId is not set
  int exitCode = runTool(conf, jc, new String[] { "-fail-task" }, out);
  assertEquals("Exit code", -1, exitCode);

  runTool(conf, jc, new String[] { "-fail-task", taid.toString() }, out);
  String answer = new String(out.toByteArray(), "UTF-8");
  Assert
    .assertTrue(answer.contains("Killed task " + taid + " by failing it"));
}
项目:hadoop    文件:TestMRJobClient.java   
/**
 * test a kill job
 */
private void testKillJob(Configuration conf) throws Exception {
  Job job = runJobInBackGround(conf);
  String jobId = job.getJobID().toString();
  CLI jc = createJobClient();

  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // without jobId
  int exitCode = runTool(conf, jc, new String[] { "-kill" }, out);
  assertEquals("Exit code", -1, exitCode);
  // good parameters
  exitCode = runTool(conf, jc, new String[] { "-kill", jobId }, out);
  assertEquals("Exit code", 0, exitCode);

  String answer = new String(out.toByteArray(), "UTF-8");
  assertTrue(answer.contains("Killed job " + jobId));
}
项目:hadoop    文件:TestMRJobClient.java   
/**
 * black list 
 */
private void testListBlackList(Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] {
      "-list-blacklisted-trackers", "second in" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-blacklisted-trackers" },
      out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(0, counter);
}
项目:hadoop    文件:TestMRJobClient.java   
/**
 * print AttemptIds list 
 */
private void testListAttemptIds(String jobId, Configuration conf)
    throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids", jobId,
      "MAP", "completed" }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(1, counter);
}
项目:hadoop    文件:TestMRJobClient.java   
/**
 * print tracker list
 */
private void testListTrackers(Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-list-active-trackers",
      "second parameter" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-active-trackers" }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(2, counter);
}
项目:hadoop    文件:TestMRJobClient.java   
/**
 * print job events list 
 */
private void testJobEvents(String jobId, Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-events" }, out);
  assertEquals("Exit code", -1, exitCode);

  exitCode = runTool(conf, jc, new String[] { "-events", jobId, "0", "100" },
      out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  String attemptId = ("attempt" + jobId.substring(3));
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (line.contains(attemptId)) {
      counter++;
    }
  }
  assertEquals(2, counter);
}
项目:hadoop    文件:TestMRJobClient.java   
/**
 * print job status 
 */
private void testJobStatus(String jobId, Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // bad options
  int exitCode = runTool(conf, jc, new String[] { "-status" }, out);
  assertEquals("Exit code", -1, exitCode);

  exitCode = runTool(conf, jc, new String[] { "-status", jobId }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));

  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (!line.contains("Job state:")) {
      continue;
    }
    break;
  }
  assertNotNull(line);
  assertTrue(line.contains("SUCCEEDED"));
}
项目:hadoop    文件:TestMRJobClient.java   
protected void verifyJobPriority(String jobId, String priority,
    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;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (!line.contains(jobId)) {
      continue;
    }
    assertTrue(line.contains(priority));
    break;
  }
  pis.close();
}
项目:aliyun-oss-hadoop-fs    文件:TestMRJobClient.java   
/**
 * test fail task
 */
private void testfailTask(Configuration conf) throws Exception {
  Job job = runJobInBackGround(conf);
  CLI jc = createJobClient();
  TaskID tid = new TaskID(job.getJobID(), TaskType.MAP, 0);
  TaskAttemptID taid = new TaskAttemptID(tid, 1);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // TaskAttemptId is not set
  int exitCode = runTool(conf, jc, new String[] { "-fail-task" }, out);
  assertEquals("Exit code", -1, exitCode);

  runTool(conf, jc, new String[] { "-fail-task", taid.toString() }, out);
  String answer = new String(out.toByteArray(), "UTF-8");
  Assert
    .assertTrue(answer.contains("Killed task " + taid + " by failing it"));
}
项目:aliyun-oss-hadoop-fs    文件:TestMRJobClient.java   
/**
 * test a kill job
 */
private void testKillJob(Configuration conf) throws Exception {
  Job job = runJobInBackGround(conf);
  String jobId = job.getJobID().toString();
  CLI jc = createJobClient();

  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // without jobId
  int exitCode = runTool(conf, jc, new String[] { "-kill" }, out);
  assertEquals("Exit code", -1, exitCode);
  // good parameters
  exitCode = runTool(conf, jc, new String[] { "-kill", jobId }, out);
  assertEquals("Exit code", 0, exitCode);

  String answer = new String(out.toByteArray(), "UTF-8");
  assertTrue(answer.contains("Killed job " + jobId));
}
项目:aliyun-oss-hadoop-fs    文件:TestMRJobClient.java   
/**
 * black list 
 */
private void testListBlackList(Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] {
      "-list-blacklisted-trackers", "second in" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-blacklisted-trackers" },
      out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(0, counter);
}
项目:aliyun-oss-hadoop-fs    文件:TestMRJobClient.java   
/**
 * print AttemptIds list 
 */
private void testListAttemptIds(String jobId, Configuration conf)
    throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids", jobId,
      "MAP", "completed" }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(1, counter);
}
项目:aliyun-oss-hadoop-fs    文件:TestMRJobClient.java   
/**
 * print tracker list
 */
private void testListTrackers(Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-list-active-trackers",
      "second parameter" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-active-trackers" }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(2, counter);
}
项目:aliyun-oss-hadoop-fs    文件:TestMRJobClient.java   
/**
 * print job events list 
 */
private void testJobEvents(String jobId, Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-events" }, out);
  assertEquals("Exit code", -1, exitCode);

  exitCode = runTool(conf, jc, new String[] { "-events", jobId, "0", "100" },
      out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  String attemptId = ("attempt" + jobId.substring(3));
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (line.contains(attemptId)) {
      counter++;
    }
  }
  assertEquals(2, counter);
}
项目:aliyun-oss-hadoop-fs    文件:TestMRJobClient.java   
/**
 * print job status 
 */
private void testJobStatus(String jobId, Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // bad options
  int exitCode = runTool(conf, jc, new String[] { "-status" }, out);
  assertEquals("Exit code", -1, exitCode);

  exitCode = runTool(conf, jc, new String[] { "-status", jobId }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));

  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (!line.contains("Job state:")) {
      continue;
    }
    break;
  }
  assertNotNull(line);
  assertTrue(line.contains("SUCCEEDED"));
}
项目:aliyun-oss-hadoop-fs    文件:TestMRJobClient.java   
protected void verifyJobPriority(String jobId, String priority,
    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;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (!line.contains(jobId)) {
      continue;
    }
    assertTrue(line.contains(priority));
    break;
  }
  pis.close();
}
项目:aliyun-oss-hadoop-fs    文件:TestMRJobClient.java   
/**
 * 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);
}
项目:aliyun-oss-hadoop-fs    文件:TestMRJobClient.java   
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();
}
项目:big-c    文件:TestMRJobClient.java   
/**
 * test fail task
 */
private void testfailTask(Configuration conf) throws Exception {
  Job job = runJobInBackGround(conf);
  CLI jc = createJobClient();
  TaskID tid = new TaskID(job.getJobID(), TaskType.MAP, 0);
  TaskAttemptID taid = new TaskAttemptID(tid, 1);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // TaskAttemptId is not set
  int exitCode = runTool(conf, jc, new String[] { "-fail-task" }, out);
  assertEquals("Exit code", -1, exitCode);

  runTool(conf, jc, new String[] { "-fail-task", taid.toString() }, out);
  String answer = new String(out.toByteArray(), "UTF-8");
  Assert
    .assertTrue(answer.contains("Killed task " + taid + " by failing it"));
}
项目:big-c    文件:TestMRJobClient.java   
/**
 * test a kill job
 */
private void testKillJob(Configuration conf) throws Exception {
  Job job = runJobInBackGround(conf);
  String jobId = job.getJobID().toString();
  CLI jc = createJobClient();

  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // without jobId
  int exitCode = runTool(conf, jc, new String[] { "-kill" }, out);
  assertEquals("Exit code", -1, exitCode);
  // good parameters
  exitCode = runTool(conf, jc, new String[] { "-kill", jobId }, out);
  assertEquals("Exit code", 0, exitCode);

  String answer = new String(out.toByteArray(), "UTF-8");
  assertTrue(answer.contains("Killed job " + jobId));
}
项目:big-c    文件:TestMRJobClient.java   
/**
 * black list 
 */
private void testListBlackList(Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] {
      "-list-blacklisted-trackers", "second in" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-blacklisted-trackers" },
      out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(0, counter);
}
项目:big-c    文件:TestMRJobClient.java   
/**
 * print AttemptIds list 
 */
private void testListAttemptIds(String jobId, Configuration conf)
    throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids", jobId,
      "MAP", "completed" }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(1, counter);
}
项目:big-c    文件:TestMRJobClient.java   
/**
 * print tracker list
 */
private void testListTrackers(Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-list-active-trackers",
      "second parameter" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-active-trackers" }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(2, counter);
}
项目:big-c    文件:TestMRJobClient.java   
/**
 * print job events list 
 */
private void testJobEvents(String jobId, Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-events" }, out);
  assertEquals("Exit code", -1, exitCode);

  exitCode = runTool(conf, jc, new String[] { "-events", jobId, "0", "100" },
      out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  String attemptId = ("attempt" + jobId.substring(3));
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (line.contains(attemptId)) {
      counter++;
    }
  }
  assertEquals(2, counter);
}
项目:big-c    文件:TestMRJobClient.java   
/**
 * print job status 
 */
private void testJobStatus(String jobId, Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // bad options
  int exitCode = runTool(conf, jc, new String[] { "-status" }, out);
  assertEquals("Exit code", -1, exitCode);

  exitCode = runTool(conf, jc, new String[] { "-status", jobId }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));

  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (!line.contains("Job state:")) {
      continue;
    }
    break;
  }
  assertNotNull(line);
  assertTrue(line.contains("SUCCEEDED"));
}
项目:big-c    文件:TestMRJobClient.java   
protected void verifyJobPriority(String jobId, String priority,
    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;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (!line.contains(jobId)) {
      continue;
    }
    assertTrue(line.contains(priority));
    break;
  }
  pis.close();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestMRJobClient.java   
/**
 * test fail task
 */
private void testfailTask(Configuration conf) throws Exception {
  Job job = runJobInBackGround(conf);
  CLI jc = createJobClient();
  TaskID tid = new TaskID(job.getJobID(), TaskType.MAP, 0);
  TaskAttemptID taid = new TaskAttemptID(tid, 1);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // TaskAttemptId is not set
  int exitCode = runTool(conf, jc, new String[] { "-fail-task" }, out);
  assertEquals("Exit code", -1, exitCode);

  runTool(conf, jc, new String[] { "-fail-task", taid.toString() }, out);
  String answer = new String(out.toByteArray(), "UTF-8");
  Assert
    .assertTrue(answer.contains("Killed task " + taid + " by failing it"));
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestMRJobClient.java   
/**
 * test a kill job
 */
private void testKillJob(Configuration conf) throws Exception {
  Job job = runJobInBackGround(conf);
  String jobId = job.getJobID().toString();
  CLI jc = createJobClient();

  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // without jobId
  int exitCode = runTool(conf, jc, new String[] { "-kill" }, out);
  assertEquals("Exit code", -1, exitCode);
  // good parameters
  exitCode = runTool(conf, jc, new String[] { "-kill", jobId }, out);
  assertEquals("Exit code", 0, exitCode);

  String answer = new String(out.toByteArray(), "UTF-8");
  assertTrue(answer.contains("Killed job " + jobId));
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestMRJobClient.java   
/**
 * black list 
 */
private void testListBlackList(Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] {
      "-list-blacklisted-trackers", "second in" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-blacklisted-trackers" },
      out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(0, counter);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestMRJobClient.java   
/**
 * print AttemptIds list 
 */
private void testListAttemptIds(String jobId, Configuration conf)
    throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids", jobId,
      "MAP", "completed" }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(1, counter);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestMRJobClient.java   
/**
 * print tracker list
 */
private void testListTrackers(Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-list-active-trackers",
      "second parameter" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-active-trackers" }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(2, counter);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestMRJobClient.java   
/**
 * print job events list 
 */
private void testJobEvents(String jobId, Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-events" }, out);
  assertEquals("Exit code", -1, exitCode);

  exitCode = runTool(conf, jc, new String[] { "-events", jobId, "0", "100" },
      out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  String attemptId = ("attempt" + jobId.substring(3));
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (line.contains(attemptId)) {
      counter++;
    }
  }
  assertEquals(2, counter);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestMRJobClient.java   
/**
 * print job status 
 */
private void testJobStatus(String jobId, Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // bad options
  int exitCode = runTool(conf, jc, new String[] { "-status" }, out);
  assertEquals("Exit code", -1, exitCode);

  exitCode = runTool(conf, jc, new String[] { "-status", jobId }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));

  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (!line.contains("Job state:")) {
      continue;
    }
    break;
  }
  assertNotNull(line);
  assertTrue(line.contains("SUCCEEDED"));
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestMRJobClient.java   
protected void verifyJobPriority(String jobId, String priority,
    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;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (!line.contains(jobId)) {
      continue;
    }
    assertTrue(line.contains(priority));
    break;
  }
  pis.close();
}
项目:hadoop-plus    文件:TestMRJobClient.java   
/**
 * test fail task
 */
private void testfailTask(Job job, Configuration conf) throws Exception {
  CLI jc = createJobClient();
  TaskID tid = new TaskID(job.getJobID(), TaskType.MAP, 0);
  TaskAttemptID taid = new TaskAttemptID(tid, 1);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  //  TaskAttemptId is not set
  int exitCode = runTool(conf, jc, new String[] { "-fail-task" }, out);
  assertEquals("Exit code", -1, exitCode);

  try {
    runTool(conf, jc, new String[] { "-fail-task", taid.toString() }, out);
    fail(" this task should field");
  } catch (IOException e) {
    // task completed !
    assertTrue(e.getMessage().contains("_0001_m_000000_1"));
  }
}
项目:hadoop-plus    文件:TestMRJobClient.java   
/**
 * test a kill task
 */ 
private void testKillTask(Job job, Configuration conf) throws Exception {
  CLI jc = createJobClient();
  TaskID tid = new TaskID(job.getJobID(), TaskType.MAP, 0);
  TaskAttemptID taid = new TaskAttemptID(tid, 1);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  // bad parameters
  int exitCode = runTool(conf, jc, new String[] { "-kill-task" }, out);
  assertEquals("Exit code", -1, exitCode);

  try {
    runTool(conf, jc, new String[] { "-kill-task", taid.toString() }, out);
    fail(" this task should be killed");
  } catch (IOException e) {
    System.out.println(e);
    // task completed
    assertTrue(e.getMessage().contains("_0001_m_000000_1"));
  }
}
项目:hadoop-plus    文件:TestMRJobClient.java   
/**
 * black list 
 */
private void testListBlackList(Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] {
      "-list-blacklisted-trackers", "second in" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-blacklisted-trackers" },
      out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(0, counter);
}
项目:hadoop-plus    文件:TestMRJobClient.java   
/**
 * print AttemptIds list 
 */
private void testListAttemptIds(String jobId, Configuration conf)
    throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids", jobId,
      "MAP", "completed" }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(1, counter);
}
项目:hadoop-plus    文件:TestMRJobClient.java   
/**
 * print tracker list
 */
private void testListTrackers(Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-list-active-trackers",
      "second parameter" }, out);
  assertEquals("Exit code", -1, exitCode);
  exitCode = runTool(conf, jc, new String[] { "-list-active-trackers" }, out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    counter++;
  }
  assertEquals(2, counter);
}
项目:hadoop-plus    文件:TestMRJobClient.java   
/**
 * print job events list 
 */
private void testJobEvents(String jobId, Configuration conf) throws Exception {
  CLI jc = createJobClient();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int exitCode = runTool(conf, jc, new String[] { "-events" }, out);
  assertEquals("Exit code", -1, exitCode);

  exitCode = runTool(conf, jc, new String[] { "-events", jobId, "0", "100" },
      out);
  assertEquals("Exit code", 0, exitCode);
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(
      new ByteArrayInputStream(out.toByteArray())));
  int counter = 0;
  String attemptId = ("attempt" + jobId.substring(3));
  while ((line = br.readLine()) != null) {
    LOG.info("line = " + line);
    if (line.contains(attemptId)) {
      counter++;
    }
  }
  assertEquals(2, counter);
}