Java Code Examples for org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetJobReportResponse

The following examples show how to use org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetJobReportResponse. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   Source File: MRClientService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request) 
  throws IOException {
  JobId jobId = request.getJobId();
  // false is for retain compatibility
  Job job = verifyAndGetJob(jobId, JobACL.VIEW_JOB, false);
  GetJobReportResponse response = 
    recordFactory.newRecordInstance(GetJobReportResponse.class);
  if (job != null) {
    response.setJobReport(job.getReport());
  }
  else {
    response.setJobReport(null);
  }
  return response;
}
 
Example 2
Source Project: hadoop   Source File: NotRunningJob.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {
  JobReport jobReport =
    recordFactory.newRecordInstance(JobReport.class);
  jobReport.setJobId(request.getJobId());
  jobReport.setJobState(jobState);
  jobReport.setUser(applicationReport.getUser());
  jobReport.setStartTime(applicationReport.getStartTime());
  jobReport.setDiagnostics(applicationReport.getDiagnostics());
  jobReport.setJobName(applicationReport.getName());
  jobReport.setTrackingUrl(applicationReport.getTrackingUrl());
  jobReport.setFinishTime(applicationReport.getFinishTime());

  GetJobReportResponse resp =
      recordFactory.newRecordInstance(GetJobReportResponse.class);
  resp.setJobReport(jobReport);
  return resp;
}
 
Example 3
Source Project: hadoop   Source File: ClientServiceDelegate.java    License: Apache License 2.0 6 votes vote down vote up
public JobStatus getJobStatus(JobID oldJobID) throws IOException {
  org.apache.hadoop.mapreduce.v2.api.records.JobId jobId =
    TypeConverter.toYarn(oldJobID);
  GetJobReportRequest request =
      recordFactory.newRecordInstance(GetJobReportRequest.class);
  request.setJobId(jobId);
  JobReport report = ((GetJobReportResponse) invoke("getJobReport",
      GetJobReportRequest.class, request)).getJobReport();
  JobStatus jobStatus = null;
  if (report != null) {
    if (StringUtils.isEmpty(report.getJobFile())) {
      String jobFile = MRApps.getJobFile(conf, report.getUser(), oldJobID);
      report.setJobFile(jobFile);
    }
    String historyTrackingUrl = report.getTrackingUrl();
    String url = StringUtils.isNotEmpty(historyTrackingUrl)
        ? historyTrackingUrl : trackingUrl;
    jobStatus = TypeConverter.fromYarn(report, url);
  }
  return jobStatus;
}
 
Example 4
Source Project: hadoop   Source File: TestClientRedirect.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {

  amContact = true;

  JobReport jobReport = recordFactory.newRecordInstance(JobReport.class);
  jobReport.setJobId(request.getJobId());
  jobReport.setJobState(JobState.RUNNING);
  jobReport.setJobName("TestClientRedirect-jobname");
  jobReport.setUser("TestClientRedirect-user");
  jobReport.setStartTime(0L);
  jobReport.setFinishTime(1L);

  GetJobReportResponse response = recordFactory
      .newRecordInstance(GetJobReportResponse.class);
  response.setJobReport(jobReport);
  return response;
}
 
Example 5
Source Project: big-c   Source File: MRClientService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request) 
  throws IOException {
  JobId jobId = request.getJobId();
  // false is for retain compatibility
  Job job = verifyAndGetJob(jobId, JobACL.VIEW_JOB, false);
  GetJobReportResponse response = 
    recordFactory.newRecordInstance(GetJobReportResponse.class);
  if (job != null) {
    response.setJobReport(job.getReport());
  }
  else {
    response.setJobReport(null);
  }
  return response;
}
 
Example 6
Source Project: big-c   Source File: NotRunningJob.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {
  JobReport jobReport =
    recordFactory.newRecordInstance(JobReport.class);
  jobReport.setJobId(request.getJobId());
  jobReport.setJobState(jobState);
  jobReport.setUser(applicationReport.getUser());
  jobReport.setStartTime(applicationReport.getStartTime());
  jobReport.setDiagnostics(applicationReport.getDiagnostics());
  jobReport.setJobName(applicationReport.getName());
  jobReport.setTrackingUrl(applicationReport.getTrackingUrl());
  jobReport.setFinishTime(applicationReport.getFinishTime());

  GetJobReportResponse resp =
      recordFactory.newRecordInstance(GetJobReportResponse.class);
  resp.setJobReport(jobReport);
  return resp;
}
 
