Search in sources :

Example 1 with HistoryContext

use of org.apache.hadoop.mapreduce.v2.hs.HistoryContext in project hadoop by apache.

the class JobHistoryServer method serviceInit.

@Override
protected void serviceInit(Configuration conf) throws Exception {
    Configuration config = new YarnConfiguration(conf);
    config.setBoolean(Dispatcher.DISPATCHER_EXIT_ON_ERROR_KEY, true);
    // This is required for WebApps to use https if enabled.
    MRWebAppUtil.initialize(getConfig());
    try {
        doSecureLogin(conf);
    } catch (IOException ie) {
        throw new YarnRuntimeException("History Server Failed to login", ie);
    }
    jobHistoryService = new JobHistory();
    historyContext = (HistoryContext) jobHistoryService;
    stateStore = createStateStore(conf);
    this.jhsDTSecretManager = createJHSSecretManager(conf, stateStore);
    clientService = createHistoryClientService();
    aggLogDelService = new AggregatedLogDeletionService();
    hsAdminServer = new HSAdminServer(aggLogDelService, jobHistoryService);
    addService(stateStore);
    addService(new HistoryServerSecretManagerService());
    addService(jobHistoryService);
    addService(clientService);
    addService(aggLogDelService);
    addService(hsAdminServer);
    DefaultMetricsSystem.initialize("JobHistoryServer");
    JvmMetrics jm = JvmMetrics.initSingleton("JobHistoryServer", null);
    pauseMonitor = new JvmPauseMonitor();
    addService(pauseMonitor);
    jm.setPauseMonitor(pauseMonitor);
    super.serviceInit(config);
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) HSAdminServer(org.apache.hadoop.mapreduce.v2.hs.server.HSAdminServer) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) JvmMetrics(org.apache.hadoop.metrics2.source.JvmMetrics) AggregatedLogDeletionService(org.apache.hadoop.yarn.logaggregation.AggregatedLogDeletionService) IOException(java.io.IOException) JvmPauseMonitor(org.apache.hadoop.util.JvmPauseMonitor)

Example 2 with HistoryContext

use of org.apache.hadoop.mapreduce.v2.hs.HistoryContext in project hadoop by apache.

the class TestJobHistoryEvents method testEventsFlushOnStop.

/**
   * Verify that all the events are flushed on stopping the HistoryHandler
   * @throws Exception
   */
@Test
public void testEventsFlushOnStop() throws Exception {
    Configuration conf = new Configuration();
    MRApp app = new MRAppWithSpecialHistoryHandler(1, 0, true, this.getClass().getName(), true);
    app.submit(conf);
    Job job = app.getContext().getAllJobs().values().iterator().next();
    JobId jobId = job.getID();
    LOG.info("JOBID is " + TypeConverter.fromYarn(jobId).toString());
    app.waitForState(job, JobState.SUCCEEDED);
    // make sure all events are flushed
    app.waitForState(Service.STATE.STOPPED);
    /*
     * Use HistoryContext to read logged events and verify the number of
     * completed maps
     */
    HistoryContext context = new JobHistory();
    ((JobHistory) context).init(conf);
    Job parsedJob = context.getJob(jobId);
    Assert.assertEquals("CompletedMaps not correct", 1, parsedJob.getCompletedMaps());
    Map<TaskId, Task> tasks = parsedJob.getTasks();
    Assert.assertEquals("No of tasks not correct", 1, tasks.size());
    verifyTask(tasks.values().iterator().next());
    Map<TaskId, Task> maps = parsedJob.getTasks(TaskType.MAP);
    Assert.assertEquals("No of maps not correct", 1, maps.size());
    Assert.assertEquals("Job state not currect", JobState.SUCCEEDED, parsedJob.getState());
}
Also used : Task(org.apache.hadoop.mapreduce.v2.app.job.Task) TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) Configuration(org.apache.hadoop.conf.Configuration) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId) MRApp(org.apache.hadoop.mapreduce.v2.app.MRApp) Test(org.junit.Test)

Example 3 with HistoryContext

use of org.apache.hadoop.mapreduce.v2.hs.HistoryContext in project hadoop by apache.

the class TestJobHistoryEvents method testAssignedQueue.

@Test
public void testAssignedQueue() throws Exception {
    Configuration conf = new Configuration();
    MRApp app = new MRAppWithHistory(2, 1, true, this.getClass().getName(), true, "assignedQueue");
    app.submit(conf);
    Job job = app.getContext().getAllJobs().values().iterator().next();
    JobId jobId = job.getID();
    LOG.info("JOBID is " + TypeConverter.fromYarn(jobId).toString());
    app.waitForState(job, JobState.SUCCEEDED);
    //make sure all events are flushed 
    app.waitForState(Service.STATE.STOPPED);
    /*
     * Use HistoryContext to read logged events and verify the number of 
     * completed maps 
    */
    HistoryContext context = new JobHistory();
    // test start and stop states
    ((JobHistory) context).init(conf);
    ((JobHistory) context).start();
    Assert.assertTrue(context.getStartTime() > 0);
    Assert.assertEquals(((JobHistory) context).getServiceState(), Service.STATE.STARTED);
    // get job before stopping JobHistory
    Job parsedJob = context.getJob(jobId);
    // stop JobHistory
    ((JobHistory) context).stop();
    Assert.assertEquals(((JobHistory) context).getServiceState(), Service.STATE.STOPPED);
    Assert.assertEquals("QueueName not correct", "assignedQueue", parsedJob.getQueueName());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId) MRApp(org.apache.hadoop.mapreduce.v2.app.MRApp) Test(org.junit.Test)

