JobHistoryServer extends CompositeService { @Private public HistoryClientService getClientService() { return this.clientService; } JobHistoryServer(); static InetSocketAddress getBindAddress(Configuration conf); @Private HistoryClientService getClientService(); static void main(String[] args); static final int SHUTDOWN_HOOK_PRIORITY; static final long historyServerTimeStamp; }
@Test (timeout= 50000 ) public void testStartStopServer() throws Exception { historyServer = new JobHistoryServer(); Configuration config = new Configuration(); historyServer.init(config); assertEquals(STATE.INITED, historyServer.getServiceState()); HistoryClientService historyService = historyServer.getClientService(); assertNotNull(historyServer.getClientService()); assertEquals(STATE.INITED, historyService.getServiceState()); historyServer.start(); assertEquals(STATE.STARTED, historyServer.getServiceState()); assertEquals(STATE.STARTED, historyService.getServiceState()); historyServer.stop(); assertEquals(STATE.STOPPED, historyServer.getServiceState()); assertNotNull(historyService.getClientHandler().getConnectAddress()); }
@Test (timeout= 50000 ) public void testReports() throws Exception { Configuration config = new Configuration(); config .setClass( CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY, MyResolver.class, DNSToSwitchMapping.class); RackResolver.init(config); MRApp app = new MRAppWithHistory(1, 1, true, this.getClass().getName(), true); app.submit(config); Job job = app.getContext().getAllJobs().values().iterator().next(); app.waitForState(job, JobState.SUCCEEDED); historyServer = new JobHistoryServer(); historyServer.init(config); historyServer.start(); JobHistory jobHistory= null; for (Service service : historyServer.getServices() ) { if (service instanceof JobHistory) { jobHistory = (JobHistory) service; } }; Map<JobId, Job> jobs= jobHistory.getAllJobs(); assertEquals(1, jobs.size()); assertEquals("job_0_0000",jobs.keySet().iterator().next().toString()); Task task = job.getTasks().values().iterator().next(); TaskAttempt attempt = task.getAttempts().values().iterator().next(); HistoryClientService historyService = historyServer.getClientService(); MRClientProtocol protocol = historyService.getClientHandler(); GetTaskAttemptReportRequest gtarRequest = recordFactory .newRecordInstance(GetTaskAttemptReportRequest.class); TaskAttemptId taId = attempt.getID(); taId.setTaskId(task.getID()); taId.getTaskId().setJobId(job.getID()); gtarRequest.setTaskAttemptId(taId); GetTaskAttemptReportResponse response = protocol .getTaskAttemptReport(gtarRequest); assertEquals("container_0_0000_01_000000", response.getTaskAttemptReport() .getContainerId().toString()); assertTrue(response.getTaskAttemptReport().getDiagnosticInfo().isEmpty()); assertNotNull(response.getTaskAttemptReport().getCounters() .getCounter(TaskCounter.PHYSICAL_MEMORY_BYTES)); assertEquals(taId.toString(), response.getTaskAttemptReport() .getTaskAttemptId().toString()); GetTaskReportRequest request = recordFactory .newRecordInstance(GetTaskReportRequest.class); TaskId taskId = task.getID(); taskId.setJobId(job.getID()); request.setTaskId(taskId); GetTaskReportResponse reportResponse = protocol.getTaskReport(request); assertEquals("", reportResponse.getTaskReport().getDiagnosticsList() .iterator().next()); assertEquals(1.0f, reportResponse.getTaskReport().getProgress(), 0.01); assertEquals(taskId.toString(), reportResponse.getTaskReport().getTaskId() .toString()); assertEquals(TaskState.SUCCEEDED, reportResponse.getTaskReport() .getTaskState()); GetTaskReportsRequest gtreportsRequest = recordFactory.newRecordInstance(GetTaskReportsRequest.class); gtreportsRequest.setJobId(TypeConverter.toYarn(JobID .forName("job_1415730144495_0001"))); gtreportsRequest.setTaskType(TaskType.REDUCE); try { protocol.getTaskReports(gtreportsRequest); fail("IOException not thrown for invalid job id"); } catch (IOException e) { } GetTaskAttemptCompletionEventsRequest taskAttemptRequest = recordFactory .newRecordInstance(GetTaskAttemptCompletionEventsRequest.class); taskAttemptRequest.setJobId(job.getID()); GetTaskAttemptCompletionEventsResponse taskAttemptCompletionEventsResponse = protocol .getTaskAttemptCompletionEvents(taskAttemptRequest); assertEquals(0, taskAttemptCompletionEventsResponse.getCompletionEventCount()); GetDiagnosticsRequest diagnosticRequest = recordFactory .newRecordInstance(GetDiagnosticsRequest.class); diagnosticRequest.setTaskAttemptId(taId); GetDiagnosticsResponse diagnosticResponse = protocol .getDiagnostics(diagnosticRequest); assertEquals(1, diagnosticResponse.getDiagnosticsCount()); assertEquals("", diagnosticResponse.getDiagnostics(0)); }
@Test (timeout= 50000 ) public void testStartStopServer() throws Exception { historyServer = new JobHistoryServer(); Configuration config = new Configuration(); historyServer.init(config); assertEquals(STATE.INITED, historyServer.getServiceState()); assertEquals(6, historyServer.getServices().size()); HistoryClientService historyService = historyServer.getClientService(); assertNotNull(historyServer.getClientService()); assertEquals(STATE.INITED, historyService.getServiceState()); historyServer.start(); assertEquals(STATE.STARTED, historyServer.getServiceState()); assertEquals(STATE.STARTED, historyService.getServiceState()); historyServer.stop(); assertEquals(STATE.STOPPED, historyServer.getServiceState()); assertNotNull(historyService.getClientHandler().getConnectAddress()); }
@Test (timeout= 50000 ) public void testReports() throws Exception { Configuration config = new Configuration(); config .setClass( CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY, MyResolver.class, DNSToSwitchMapping.class); RackResolver.init(config); MRApp app = new MRAppWithHistory(1, 1, true, this.getClass().getName(), true); app.submit(config); Job job = app.getContext().getAllJobs().values().iterator().next(); app.waitForState(job, JobState.SUCCEEDED); historyServer = new JobHistoryServer(); historyServer.init(config); historyServer.start(); JobHistory jobHistory= null; for (Service service : historyServer.getServices() ) { if (service instanceof JobHistory) { jobHistory = (JobHistory) service; } }; Map<JobId, Job> jobs= jobHistory.getAllJobs(); assertEquals(1, jobs.size()); assertEquals("job_0_0000",jobs.keySet().iterator().next().toString()); Task task = job.getTasks().values().iterator().next(); TaskAttempt attempt = task.getAttempts().values().iterator().next(); HistoryClientService historyService = historyServer.getClientService(); MRClientProtocol protocol = historyService.getClientHandler(); GetTaskAttemptReportRequest gtarRequest = recordFactory .newRecordInstance(GetTaskAttemptReportRequest.class); TaskAttemptId taId = attempt.getID(); taId.setTaskId(task.getID()); taId.getTaskId().setJobId(job.getID()); gtarRequest.setTaskAttemptId(taId); GetTaskAttemptReportResponse response = protocol .getTaskAttemptReport(gtarRequest); assertEquals("container_0_0000_01_000000", response.getTaskAttemptReport() .getContainerId().toString()); assertTrue(response.getTaskAttemptReport().getDiagnosticInfo().isEmpty()); assertNotNull(response.getTaskAttemptReport().getCounters() .getCounter(TaskCounter.PHYSICAL_MEMORY_BYTES)); assertEquals(taId.toString(), response.getTaskAttemptReport() .getTaskAttemptId().toString()); GetTaskReportRequest request = recordFactory .newRecordInstance(GetTaskReportRequest.class); TaskId taskId = task.getID(); taskId.setJobId(job.getID()); request.setTaskId(taskId); GetTaskReportResponse reportResponse = protocol.getTaskReport(request); assertEquals("", reportResponse.getTaskReport().getDiagnosticsList() .iterator().next()); assertEquals(1.0f, reportResponse.getTaskReport().getProgress(), 0.01); assertEquals(taskId.toString(), reportResponse.getTaskReport().getTaskId() .toString()); assertEquals(TaskState.SUCCEEDED, reportResponse.getTaskReport() .getTaskState()); GetTaskAttemptCompletionEventsRequest taskAttemptRequest = recordFactory .newRecordInstance(GetTaskAttemptCompletionEventsRequest.class); taskAttemptRequest.setJobId(job.getID()); GetTaskAttemptCompletionEventsResponse taskAttemptCompletionEventsResponse = protocol .getTaskAttemptCompletionEvents(taskAttemptRequest); assertEquals(0, taskAttemptCompletionEventsResponse.getCompletionEventCount()); GetDiagnosticsRequest diagnosticRequest = recordFactory .newRecordInstance(GetDiagnosticsRequest.class); diagnosticRequest.setTaskAttemptId(taId); GetDiagnosticsResponse diagnosticResponse = protocol .getDiagnostics(diagnosticRequest); assertEquals(1, diagnosticResponse.getDiagnosticsCount()); assertEquals("", diagnosticResponse.getDiagnostics(0)); }