Example 7
Source Project: big-c   Source File: ClientServiceDelegate.java    License: Apache License 2.0 6 votes vote down vote up
public JobStatus getJobStatus(JobID oldJobID) throws IOException {
  org.apache.hadoop.mapreduce.v2.api.records.JobId jobId =
    TypeConverter.toYarn(oldJobID);
  GetJobReportRequest request =
      recordFactory.newRecordInstance(GetJobReportRequest.class);
  request.setJobId(jobId);
  JobReport report = ((GetJobReportResponse) invoke("getJobReport",
      GetJobReportRequest.class, request)).getJobReport();
  JobStatus jobStatus = null;
  if (report != null) {
    if (StringUtils.isEmpty(report.getJobFile())) {
      String jobFile = MRApps.getJobFile(conf, report.getUser(), oldJobID);
      report.setJobFile(jobFile);
    }
    String historyTrackingUrl = report.getTrackingUrl();
    String url = StringUtils.isNotEmpty(historyTrackingUrl)
        ? historyTrackingUrl : trackingUrl;
    jobStatus = TypeConverter.fromYarn(report, url);
  }
  return jobStatus;
}
 
Example 8
Source Project: big-c   Source File: TestClientRedirect.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {

  amContact = true;

  JobReport jobReport = recordFactory.newRecordInstance(JobReport.class);
  jobReport.setJobId(request.getJobId());
  jobReport.setJobState(JobState.RUNNING);
  jobReport.setJobName("TestClientRedirect-jobname");
  jobReport.setUser("TestClientRedirect-user");
  jobReport.setStartTime(0L);
  jobReport.setFinishTime(1L);

  GetJobReportResponse response = recordFactory
      .newRecordInstance(GetJobReportResponse.class);
  response.setJobReport(jobReport);
  return response;
}
 
Example 9
Source Project: incubator-tez   Source File: NotRunningJob.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {
  JobReport jobReport =
    recordFactory.newRecordInstance(JobReport.class);
  jobReport.setJobId(request.getJobId());
  jobReport.setJobState(jobState);
  jobReport.setUser(applicationReport.getUser());
  jobReport.setStartTime(applicationReport.getStartTime());
  jobReport.setDiagnostics(applicationReport.getDiagnostics());
  jobReport.setJobName(applicationReport.getName());
  jobReport.setTrackingUrl(applicationReport.getTrackingUrl());
  jobReport.setFinishTime(applicationReport.getFinishTime());

  GetJobReportResponse resp =
      recordFactory.newRecordInstance(GetJobReportResponse.class);
  resp.setJobReport(jobReport);
  return resp;
}
 
Example 10
Source Project: tez   Source File: NotRunningJob.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {
  JobReport jobReport =
    recordFactory.newRecordInstance(JobReport.class);
  jobReport.setJobId(request.getJobId());
  jobReport.setJobState(jobState);
  jobReport.setUser(applicationReport.getUser());
  jobReport.setStartTime(applicationReport.getStartTime());
  jobReport.setDiagnostics(applicationReport.getDiagnostics());
  jobReport.setJobName(applicationReport.getName());
  jobReport.setTrackingUrl(applicationReport.getTrackingUrl());
  jobReport.setFinishTime(applicationReport.getFinishTime());

  GetJobReportResponse resp =
      recordFactory.newRecordInstance(GetJobReportResponse.class);
  resp.setJobReport(jobReport);
  return resp;
}
 
Example 11
Source Project: hadoop   Source File: TestClientServiceDelegate.java    License: Apache License 2.0 5 votes vote down vote up
private GetJobReportResponse getJobReportResponse() {
  GetJobReportResponse jobReportResponse = Records
      .newRecord(GetJobReportResponse.class);
  JobReport jobReport = Records.newRecord(JobReport.class);
  jobReport.setJobId(jobId);
  jobReport.setJobState(JobState.SUCCEEDED);
  jobReportResponse.setJobReport(jobReport);
  return jobReportResponse;
}
 
Example 12
Source Project: hadoop   Source File: TestClientServiceDelegate.java    License: Apache License 2.0 5 votes vote down vote up
private GetJobReportResponse getJobReportResponseFromHistoryServer() {
  GetJobReportResponse jobReportResponse = Records                                              
      .newRecord(GetJobReportResponse.class);                                                   
  JobReport jobReport = Records.newRecord(JobReport.class);                                     
  jobReport.setJobId(jobId);                                                                    
  jobReport.setJobState(JobState.SUCCEEDED);                                                    
  jobReport.setMapProgress(1.0f);
  jobReport.setReduceProgress(1.0f);
  jobReport.setJobFile("TestJobFilePath");
  jobReport.setTrackingUrl("http://TestTrackingUrl");
  jobReportResponse.setJobReport(jobReport);
  return jobReportResponse;
}
 
