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


Java MockAppContext类代码示例

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


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

示例1: testSingleTaskCounterView

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test public void testSingleTaskCounterView() {
  AppContext appContext = new MockAppContext(0, 1, 1, 2);
  Map<String, String> params = getTaskParams(appContext);
  params.put(AMParams.COUNTER_GROUP, 
      "org.apache.hadoop.mapreduce.FileSystemCounter");
  params.put(AMParams.COUNTER_NAME, "HDFS_WRITE_OPS");
  
  // remove counters from one task attempt
  // to test handling of missing counters
  TaskId taskID = MRApps.toTaskID(params.get(AMParams.TASK_ID));
  Job job = appContext.getJob(taskID.getJobId());
  Task task = job.getTask(taskID);
  TaskAttempt attempt = task.getAttempts().values().iterator().next();
  attempt.getReport().setCounters(null);
  
  WebAppTests.testPage(SingleCounterPage.class, AppContext.class,
                       appContext, params);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestAMWebApp.java

示例2: testLogsView2

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test
public void testLogsView2() throws IOException {
  LOG.info("HsLogsPage with data");
  MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
  Map<String, String> params = new HashMap<String, String>();

  params.put(CONTAINER_ID, MRApp.newContainerId(1, 1, 333, 1)
      .toString());
  params.put(NM_NODENAME, 
      NodeId.newInstance(MockJobs.NM_HOST, MockJobs.NM_PORT).toString());
  params.put(ENTITY_STRING, "container_10_0001_01_000001");
  params.put(APP_OWNER, "owner");

  Injector injector =
      WebAppTests.testPage(AggregatedLogsPage.class, AppContext.class, ctx,
          params);
  PrintWriter spyPw = WebAppTests.getPrintWriter(injector);
  verify(spyPw).write(
      "Aggregation is not enabled. Try the nodemanager at "
          + MockJobs.NM_HOST + ":" + MockJobs.NM_PORT);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestHSWebApp.java

示例3: testLogsViewBadStartEnd

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test
public void testLogsViewBadStartEnd() throws IOException {
  LOG.info("HsLogsPage with bad start/end params");
  MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
  Map<String, String> params = new HashMap<String, String>();

  params.put("start", "foo");
  params.put("end", "bar");
  params.put(CONTAINER_ID, MRApp.newContainerId(1, 1, 333, 1)
      .toString());
  params.put(NM_NODENAME,
      NodeId.newInstance(MockJobs.NM_HOST, MockJobs.NM_PORT).toString());
  params.put(ENTITY_STRING, "container_10_0001_01_000001");
  params.put(APP_OWNER, "owner");

  Injector injector =
      WebAppTests.testPage(AggregatedLogsPage.class, AppContext.class, ctx,
          params);
  PrintWriter spyPw = WebAppTests.getPrintWriter(injector);
  verify(spyPw).write("Invalid log start value: foo");
  verify(spyPw).write("Invalid log end value: bar");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestHSWebApp.java

示例4: configureServlets

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Override
protected void configureServlets() {

  appContext = new MockAppContext(0, 1, 2, 1);
  bind(JAXBContextResolver.class);
  bind(AMWebServices.class);
  bind(GenericExceptionHandler.class);
  bind(AppContext.class).toInstance(appContext);
  bind(Configuration.class).toInstance(conf);

  serve("/*").with(GuiceContainer.class);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:TestAMWebServicesTasks.java

示例5: configureServlets

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Override
protected void configureServlets() {

  Path confPath = new Path(testConfDir.toString(),
      MRJobConfig.JOB_CONF_FILE);
  Configuration config = new Configuration();

  FileSystem localFs;
  try {
    localFs = FileSystem.getLocal(config);
    confPath = localFs.makeQualified(confPath);

    OutputStream out = localFs.create(confPath);
    try {
      conf.writeXml(out);
    } finally {
      out.close();
    }
    if (!localFs.exists(confPath)) {
      fail("error creating config file: " + confPath);
    }

  } catch (IOException e) {
    fail("error creating config file: " + e.getMessage());
  }

  appContext = new MockAppContext(0, 2, 1, confPath);

  bind(JAXBContextResolver.class);
  bind(AMWebServices.class);
  bind(GenericExceptionHandler.class);
  bind(AppContext.class).toInstance(appContext);
  bind(Configuration.class).toInstance(conf);

  serve("/*").with(GuiceContainer.class);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:TestAMWebServicesJobConf.java

示例6: configureServlets

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Override
protected void configureServlets() {

  appContext = new MockAppContext(0, 1, 1, 1);
  appContext.setBlacklistedNodes(Sets.newHashSet("badnode1", "badnode2"));
  
  bind(JAXBContextResolver.class);
  bind(AMWebServices.class);
  bind(GenericExceptionHandler.class);
  bind(AppContext.class).toInstance(appContext);
  bind(Configuration.class).toInstance(conf);

  serve("/*").with(GuiceContainer.class);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestAMWebServices.java

示例7: testAppControllerIndex

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test public void testAppControllerIndex() {
  AppContext ctx = new MockAppContext(0, 1, 1, 1);
  Injector injector = WebAppTests.createMockInjector(AppContext.class, ctx);
  AppController controller = injector.getInstance(AppController.class);
  controller.index();
  assertEquals(ctx.getApplicationID().toString(), controller.get(APP_ID,""));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:TestAMWebApp.java

示例8: testTaskView

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test public void testTaskView() {
  AppContext appContext = new MockAppContext(0, 1, 1, 1);
  Map<String, String> params = getTaskParams(appContext);
  App app = new App(appContext);
  app.setJob(appContext.getAllJobs().values().iterator().next());
  app.setTask(app.getJob().getTasks().values().iterator().next());
  WebAppTests.testPage(TaskPage.class, App.class, app, params);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TestAMWebApp.java

示例9: testSingleCounterView

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test public void testSingleCounterView() {
  AppContext appContext = new MockAppContext(0, 1, 1, 1);
  Job job = appContext.getAllJobs().values().iterator().next();
  // add a failed task to the job without any counters
  Task failedTask = MockJobs.newTask(job.getID(), 2, 1, true);
  Map<TaskId,Task> tasks = job.getTasks();
  tasks.put(failedTask.getID(), failedTask);
  Map<String, String> params = getJobParams(appContext);
  params.put(AMParams.COUNTER_GROUP, 
      "org.apache.hadoop.mapreduce.FileSystemCounter");
  params.put(AMParams.COUNTER_NAME, "HDFS_WRITE_OPS");
  WebAppTests.testPage(SingleCounterPage.class, AppContext.class,
                       appContext, params);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestAMWebApp.java

示例10: testAppControllerIndex

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test public void testAppControllerIndex() {
  MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
  Injector injector = WebAppTests.createMockInjector(AppContext.class, ctx);
  HsController controller = injector.getInstance(HsController.class);
  controller.index();
  assertEquals(ctx.getApplicationID().toString(), controller.get(APP_ID,""));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:TestHSWebApp.java

示例11: testTasksView

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test
public void testTasksView() {
  LOG.info("HsTasksPage");
  AppContext appContext = new MockAppContext(0, 1, 1, 1);
  Map<String, String> params = TestAMWebApp.getTaskParams(appContext);
  WebAppTests.testPage(HsTasksPage.class, AppContext.class, appContext,
      params);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TestHSWebApp.java

示例12: testTaskView

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test
public void testTaskView() {
  LOG.info("HsTaskPage");
  AppContext appContext = new MockAppContext(0, 1, 1, 1);
  Map<String, String> params = TestAMWebApp.getTaskParams(appContext);
  WebAppTests
      .testPage(HsTaskPage.class, AppContext.class, appContext, params);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TestHSWebApp.java

示例13: testAttemptsWithJobView

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test public void testAttemptsWithJobView() {
  LOG.info("HsAttemptsPage with data");
  MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
  JobId id = ctx.getAllJobs().keySet().iterator().next();
  Map<String, String> params = new HashMap<String,String>();
  params.put(JOB_ID, id.toString());
  params.put(TASK_TYPE, "m");
  params.put(ATTEMPT_STATE, "SUCCESSFUL");
  WebAppTests.testPage(HsAttemptsPage.class, AppContext.class,
      ctx, params);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestHSWebApp.java

示例14: testAttemptsView

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test public void testAttemptsView() {
  LOG.info("HsAttemptsPage");
  AppContext appContext = new MockAppContext(0, 1, 1, 1);
  Map<String, String> params = TestAMWebApp.getTaskParams(appContext);
  WebAppTests.testPage(HsAttemptsPage.class, AppContext.class,
                       appContext, params);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:TestHSWebApp.java

示例15: testJobCounterView

import org.apache.hadoop.mapreduce.v2.app.MockAppContext; //导入依赖的package包/类
@Test public void testJobCounterView() {
  LOG.info("JobCounterView");
  AppContext appContext = new MockAppContext(0, 1, 1, 1);
  Map<String, String> params = TestAMWebApp.getJobParams(appContext);
  WebAppTests.testPage(HsCountersPage.class, AppContext.class,
                       appContext, params);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:TestHSWebApp.java


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