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


Java ApplicationIdPBImpl.newInstance方法代码示例

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


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

示例1: getJob

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的package包/类
private Job getJob() {
  Job job = mock(Job.class);

  JobId jobId = new JobIdPBImpl();

  ApplicationId appId = ApplicationIdPBImpl.newInstance(System.currentTimeMillis(),4);
  jobId.setAppId(appId);
  jobId.setId(1);
  when(job.getID()).thenReturn(jobId);

  JobReport report = mock(JobReport.class);
  when(report.getStartTime()).thenReturn(100010L);
  when(report.getFinishTime()).thenReturn(100015L);

  when(job.getReport()).thenReturn(report);
  when(job.getName()).thenReturn("JobName");
  when(job.getUserName()).thenReturn("UserName");
  when(job.getQueueName()).thenReturn("QueueName");
  when(job.getState()).thenReturn(JobState.SUCCEEDED);
  when(job.getTotalMaps()).thenReturn(3);
  when(job.getCompletedMaps()).thenReturn(2);
  when(job.getTotalReduces()).thenReturn(2);
  when(job.getCompletedReduces()).thenReturn(1);
  when(job.getCompletedReduces()).thenReturn(1);
  return job;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestBlocks.java

示例2: writeLog

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的package包/类
private void writeLog(Configuration configuration, String user)
    throws Exception {
  ApplicationId appId =  ApplicationIdPBImpl.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =  ApplicationAttemptIdPBImpl.newInstance(appId, 1);
  ContainerId containerId = ContainerIdPBImpl.newContainerId(appAttemptId, 1);

  String path = "target/logs/" + user
      + "/logs/application_0_0001/localhost_1234";
  File f = new File(path);
  if (!f.getParentFile().exists()) {
   assertTrue(f.getParentFile().mkdirs());
  }
  List<String> rootLogDirs = Arrays.asList("target/logs/logs");
  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();

  AggregatedLogFormat.LogWriter writer = new AggregatedLogFormat.LogWriter(
      configuration, new Path(path), ugi);
  writer.writeApplicationOwner(ugi.getUserName());

  Map<ApplicationAccessType, String> appAcls = new HashMap<ApplicationAccessType, String>();
  appAcls.put(ApplicationAccessType.VIEW_APP, ugi.getUserName());
  writer.writeApplicationACLs(appAcls);

  writer.append(new AggregatedLogFormat.LogKey("container_0_0001_01_000001"),
      new AggregatedLogFormat.LogValue(rootLogDirs, containerId,UserGroupInformation.getCurrentUser().getShortUserName()));
  writer.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestAggregatedLogsBlock.java

示例3: writeLog

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的package包/类
private void writeLog(Configuration configuration, String user)
    throws Exception {
  ApplicationId appId =  ApplicationIdPBImpl.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =  ApplicationAttemptIdPBImpl.newInstance(appId, 1);
  ContainerId containerId = ContainerIdPBImpl.newContainerId(appAttemptId, 1);

  String path = "target/logs/" + user
      + "/logs/application_0_0001/localhost_1234";
  File f = new File(path);
  if (!f.getParentFile().exists()) {
   assertTrue(f.getParentFile().mkdirs());
  }
  List<String> rootLogDirs = Arrays.asList("target/logs/logs");
  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();

  try (AggregatedLogFormat.LogWriter writer =
           new AggregatedLogFormat.LogWriter()) {
    writer.initialize(configuration, new Path(path), ugi);
    writer.writeApplicationOwner(ugi.getUserName());

    Map<ApplicationAccessType, String> appAcls = new HashMap<ApplicationAccessType, String>();
    appAcls.put(ApplicationAccessType.VIEW_APP, ugi.getUserName());
    writer.writeApplicationACLs(appAcls);

    writer.append(new AggregatedLogFormat.LogKey("container_0_0001_01_000001"),
        new AggregatedLogFormat.LogValue(rootLogDirs, containerId,
            UserGroupInformation.getCurrentUser().getShortUserName(), UserGroupInformation.getCurrentUser().
            getShortUserName()));
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:31,代码来源:TestAggregatedLogsBlock.java

示例4: writeLog

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的package包/类
private void writeLog(Configuration configuration, String user)
    throws Exception {
  ApplicationId appId =  ApplicationIdPBImpl.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =  ApplicationAttemptIdPBImpl.newInstance(appId, 1);
  ContainerId containerId = ContainerIdPBImpl.newInstance(appAttemptId, 1);

  String path = "target/logs/" + user
      + "/logs/application_0_0001/localhost_1234";
  File f = new File(path);
  if (!f.getParentFile().exists()) {
   assertTrue(f.getParentFile().mkdirs());
  }
  List<String> rootLogDirs = Arrays.asList("target/logs/logs");
  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();

  AggregatedLogFormat.LogWriter writer = new AggregatedLogFormat.LogWriter(
      configuration, new Path(path), ugi);
  writer.writeApplicationOwner(ugi.getUserName());

  Map<ApplicationAccessType, String> appAcls = new HashMap<ApplicationAccessType, String>();
  appAcls.put(ApplicationAccessType.VIEW_APP, ugi.getUserName());
  writer.writeApplicationACLs(appAcls);

  writer.append(new AggregatedLogFormat.LogKey("container_0_0001_01_000001"),
      new AggregatedLogFormat.LogValue(rootLogDirs, containerId,UserGroupInformation.getCurrentUser().getShortUserName()));
  writer.close();
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:28,代码来源:TestAggregatedLogsBlock.java

示例5: testTasksBlock

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的package包/类
/**
 * Test rendering for TasksBlock
 */
@Test
public void testTasksBlock() throws Exception {

  ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 1);
  JobId jobId = new JobIdPBImpl();
  jobId.setId(0);
  jobId.setAppId(appId);

  TaskId taskId = new TaskIdPBImpl();
  taskId.setId(0);
  taskId.setTaskType(TaskType.MAP);
  taskId.setJobId(jobId);
  Task task = mock(Task.class);
  when(task.getID()).thenReturn(taskId);
  TaskReport report = mock(TaskReport.class);
  when(report.getProgress()).thenReturn(0.7f);
  when(report.getTaskState()).thenReturn(TaskState.SUCCEEDED);
  when(report.getStartTime()).thenReturn(100001L);
  when(report.getFinishTime()).thenReturn(100011L);
  when(report.getStatus()).thenReturn("Dummy Status \n*");


  when(task.getReport()).thenReturn(report);
  when(task.getType()).thenReturn(TaskType.MAP);


  Map<TaskId, Task> tasks = new HashMap<TaskId, Task>();
  tasks.put(taskId, task);
  AppContext ctx = mock(AppContext.class);
  Job job = mock(Job.class);
  when(job.getTasks()).thenReturn(tasks);


  App app = new App(ctx);
  app.setJob(job);
  TasksBlockForTest taskBlock = new TasksBlockForTest(app);
  taskBlock.addParameter(AMParams.TASK_TYPE, "m");

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

  taskBlock.render(html);
  pWriter.flush();
  assertTrue(data.toString().contains("task_0_0001_m_000000"));
  assertTrue(data.toString().contains("70.00"));
  assertTrue(data.toString().contains("SUCCEEDED"));
  assertTrue(data.toString().contains("100001"));
  assertTrue(data.toString().contains("100011"));
  assertFalse(data.toString().contains("Dummy Status \n*"));
  assertTrue(data.toString().contains("Dummy Status \\n*"));


}
 
开发者ID:naver,项目名称:hadoop,代码行数:57,代码来源:TestBlocks.java

示例6: testAttemptsBlock

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的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

示例7: testHsController

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的package包/类
/**
 * test HsController
 */

@Test
public void testHsController() throws Exception {
  AppContext ctx = mock(AppContext.class);
  ApplicationId appId = ApplicationIdPBImpl.newInstance(0,5);
  
  when(ctx.getApplicationID()).thenReturn(appId);

  AppForTest app = new AppForTest(ctx);
  Configuration config = new Configuration();
  RequestContext requestCtx = mock(RequestContext.class);
  HsControllerForTest controller = new HsControllerForTest(app, config,
          requestCtx);
  controller.index();
  assertEquals("JobHistory", controller.get(Params.TITLE, ""));
  assertEquals(HsJobPage.class, controller.jobPage());
  assertEquals(HsCountersPage.class, controller.countersPage());
  assertEquals(HsTasksPage.class, controller.tasksPage());
  assertEquals(HsTaskPage.class, controller.taskPage());
  assertEquals(HsAttemptsPage.class, controller.attemptsPage());

  controller.set(AMParams.JOB_ID, "job_01_01");
  controller.set(AMParams.TASK_ID, "task_01_01_m01_01");
  controller.set(AMParams.TASK_TYPE, "m");
  controller.set(AMParams.ATTEMPT_STATE, "State");

  Job job = mock(Job.class);
  Task task = mock(Task.class);
  when(job.getTask(any(TaskId.class))).thenReturn(task);
  JobId jobID = MRApps.toJobID("job_01_01");
  when(ctx.getJob(jobID)).thenReturn(job);
  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
          .thenReturn(true);

  controller.job();
  assertEquals(HsJobPage.class, controller.getClazz());
  controller.jobCounters();
  assertEquals(HsCountersPage.class, controller.getClazz());
  controller.taskCounters();
  assertEquals(HsCountersPage.class, controller.getClazz());
  controller.tasks();
  assertEquals(HsTasksPage.class, controller.getClazz());
  controller.task();
  assertEquals(HsTaskPage.class, controller.getClazz());
  controller.attempts();
  assertEquals(HsAttemptsPage.class, controller.getClazz());

  assertEquals(HsConfPage.class, controller.confPage());
  assertEquals(HsAboutPage.class, controller.aboutPage());
  controller.about();
  assertEquals(HsAboutPage.class, controller.getClazz());
  controller.logs();
  assertEquals(HsLogsPage.class, controller.getClazz());
  controller.nmlogs();
  assertEquals(AggregatedLogsPage.class, controller.getClazz());

  assertEquals(HsSingleCounterPage.class, controller.singleCounterPage());
  controller.singleJobCounter();
  assertEquals(HsSingleCounterPage.class, controller.getClazz());
  controller.singleTaskCounter();
  assertEquals(HsSingleCounterPage.class, controller.getClazz());


}
 
开发者ID:naver,项目名称:hadoop,代码行数:68,代码来源:TestBlocks.java

示例8: testTasksBlock

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的package包/类
/**
 * Test rendering for TasksBlock
 */
@Test
public void testTasksBlock() throws Exception {

  ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 1);
  JobId jobId = new JobIdPBImpl();
  jobId.setId(0);
  jobId.setAppId(appId);

  TaskId taskId = new TaskIdPBImpl();
  taskId.setId(0);
  taskId.setTaskType(TaskType.MAP);
  taskId.setJobId(jobId);
  Task task = mock(Task.class);
  when(task.getID()).thenReturn(taskId);
  TaskReport report = mock(TaskReport.class);
  when(report.getProgress()).thenReturn(0.7f);
  when(report.getTaskState()).thenReturn(TaskState.SUCCEEDED);
  when(report.getStartTime()).thenReturn(100001L);
  when(report.getFinishTime()).thenReturn(100011L);
  when(report.getStatus()).thenReturn("Dummy Status \n*");


  when(task.getReport()).thenReturn(report);
  when(task.getType()).thenReturn(TaskType.MAP);


  Map<TaskId, Task> tasks = new HashMap<TaskId, Task>();
  tasks.put(taskId, task);
  AppContext ctx = mock(AppContext.class);
  Job job = mock(Job.class);
  when(job.getTasks()).thenReturn(tasks);


  App app = new App(ctx);
  app.setJob(job);
  TasksBlockForTest taskBlock = new TasksBlockForTest(app);
  taskBlock.addParameter(AMParams.TASK_TYPE, "m");

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

  taskBlock.render(html);
  pWriter.flush();
  assertTrue(data.toString().contains("task_0_0001_m_000000"));
  assertTrue(data.toString().contains("70.00"));
  assertTrue(data.toString().contains("SUCCEEDED"));
  assertTrue(data.toString().contains("100001"));
  assertTrue(data.toString().contains("100011"));
  assertFalse(data.toString().contains("Dummy Status \n*"));
  assertTrue(data.toString().contains("Dummy Status \\n*"));
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:55,代码来源:TestBlocks.java

示例9: testAttemptsBlock

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的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

示例10: testHsController

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的package包/类
/**
 * test HsController
 */

@Test
public void testHsController() throws Exception {
  AppContext ctx = mock(AppContext.class);
  ApplicationId appId = ApplicationIdPBImpl.newInstance(0,5);
  
  when(ctx.getApplicationID()).thenReturn(appId);

  AppForTest app = new AppForTest(ctx);
  Configuration config = new Configuration();
  RequestContext requestCtx = mock(RequestContext.class);
  HsControllerForTest controller = new HsControllerForTest(app, config,
          requestCtx);
  controller.index();
  assertEquals("JobHistory", controller.get(Params.TITLE, ""));
  assertEquals(HsJobPage.class, controller.jobPage());
  assertEquals(HsCountersPage.class, controller.countersPage());
  assertEquals(HsTasksPage.class, controller.tasksPage());
  assertEquals(HsTaskPage.class, controller.taskPage());
  assertEquals(HsAttemptsPage.class, controller.attemptsPage());

  controller.set(AMParams.JOB_ID, "job_01_01");
  controller.set(AMParams.TASK_ID, "task_01_01_m_01");
  controller.set(AMParams.TASK_TYPE, "m");
  controller.set(AMParams.ATTEMPT_STATE, "State");

  Job job = mock(Job.class);
  Task task = mock(Task.class);
  when(job.getTask(any(TaskId.class))).thenReturn(task);
  JobId jobID = MRApps.toJobID("job_01_01");
  when(ctx.getJob(jobID)).thenReturn(job);
  when(job.checkAccess(any(UserGroupInformation.class), any(JobACL.class)))
          .thenReturn(true);

  controller.job();
  assertEquals(HsJobPage.class, controller.getClazz());
  controller.jobCounters();
  assertEquals(HsCountersPage.class, controller.getClazz());
  controller.taskCounters();
  assertEquals(HsCountersPage.class, controller.getClazz());
  controller.tasks();
  assertEquals(HsTasksPage.class, controller.getClazz());
  controller.task();
  assertEquals(HsTaskPage.class, controller.getClazz());
  controller.attempts();
  assertEquals(HsAttemptsPage.class, controller.getClazz());

  assertEquals(HsConfPage.class, controller.confPage());
  assertEquals(HsAboutPage.class, controller.aboutPage());
  controller.about();
  assertEquals(HsAboutPage.class, controller.getClazz());
  controller.logs();
  assertEquals(HsLogsPage.class, controller.getClazz());
  controller.nmlogs();
  assertEquals(AggregatedLogsPage.class, controller.getClazz());

  assertEquals(HsSingleCounterPage.class, controller.singleCounterPage());
  controller.singleJobCounter();
  assertEquals(HsSingleCounterPage.class, controller.getClazz());
  controller.singleTaskCounter();
  assertEquals(HsSingleCounterPage.class, controller.getClazz());


}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:68,代码来源:TestBlocks.java

示例11: testTasksBlock

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的package包/类
/**
 * Test rendering for TasksBlock
 */
@Test
public void testTasksBlock() throws Exception {

  ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 1);
  JobId jobId = new JobIdPBImpl();
  jobId.setId(0);
  jobId.setAppId(appId);

  TaskId taskId = new TaskIdPBImpl();
  taskId.setId(0);
  taskId.setTaskType(TaskType.MAP);
  taskId.setJobId(jobId);
  Task task = mock(Task.class);
  when(task.getID()).thenReturn(taskId);
  TaskReport report = mock(TaskReport.class);
  when(report.getProgress()).thenReturn(0.7f);
  when(report.getTaskState()).thenReturn(TaskState.SUCCEEDED);
  when(report.getStartTime()).thenReturn(100001L);
  when(report.getFinishTime()).thenReturn(100011L);


  when(task.getReport()).thenReturn(report);
  when(task.getType()).thenReturn(TaskType.MAP);


  Map<TaskId, Task> tasks = new HashMap<TaskId, Task>();
  tasks.put(taskId, task);
  AppContext ctx = mock(AppContext.class);
  Job job = mock(Job.class);
  when(job.getTasks()).thenReturn(tasks);


  App app = new App(ctx);
  app.setJob(job);
  TasksBlockForTest taskBlock = new TasksBlockForTest(app);
  taskBlock.addParameter(AMParams.TASK_TYPE, "m");

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

  taskBlock.render(html);
  pWriter.flush();
  assertTrue(data.toString().contains("task_0_0001_m_000000"));
  assertTrue(data.toString().contains("70.00"));
  assertTrue(data.toString().contains("SUCCEEDED"));
  assertTrue(data.toString().contains("100001"));
  assertTrue(data.toString().contains("100011"));


}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:54,代码来源:TestBlocks.java

示例12: testAttemptsBlock

import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl; //导入方法依赖的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.yarn.api.records.impl.pb.ApplicationIdPBImpl.newInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。