Example 13
Source Project: hadoop   Source File: MRClientProtocolPBServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetJobReportResponseProto getJobReport(RpcController controller,
    GetJobReportRequestProto proto) throws ServiceException {
  GetJobReportRequestPBImpl request = new GetJobReportRequestPBImpl(proto);
  try {
    GetJobReportResponse response = real.getJobReport(request);
    return ((GetJobReportResponsePBImpl)response).getProto();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example 14
Source Project: hadoop   Source File: MRClientProtocolPBClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {
  GetJobReportRequestProto requestProto = ((GetJobReportRequestPBImpl)request).getProto();
  try {
    return new GetJobReportResponsePBImpl(proxy.getJobReport(null, requestProto));
  } catch (ServiceException e) {
    throw unwrapAndThrowException(e);
  }
}
 
Example 15
Source Project: hadoop   Source File: HistoryClientService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {
  JobId jobId = request.getJobId();
  Job job = verifyAndGetJob(jobId, false);
  GetJobReportResponse response = recordFactory.newRecordInstance(GetJobReportResponse.class);
  if (job != null) {
    response.setJobReport(job.getReport());
  }
  else {
    response.setJobReport(null);
  }
  return response;
}
 
Example 16
Source Project: big-c   Source File: TestClientServiceDelegate.java    License: Apache License 2.0 5 votes vote down vote up
private GetJobReportResponse getJobReportResponse() {
  GetJobReportResponse jobReportResponse = Records
      .newRecord(GetJobReportResponse.class);
  JobReport jobReport = Records.newRecord(JobReport.class);
  jobReport.setJobId(jobId);
  jobReport.setJobState(JobState.SUCCEEDED);
  jobReportResponse.setJobReport(jobReport);
  return jobReportResponse;
}
 
Example 17
Source Project: big-c   Source File: TestClientServiceDelegate.java    License: Apache License 2.0 5 votes vote down vote up
private GetJobReportResponse getJobReportResponseFromHistoryServer() {
  GetJobReportResponse jobReportResponse = Records                                              
      .newRecord(GetJobReportResponse.class);                                                   
  JobReport jobReport = Records.newRecord(JobReport.class);                                     
  jobReport.setJobId(jobId);                                                                    
  jobReport.setJobState(JobState.SUCCEEDED);                                                    
  jobReport.setMapProgress(1.0f);
  jobReport.setReduceProgress(1.0f);
  jobReport.setJobFile("TestJobFilePath");
  jobReport.setTrackingUrl("http://TestTrackingUrl");
  jobReportResponse.setJobReport(jobReport);
  return jobReportResponse;
}
 
Example 18
Source Project: big-c   Source File: MRClientProtocolPBServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetJobReportResponseProto getJobReport(RpcController controller,
    GetJobReportRequestProto proto) throws ServiceException {
  GetJobReportRequestPBImpl request = new GetJobReportRequestPBImpl(proto);
  try {
    GetJobReportResponse response = real.getJobReport(request);
    return ((GetJobReportResponsePBImpl)response).getProto();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example 19
Source Project: big-c   Source File: MRClientProtocolPBClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {
  GetJobReportRequestProto requestProto = ((GetJobReportRequestPBImpl)request).getProto();
  try {
    return new GetJobReportResponsePBImpl(proxy.getJobReport(null, requestProto));
  } catch (ServiceException e) {
    throw unwrapAndThrowException(e);
  }
}
 
Example 20
Source Project: big-c   Source File: HistoryClientService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {
  JobId jobId = request.getJobId();
  Job job = verifyAndGetJob(jobId, false);
  GetJobReportResponse response = recordFactory.newRecordInstance(GetJobReportResponse.class);
  if (job != null) {
    response.setJobReport(job.getReport());
  }
  else {
    response.setJobReport(null);
  }
  return response;
}
 
Example 21
/**
 * Given the required details (application id and suffix id) for JobId it gives the JobReport
 * @param appid, the Application Id instance
 * @param id, the suffix id
 * @return the Job Report
 * @throws IOException
 */
public JobReport getJobReport(ApplicationId appId, int id) throws IOException{
	JobId jobId = YarnCommunicatorUtil.getJobId(appId, (int)1);
	GetJobReportRequestProto proto = GetJobReportRequestProto.getDefaultInstance();
	GetJobReportRequest request = new GetJobReportRequestPBImpl(proto);
	request.setJobId(jobId);
	GetJobReportResponse jobReportResponse = proxy.getJobReport(request);
	return jobReportResponse.getJobReport();
}
 
Example 22
public JobReport getJobReport(JobId jobId) throws IOException {
	GetJobReportRequestProto proto = GetJobReportRequestProto.getDefaultInstance();
	GetJobReportRequest request = new GetJobReportRequestPBImpl(proto);
	request.setJobId(jobId);
	GetJobReportResponse jobReportResponse = proxy.getJobReport(request);
	return jobReportResponse.getJobReport();
}
 
Example 23
Source Project: hadoop   Source File: ClientServiceDelegate.java    License: Apache License 2.0 4 votes vote down vote up
public LogParams getLogFilePath(JobID oldJobID, TaskAttemptID oldTaskAttemptID)
    throws IOException {
  org.apache.hadoop.mapreduce.v2.api.records.JobId jobId =
      TypeConverter.toYarn(oldJobID);
  GetJobReportRequest request =
      recordFactory.newRecordInstance(GetJobReportRequest.class);
  request.setJobId(jobId);

  JobReport report =
      ((GetJobReportResponse) invoke("getJobReport",
          GetJobReportRequest.class, request)).getJobReport();
  if (EnumSet.of(JobState.SUCCEEDED, JobState.FAILED, JobState.KILLED,
      JobState.ERROR).contains(report.getJobState())) {
    if (oldTaskAttemptID != null) {
      GetTaskAttemptReportRequest taRequest =
          recordFactory.newRecordInstance(GetTaskAttemptReportRequest.class);
      taRequest.setTaskAttemptId(TypeConverter.toYarn(oldTaskAttemptID));
      TaskAttemptReport taReport =
          ((GetTaskAttemptReportResponse) invoke("getTaskAttemptReport",
              GetTaskAttemptReportRequest.class, taRequest))
              .getTaskAttemptReport();
      if (taReport.getContainerId() == null
          || taReport.getNodeManagerHost() == null) {
        throw new IOException("Unable to get log information for task: "
            + oldTaskAttemptID);
      }
      return new LogParams(
          taReport.getContainerId().toString(),
          taReport.getContainerId().getApplicationAttemptId()
              .getApplicationId().toString(),
          NodeId.newInstance(taReport.getNodeManagerHost(),
              taReport.getNodeManagerPort()).toString(), report.getUser());
    } else {
      if (report.getAMInfos() == null || report.getAMInfos().size() == 0) {
        throw new IOException("Unable to get log information for job: "
            + oldJobID);
      }
      AMInfo amInfo = report.getAMInfos().get(report.getAMInfos().size() - 1);
      return new LogParams(
          amInfo.getContainerId().toString(),
          amInfo.getAppAttemptId().getApplicationId().toString(),
          NodeId.newInstance(amInfo.getNodeManagerHost(),
              amInfo.getNodeManagerPort()).toString(), report.getUser());
    }
  } else {
    throw new IOException("Cannot get log path for a in-progress job");
  }
}
 
Example 24
Source Project: hadoop   Source File: TestClientServiceDelegate.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testReconnectOnAMRestart() throws IOException {
  //test not applicable when AM not reachable
  //as instantiateAMProxy is not called at all
  if(!isAMReachableFromClient) {
    return;
  }

  MRClientProtocol historyServerProxy = mock(MRClientProtocol.class);

  // RM returns AM1 url, null, null and AM2 url on invocations.
  // Nulls simulate the time when AM2 is in the process of restarting.
  ResourceMgrDelegate rmDelegate = mock(ResourceMgrDelegate.class);
  try {
    when(rmDelegate.getApplicationReport(jobId.getAppId())).thenReturn(
        getRunningApplicationReport("am1", 78)).thenReturn(
        getRunningApplicationReport(null, 0)).thenReturn(
        getRunningApplicationReport(null, 0)).thenReturn(
        getRunningApplicationReport("am2", 90));
  } catch (YarnException e) {
    throw new IOException(e);
  }

  GetJobReportResponse jobReportResponse1 = mock(GetJobReportResponse.class);
  when(jobReportResponse1.getJobReport()).thenReturn(
      MRBuilderUtils.newJobReport(jobId, "jobName-firstGen", "user",
          JobState.RUNNING, 0, 0, 0, 0, 0, 0, 0, "anything", null,
          false, ""));

  // First AM returns a report with jobName firstGen and simulates AM shutdown
  // on second invocation.
  MRClientProtocol firstGenAMProxy = mock(MRClientProtocol.class);
  when(firstGenAMProxy.getJobReport(any(GetJobReportRequest.class)))
      .thenReturn(jobReportResponse1).thenThrow(
          new RuntimeException("AM is down!"));

  GetJobReportResponse jobReportResponse2 = mock(GetJobReportResponse.class);
  when(jobReportResponse2.getJobReport()).thenReturn(
      MRBuilderUtils.newJobReport(jobId, "jobName-secondGen", "user",
          JobState.RUNNING, 0, 0, 0, 0, 0, 0, 0, "anything", null,
          false, ""));

  // Second AM generation returns a report with jobName secondGen
  MRClientProtocol secondGenAMProxy = mock(MRClientProtocol.class);
  when(secondGenAMProxy.getJobReport(any(GetJobReportRequest.class)))
      .thenReturn(jobReportResponse2);
  
  ClientServiceDelegate clientServiceDelegate = spy(getClientServiceDelegate(
      historyServerProxy, rmDelegate));
  // First time, connection should be to AM1, then to AM2. Further requests
  // should use the same proxy to AM2 and so instantiateProxy shouldn't be
  // called.
  doReturn(firstGenAMProxy).doReturn(secondGenAMProxy).when(
      clientServiceDelegate).instantiateAMProxy(any(InetSocketAddress.class));

  JobStatus jobStatus = clientServiceDelegate.getJobStatus(oldJobId);
  Assert.assertNotNull(jobStatus);
  Assert.assertEquals("jobName-firstGen", jobStatus.getJobName());

  jobStatus = clientServiceDelegate.getJobStatus(oldJobId);
  Assert.assertNotNull(jobStatus);
  Assert.assertEquals("jobName-secondGen", jobStatus.getJobName());

  jobStatus = clientServiceDelegate.getJobStatus(oldJobId);
  Assert.assertNotNull(jobStatus);
  Assert.assertEquals("jobName-secondGen", jobStatus.getJobName());

  verify(clientServiceDelegate, times(2)).instantiateAMProxy(
      any(InetSocketAddress.class));
}
 
Example 25
Source Project: hadoop   Source File: TestRPCFactories.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {
  return null;
}
 
Example 26
Source Project: big-c   Source File: ClientServiceDelegate.java    License: Apache License 2.0 4 votes vote down vote up
public LogParams getLogFilePath(JobID oldJobID, TaskAttemptID oldTaskAttemptID)
    throws IOException {
  org.apache.hadoop.mapreduce.v2.api.records.JobId jobId =
      TypeConverter.toYarn(oldJobID);
  GetJobReportRequest request =
      recordFactory.newRecordInstance(GetJobReportRequest.class);
  request.setJobId(jobId);

  JobReport report =
      ((GetJobReportResponse) invoke("getJobReport",
          GetJobReportRequest.class, request)).getJobReport();
  if (EnumSet.of(JobState.SUCCEEDED, JobState.FAILED, JobState.KILLED,
      JobState.ERROR).contains(report.getJobState())) {
    if (oldTaskAttemptID != null) {
      GetTaskAttemptReportRequest taRequest =
          recordFactory.newRecordInstance(GetTaskAttemptReportRequest.class);
      taRequest.setTaskAttemptId(TypeConverter.toYarn(oldTaskAttemptID));
      TaskAttemptReport taReport =
          ((GetTaskAttemptReportResponse) invoke("getTaskAttemptReport",
              GetTaskAttemptReportRequest.class, taRequest))
              .getTaskAttemptReport();
      if (taReport.getContainerId() == null
          || taReport.getNodeManagerHost() == null) {
        throw new IOException("Unable to get log information for task: "
            + oldTaskAttemptID);
      }
      return new LogParams(
          taReport.getContainerId().toString(),
          taReport.getContainerId().getApplicationAttemptId()
              .getApplicationId().toString(),
          NodeId.newInstance(taReport.getNodeManagerHost(),
              taReport.getNodeManagerPort()).toString(), report.getUser());
    } else {
      if (report.getAMInfos() == null || report.getAMInfos().size() == 0) {
        throw new IOException("Unable to get log information for job: "
            + oldJobID);
      }
      AMInfo amInfo = report.getAMInfos().get(report.getAMInfos().size() - 1);
      return new LogParams(
          amInfo.getContainerId().toString(),
          amInfo.getAppAttemptId().getApplicationId().toString(),
          NodeId.newInstance(amInfo.getNodeManagerHost(),
              amInfo.getNodeManagerPort()).toString(), report.getUser());
    }
  } else {
    throw new IOException("Cannot get log path for a in-progress job");
  }
}
 
Example 27
Source Project: big-c   Source File: TestClientServiceDelegate.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testReconnectOnAMRestart() throws IOException {
  //test not applicable when AM not reachable
  //as instantiateAMProxy is not called at all
  if(!isAMReachableFromClient) {
    return;
  }

  MRClientProtocol historyServerProxy = mock(MRClientProtocol.class);

  // RM returns AM1 url, null, null and AM2 url on invocations.
  // Nulls simulate the time when AM2 is in the process of restarting.
  ResourceMgrDelegate rmDelegate = mock(ResourceMgrDelegate.class);
  try {
    when(rmDelegate.getApplicationReport(jobId.getAppId())).thenReturn(
        getRunningApplicationReport("am1", 78)).thenReturn(
        getRunningApplicationReport(null, 0)).thenReturn(
        getRunningApplicationReport(null, 0)).thenReturn(
        getRunningApplicationReport("am2", 90));
  } catch (YarnException e) {
    throw new IOException(e);
  }

  GetJobReportResponse jobReportResponse1 = mock(GetJobReportResponse.class);
  when(jobReportResponse1.getJobReport()).thenReturn(
      MRBuilderUtils.newJobReport(jobId, "jobName-firstGen", "user",
          JobState.RUNNING, 0, 0, 0, 0, 0, 0, 0, "anything", null,
          false, ""));

  // First AM returns a report with jobName firstGen and simulates AM shutdown
  // on second invocation.
  MRClientProtocol firstGenAMProxy = mock(MRClientProtocol.class);
  when(firstGenAMProxy.getJobReport(any(GetJobReportRequest.class)))
      .thenReturn(jobReportResponse1).thenThrow(
          new RuntimeException("AM is down!"));

  GetJobReportResponse jobReportResponse2 = mock(GetJobReportResponse.class);
  when(jobReportResponse2.getJobReport()).thenReturn(
      MRBuilderUtils.newJobReport(jobId, "jobName-secondGen", "user",
          JobState.RUNNING, 0, 0, 0, 0, 0, 0, 0, "anything", null,
          false, ""));

  // Second AM generation returns a report with jobName secondGen
  MRClientProtocol secondGenAMProxy = mock(MRClientProtocol.class);
  when(secondGenAMProxy.getJobReport(any(GetJobReportRequest.class)))
      .thenReturn(jobReportResponse2);
  
  ClientServiceDelegate clientServiceDelegate = spy(getClientServiceDelegate(
      historyServerProxy, rmDelegate));
  // First time, connection should be to AM1, then to AM2. Further requests
  // should use the same proxy to AM2 and so instantiateProxy shouldn't be
  // called.
  doReturn(firstGenAMProxy).doReturn(secondGenAMProxy).when(
      clientServiceDelegate).instantiateAMProxy(any(InetSocketAddress.class));

  JobStatus jobStatus = clientServiceDelegate.getJobStatus(oldJobId);
  Assert.assertNotNull(jobStatus);
  Assert.assertEquals("jobName-firstGen", jobStatus.getJobName());

  jobStatus = clientServiceDelegate.getJobStatus(oldJobId);
  Assert.assertNotNull(jobStatus);
  Assert.assertEquals("jobName-secondGen", jobStatus.getJobName());

  jobStatus = clientServiceDelegate.getJobStatus(oldJobId);
  Assert.assertNotNull(jobStatus);
  Assert.assertEquals("jobName-secondGen", jobStatus.getJobName());

  verify(clientServiceDelegate, times(2)).instantiateAMProxy(
      any(InetSocketAddress.class));
}
 
Example 28
Source Project: big-c   Source File: TestRPCFactories.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request)
    throws IOException {
  return null;
}
 
Example 29
Source Project: hadoop   Source File: MRClientProtocol.java    License: Apache License 2.0 votes vote down vote up
public GetJobReportResponse getJobReport(GetJobReportRequest request) throws IOException; 
Example 30
Source Project: big-c   Source File: MRClientProtocol.java    License: Apache License 2.0 votes vote down vote up
public GetJobReportResponse getJobReport(GetJobReportRequest request) throws IOException;