Search in sources :

Example 16 with MockAppContext

use of org.apache.hadoop.mapreduce.v2.app.MockAppContext in project hadoop by apache.

the class TestAMWebApp method testTaskView.

@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);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) MRApp(org.apache.hadoop.mapreduce.v2.app.MRApp) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Test(org.junit.Test)

Example 17 with MockAppContext

use of org.apache.hadoop.mapreduce.v2.app.MockAppContext in project hadoop by apache.

the class TestAMWebApp method testSingleCounterView.

@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);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Task(org.apache.hadoop.mapreduce.v2.app.job.Task) TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) Test(org.junit.Test)

Example 18 with MockAppContext

use of org.apache.hadoop.mapreduce.v2.app.MockAppContext in project hadoop by apache.

the class TestAMWebApp method testAppControllerIndex.

@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, ""));
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Injector(com.google.inject.Injector) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Test(org.junit.Test)

Example 19 with MockAppContext

use of org.apache.hadoop.mapreduce.v2.app.MockAppContext in project hadoop by apache.

the class TestAMWebApp method testTasksView.

@Test
public void testTasksView() {
    AppContext appContext = new MockAppContext(0, 1, 1, 1);
    Map<String, String> params = getTaskParams(appContext);
    WebAppTests.testPage(TasksPage.class, AppContext.class, appContext, params);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Test(org.junit.Test)

Example 20 with MockAppContext

use of org.apache.hadoop.mapreduce.v2.app.MockAppContext in project hadoop by apache.

the class TestAMWebApp method testSingleTaskCounterView.

@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);
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Task(org.apache.hadoop.mapreduce.v2.app.job.Task) TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) TaskAttempt(org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) Test(org.junit.Test)

Aggregations

MockAppContext (org.apache.hadoop.mapreduce.v2.app.MockAppContext)25 Test (org.junit.Test)25 AppContext (org.apache.hadoop.mapreduce.v2.app.AppContext)17 Injector (com.google.inject.Injector)8 PrintWriter (java.io.PrintWriter)4 HashMap (java.util.HashMap)4 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)3 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)2 TaskId (org.apache.hadoop.mapreduce.v2.api.records.TaskId)2 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)2 View (org.apache.hadoop.yarn.webapp.View)2 AbstractModule (com.google.inject.AbstractModule)1 Configuration (org.apache.hadoop.conf.Configuration)1 MRApp (org.apache.hadoop.mapreduce.v2.app.MRApp)1 RunningAppContext (org.apache.hadoop.mapreduce.v2.app.MRAppMaster.RunningAppContext)1 TaskAttempt (org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1