Example 4 with HistoryContext

use of org.apache.hadoop.mapreduce.v2.hs.HistoryContext in project hadoop by apache.

the class TestHsWebServicesAcls method buildHistoryContext.

private static HistoryContext buildHistoryContext(final Configuration conf) throws IOException {
    HistoryContext ctx = new MockHistoryContext(1, 1, 1);
    Map<JobId, Job> jobs = ctx.getAllJobs();
    JobId jobId = jobs.keySet().iterator().next();
    Job mockJob = new MockJobForAcls(jobs.get(jobId), conf);
    jobs.put(jobId, mockJob);
    return ctx;
}
Also used : MockHistoryContext(org.apache.hadoop.mapreduce.v2.hs.MockHistoryContext) HistoryContext(org.apache.hadoop.mapreduce.v2.hs.HistoryContext) MockHistoryContext(org.apache.hadoop.mapreduce.v2.hs.MockHistoryContext) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId)

Example 5 with HistoryContext

use of org.apache.hadoop.mapreduce.v2.hs.HistoryContext in project hadoop by apache.

the class TestJobHistoryEvents method testHistoryEvents.

@Test
public void testHistoryEvents() throws Exception {
    Configuration conf = new Configuration();
    MRApp app = new MRAppWithHistory(2, 1, true, this.getClass().getName(), true);
    app.submit(conf);
    Job job = app.getContext().getAllJobs().values().iterator().next();
    JobId jobId = job.getID();
    LOG.info("JOBID is " + TypeConverter.fromYarn(jobId).toString());
    app.waitForState(job, JobState.SUCCEEDED);
    //make sure all events are flushed 
    app.waitForState(Service.STATE.STOPPED);
    /*
     * Use HistoryContext to read logged events and verify the number of 
     * completed maps 
    */
    HistoryContext context = new JobHistory();
    // test start and stop states
    ((JobHistory) context).init(conf);
    ((JobHistory) context).start();
    Assert.assertTrue(context.getStartTime() > 0);
    Assert.assertEquals(((JobHistory) context).getServiceState(), Service.STATE.STARTED);
    // get job before stopping JobHistory
    Job parsedJob = context.getJob(jobId);
    // stop JobHistory
    ((JobHistory) context).stop();
    Assert.assertEquals(((JobHistory) context).getServiceState(), Service.STATE.STOPPED);
    Assert.assertEquals("CompletedMaps not correct", 2, parsedJob.getCompletedMaps());
    Assert.assertEquals(System.getProperty("user.name"), parsedJob.getUserName());
    Map<TaskId, Task> tasks = parsedJob.getTasks();
    Assert.assertEquals("No of tasks not correct", 3, tasks.size());
    for (Task task : tasks.values()) {
        verifyTask(task);
    }
    Map<TaskId, Task> maps = parsedJob.getTasks(TaskType.MAP);
    Assert.assertEquals("No of maps not correct", 2, maps.size());
    Map<TaskId, Task> reduces = parsedJob.getTasks(TaskType.REDUCE);
    Assert.assertEquals("No of reduces not correct", 1, reduces.size());
    Assert.assertEquals("CompletedReduce not correct", 1, parsedJob.getCompletedReduces());
    Assert.assertEquals("Job state not currect", JobState.SUCCEEDED, parsedJob.getState());
}
Also used : Task(org.apache.hadoop.mapreduce.v2.app.job.Task) TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) Configuration(org.apache.hadoop.conf.Configuration) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId) MRApp(org.apache.hadoop.mapreduce.v2.app.MRApp) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)5 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)4 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)4 Test (org.junit.Test)4 MRApp (org.apache.hadoop.mapreduce.v2.app.MRApp)3 IOException (java.io.IOException)2 TaskId (org.apache.hadoop.mapreduce.v2.api.records.TaskId)2 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 JobConf (org.apache.hadoop.mapred.JobConf)1 MRClientProtocol (org.apache.hadoop.mapreduce.v2.api.MRClientProtocol)1 GetJobReportRequest (org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetJobReportRequest)1 HistoryClientService (org.apache.hadoop.mapreduce.v2.hs.HistoryClientService)1 HistoryContext (org.apache.hadoop.mapreduce.v2.hs.HistoryContext)1 HistoryServerStateStoreService (org.apache.hadoop.mapreduce.v2.hs.HistoryServerStateStoreService)1 JHSDelegationTokenSecretManager (org.apache.hadoop.mapreduce.v2.hs.JHSDelegationTokenSecretManager)1 JobHistoryServer (org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer)1 MockHistoryContext (org.apache.hadoop.mapreduce.v2.hs.MockHistoryContext)1 HSAdminServer (org.apache.hadoop.mapreduce.v2.hs.server.HSAdminServer)1 JvmMetrics (org.apache.hadoop.metrics2.source.JvmMetrics)1