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


Java AppForTest.setJob方法代码示例

本文整理汇总了Java中org.apache.hadoop.mapreduce.v2.app.webapp.AppForTest.setJob方法的典型用法代码示例。如果您正苦于以下问题:Java AppForTest.setJob方法的具体用法?Java AppForTest.setJob怎么用?Java AppForTest.setJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.mapreduce.v2.app.webapp.AppForTest的用法示例。


在下文中一共展示了AppForTest.setJob方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testHsTasksBlock

import org.apache.hadoop.mapreduce.v2.app.webapp.AppForTest; //导入方法依赖的package包/类
/**
 * test HsTasksBlock's rendering.
 */
@Test
public void testHsTasksBlock() {

  Task task = getTask(0);

  Map<TaskId, Task> tasks = new HashMap<TaskId, Task>();
  tasks.put(task.getID(), task);

  AppContext ctx = mock(AppContext.class);
  AppForTest app = new AppForTest(ctx);
  Job job = mock(Job.class);
  when(job.getTasks()).thenReturn(tasks);

  app.setJob(job);

  HsTasksBlockForTest block = new HsTasksBlockForTest(app);

  block.addParameter(AMParams.TASK_TYPE, "r");

  PrintWriter pWriter = new PrintWriter(data);
  Block html = new BlockForTest(new HtmlBlockForTest(), pWriter, 0, false);

  block.render(html);
  pWriter.flush();
  // should be printed information about task
  assertTrue(data.toString().contains("task_0_0001_r_000000"));
  assertTrue(data.toString().contains("SUCCEEDED"));
  assertTrue(data.toString().contains("100001"));
  assertTrue(data.toString().contains("100011"));
  assertTrue(data.toString().contains(""));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:TestBlocks.java

示例2: testAttemptsBlock

import org.apache.hadoop.mapreduce.v2.app.webapp.AppForTest; //导入方法依赖的package包/类
/**
 * test AttemptsBlock's rendering.
 */
@Test
public void testAttemptsBlock() {
  AppContext ctx = mock(AppContext.class);
  AppForTest app = new AppForTest(ctx);

  Task task = getTask(0);
  Map<TaskAttemptId, TaskAttempt> attempts = new HashMap<TaskAttemptId, TaskAttempt>();
  TaskAttempt attempt = mock(TaskAttempt.class);
  TaskAttemptId taId = new TaskAttemptIdPBImpl();
  taId.setId(0);
  taId.setTaskId(task.getID());
  when(attempt.getID()).thenReturn(taId);
  when(attempt.getNodeHttpAddress()).thenReturn("Node address");

  ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptIdPBImpl.newInstance(appId, 1);

  ContainerId containerId = ContainerIdPBImpl.newContainerId(appAttemptId, 1);
  when(attempt.getAssignedContainerID()).thenReturn(containerId);

  when(attempt.getAssignedContainerMgrAddress()).thenReturn(
          "assignedContainerMgrAddress");
  when(attempt.getNodeRackName()).thenReturn("nodeRackName");

  final long taStartTime = 100002L;
  final long taFinishTime = 100012L;
  final long taShuffleFinishTime = 100010L;
  final long taSortFinishTime = 100011L;
  final TaskAttemptState taState = TaskAttemptState.SUCCEEDED;

  when(attempt.getLaunchTime()).thenReturn(taStartTime);
  when(attempt.getFinishTime()).thenReturn(taFinishTime);
  when(attempt.getShuffleFinishTime()).thenReturn(taShuffleFinishTime);
  when(attempt.getSortFinishTime()).thenReturn(taSortFinishTime);
  when(attempt.getState()).thenReturn(taState);

  TaskAttemptReport taReport = mock(TaskAttemptReport.class);
  when(taReport.getStartTime()).thenReturn(taStartTime);
  when(taReport.getFinishTime()).thenReturn(taFinishTime);
  when(taReport.getShuffleFinishTime()).thenReturn(taShuffleFinishTime);
  when(taReport.getSortFinishTime()).thenReturn(taSortFinishTime);
  when(taReport.getContainerId()).thenReturn(containerId);
  when(taReport.getProgress()).thenReturn(1.0f);
  when(taReport.getStateString()).thenReturn("Processed 128/128 records <p> \n");
  when(taReport.getTaskAttemptState()).thenReturn(taState);
  when(taReport.getDiagnosticInfo()).thenReturn("");

  when(attempt.getReport()).thenReturn(taReport);

  attempts.put(taId, attempt);
  when(task.getAttempts()).thenReturn(attempts);

  app.setTask(task);
  Job job = mock(Job.class);
  when(job.getUserName()).thenReturn("User");
  app.setJob(job);

  AttemptsBlockForTest block = new AttemptsBlockForTest(app);
  block.addParameter(AMParams.TASK_TYPE, "r");

  PrintWriter pWriter = new PrintWriter(data);
  Block html = new BlockForTest(new HtmlBlockForTest(), pWriter, 0, false);

  block.render(html);
  pWriter.flush();
  // should be printed information about attempts
  assertTrue(data.toString().contains("0 attempt_0_0001_r_000000_0"));
  assertTrue(data.toString().contains("SUCCEEDED"));
  assertFalse(data.toString().contains("Processed 128/128 records <p> \n"));
  assertTrue(data.toString().contains("Processed 128\\/128 records &lt;p&gt; \\n"));
  assertTrue(data.toString().contains(
          "_0005_01_000001:attempt_0_0001_r_000000_0:User:"));
  assertTrue(data.toString().contains("100002"));
  assertTrue(data.toString().contains("100010"));
  assertTrue(data.toString().contains("100011"));
  assertTrue(data.toString().contains("100012"));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:81,代码来源:TestBlocks.java

示例3: testAttemptsBlock

import org.apache.hadoop.mapreduce.v2.app.webapp.AppForTest; //导入方法依赖的package包/类
/**
 * test AttemptsBlock's rendering.
 */
@Test
public void testAttemptsBlock() {
  AppContext ctx = mock(AppContext.class);
  AppForTest app = new AppForTest(ctx);

  Task task = getTask(0);
  Map<TaskAttemptId, TaskAttempt> attempts = new HashMap<TaskAttemptId, TaskAttempt>();
  TaskAttempt attempt = mock(TaskAttempt.class);
  TaskAttemptId taId = new TaskAttemptIdPBImpl();
  taId.setId(0);
  taId.setTaskId(task.getID());
  when(attempt.getID()).thenReturn(taId);
  when(attempt.getNodeHttpAddress()).thenReturn("Node address");

  ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptIdPBImpl.newInstance(appId, 1);

  ContainerId containerId = ContainerIdPBImpl.newContainerId(appAttemptId, 1);
  when(attempt.getAssignedContainerID()).thenReturn(containerId);

  when(attempt.getAssignedContainerMgrAddress()).thenReturn(
          "assignedContainerMgrAddress");
  when(attempt.getNodeRackName()).thenReturn("nodeRackName");

  final long taStartTime = 100002L;
  final long taFinishTime = 100012L;
  final long taShuffleFinishTime = 100010L;
  final long taSortFinishTime = 100011L;
  final TaskAttemptState taState = TaskAttemptState.SUCCEEDED;

  when(attempt.getLaunchTime()).thenReturn(taStartTime);
  when(attempt.getFinishTime()).thenReturn(taFinishTime);
  when(attempt.getShuffleFinishTime()).thenReturn(taShuffleFinishTime);
  when(attempt.getSortFinishTime()).thenReturn(taSortFinishTime);
  when(attempt.getState()).thenReturn(taState);

  TaskAttemptReport taReport = mock(TaskAttemptReport.class);
  when(taReport.getStartTime()).thenReturn(taStartTime);
  when(taReport.getFinishTime()).thenReturn(taFinishTime);
  when(taReport.getShuffleFinishTime()).thenReturn(taShuffleFinishTime);
  when(taReport.getSortFinishTime()).thenReturn(taSortFinishTime);
  when(taReport.getContainerId()).thenReturn(containerId);
  when(taReport.getProgress()).thenReturn(1.0f);
  when(taReport.getStateString()).thenReturn("Processed 128/128 records <p> \n");
  when(taReport.getTaskAttemptState()).thenReturn(taState);
  when(taReport.getDiagnosticInfo()).thenReturn("");

  when(attempt.getReport()).thenReturn(taReport);

  attempts.put(taId, attempt);
  when(task.getAttempts()).thenReturn(attempts);

  app.setTask(task);
  Job job = mock(Job.class);
  when(job.getUserName()).thenReturn("User");
  app.setJob(job);

  AttemptsBlockForTest block = new AttemptsBlockForTest(app);
  block.addParameter(AMParams.TASK_TYPE, "r");

  PrintWriter pWriter = new PrintWriter(data);
  Block html = new BlockForTest(new HtmlBlockForTest(), pWriter, 0, false);

  block.render(html);
  pWriter.flush();
  // should be printed information about attempts
  assertTrue(data.toString().contains("attempt_0_0001_r_000000_0"));
  assertTrue(data.toString().contains("SUCCEEDED"));
  assertFalse(data.toString().contains("Processed 128/128 records <p> \n"));
  assertTrue(data.toString().contains("Processed 128\\/128 records &lt;p&gt; \\n"));
  assertTrue(data.toString().contains(
          "_0005_01_000001:attempt_0_0001_r_000000_0:User:"));
  assertTrue(data.toString().contains("100002"));
  assertTrue(data.toString().contains("100010"));
  assertTrue(data.toString().contains("100011"));
  assertTrue(data.toString().contains("100012"));
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:81,代码来源:TestBlocks.java

示例4: testAttemptsBlock

import org.apache.hadoop.mapreduce.v2.app.webapp.AppForTest; //导入方法依赖的package包/类
/**
 * test AttemptsBlock's rendering.
 */
@Test
public void testAttemptsBlock() {
  AppContext ctx = mock(AppContext.class);
  AppForTest app = new AppForTest(ctx);

  Task task = getTask(0);
  Map<TaskAttemptId, TaskAttempt> attempts = new HashMap<TaskAttemptId, TaskAttempt>();
  TaskAttempt attempt = mock(TaskAttempt.class);
  TaskAttemptId taId = new TaskAttemptIdPBImpl();
  taId.setId(0);
  taId.setTaskId(task.getID());
  when(attempt.getID()).thenReturn(taId);
  when(attempt.getNodeHttpAddress()).thenReturn("Node address");

  ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptIdPBImpl.newInstance(appId, 1);

  ContainerId containerId = ContainerIdPBImpl.newInstance(appAttemptId, 1);
  when(attempt.getAssignedContainerID()).thenReturn(containerId);

  when(attempt.getAssignedContainerMgrAddress()).thenReturn(
          "assignedContainerMgrAddress");
  when(attempt.getNodeRackName()).thenReturn("nodeRackName");

  final long taStartTime = 100002L;
  final long taFinishTime = 100012L;
  final long taShuffleFinishTime = 100010L;
  final long taSortFinishTime = 100011L;
  final TaskAttemptState taState = TaskAttemptState.SUCCEEDED;

  when(attempt.getLaunchTime()).thenReturn(taStartTime);
  when(attempt.getFinishTime()).thenReturn(taFinishTime);
  when(attempt.getShuffleFinishTime()).thenReturn(taShuffleFinishTime);
  when(attempt.getSortFinishTime()).thenReturn(taSortFinishTime);
  when(attempt.getState()).thenReturn(taState);

  TaskAttemptReport taReport = mock(TaskAttemptReport.class);
  when(taReport.getStartTime()).thenReturn(taStartTime);
  when(taReport.getFinishTime()).thenReturn(taFinishTime);
  when(taReport.getShuffleFinishTime()).thenReturn(taShuffleFinishTime);
  when(taReport.getSortFinishTime()).thenReturn(taSortFinishTime);
  when(taReport.getContainerId()).thenReturn(containerId);
  when(taReport.getProgress()).thenReturn(1.0f);
  when(taReport.getStateString()).thenReturn("Processed 128/128 records");
  when(taReport.getTaskAttemptState()).thenReturn(taState);
  when(taReport.getDiagnosticInfo()).thenReturn("");

  when(attempt.getReport()).thenReturn(taReport);

  attempts.put(taId, attempt);
  when(task.getAttempts()).thenReturn(attempts);

  app.setTask(task);
  Job job = mock(Job.class);
  when(job.getUserName()).thenReturn("User");
  app.setJob(job);

  AttemptsBlockForTest block = new AttemptsBlockForTest(app);
  block.addParameter(AMParams.TASK_TYPE, "r");

  PrintWriter pWriter = new PrintWriter(data);
  Block html = new BlockForTest(new HtmlBlockForTest(), pWriter, 0, false);

  block.render(html);
  pWriter.flush();
  // should be printed information about attempts
  assertTrue(data.toString().contains("0 attempt_0_0001_r_000000_0"));
  assertTrue(data.toString().contains("SUCCEEDED"));
  assertTrue(data.toString().contains(
          "_0005_01_000001:attempt_0_0001_r_000000_0:User:"));
  assertTrue(data.toString().contains("100002"));
  assertTrue(data.toString().contains("100010"));
  assertTrue(data.toString().contains("100011"));
  assertTrue(data.toString().contains("100012"));
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:79,代码来源:TestBlocks.java


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