当前位置: 首页>>代码示例>>Java>>正文


Java CLI类代码示例

本文整理汇总了Java中org.apache.hadoop.mapreduce.tools.CLI的典型用法代码示例。如果您正苦于以下问题:Java CLI类的具体用法?Java CLI怎么用?Java CLI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CLI类属于org.apache.hadoop.mapreduce.tools包,在下文中一共展示了CLI类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testfailTask

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
/**
 * 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"));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestMRJobClient.java

示例2: testKillJob

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestMRJobClient.java

示例3: testListBlackList

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestMRJobClient.java

示例4: testListAttemptIds

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestMRJobClient.java

示例5: testListTrackers

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestMRJobClient.java

示例6: testJobEvents

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestMRJobClient.java

示例7: testJobStatus

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
/**
 * 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"));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestMRJobClient.java

示例8: verifyJobPriority

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
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();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestMRJobClient.java

示例9: testJobName

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:23,代码来源:TestMRJobClient.java

示例10: verifyJobName

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
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();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:20,代码来源:TestMRJobClient.java

示例11: testfailTask

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
/**
 * 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"));
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:21,代码来源:TestMRJobClient.java

示例12: testKillTask

import org.apache.hadoop.mapreduce.tools.CLI; //导入依赖的package包/类
/**
 * 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"));
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:22,代码来源:TestMRJobClient.java


注:本文中的org.apache.hadoop.mapreduce.tools.CLI类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。