Java 类org.apache.hadoop.yarn.api.records.ApplicationAttemptReport 实例源码

项目:hadoop    文件:RMAppAttemptImpl.java   
@Override
public ApplicationAttemptReport createApplicationAttemptReport() {
  this.readLock.lock();
  ApplicationAttemptReport attemptReport = null;
  try {
    // AM container maybe not yet allocated. and also unmangedAM doesn't have
    // am container.
    ContainerId amId =
        masterContainer == null ? null : masterContainer.getId();
    attemptReport = ApplicationAttemptReport.newInstance(this
        .getAppAttemptId(), this.getHost(), this.getRpcPort(), this
        .getTrackingUrl(), this.getOriginalTrackingUrl(), this.getDiagnostics(),
        YarnApplicationAttemptState .valueOf(this.getState().toString()), amId);
  } finally {
    this.readLock.unlock();
  }
  return attemptReport;
}
项目:hadoop    文件:ApplicationHistoryManagerOnTimelineStore.java   
@Override
public Map<ApplicationAttemptId, ApplicationAttemptReport>
    getApplicationAttempts(ApplicationId appId)
        throws YarnException, IOException {
  ApplicationReportExt app = getApplication(
      appId, ApplicationReportField.USER_AND_ACLS);
  checkAccess(app);
  TimelineEntities entities = timelineDataManager.getEntities(
      AppAttemptMetricsConstants.ENTITY_TYPE,
      new NameValuePair(
          AppAttemptMetricsConstants.PARENT_PRIMARY_FILTER, appId
              .toString()), null, null, null, null, null,
      Long.MAX_VALUE, EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  Map<ApplicationAttemptId, ApplicationAttemptReport> appAttempts =
      new LinkedHashMap<ApplicationAttemptId, ApplicationAttemptReport>();
  for (TimelineEntity entity : entities.getEntities()) {
    ApplicationAttemptReport appAttempt =
        convertToApplicationAttemptReport(entity);
    appAttempts.put(appAttempt.getApplicationAttemptId(), appAttempt);
  }
  return appAttempts;
}
项目:hadoop    文件:ApplicationHistoryManagerOnTimelineStore.java   
private ApplicationAttemptReport getApplicationAttempt(
    ApplicationAttemptId appAttemptId, boolean checkACLs)
    throws YarnException, IOException {
  if (checkACLs) {
    ApplicationReportExt app = getApplication(
        appAttemptId.getApplicationId(),
        ApplicationReportField.USER_AND_ACLS);
    checkAccess(app);
  }
  TimelineEntity entity = timelineDataManager.getEntity(
      AppAttemptMetricsConstants.ENTITY_TYPE,
      appAttemptId.toString(), EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  if (entity == null) {
    throw new ApplicationAttemptNotFoundException(
        "The entity for application attempt " + appAttemptId +
        " doesn't exist in the timeline store");
  } else {
    return convertToApplicationAttemptReport(entity);
  }
}
项目:hadoop    文件:TestApplicationHistoryClientService.java   
@Test
public void testApplicationAttempts() throws IOException, YarnException {
  ApplicationId appId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  ApplicationAttemptId appAttemptId1 =
      ApplicationAttemptId.newInstance(appId, 2);
  GetApplicationAttemptsRequest request =
      GetApplicationAttemptsRequest.newInstance(appId);
  GetApplicationAttemptsResponse response =
      clientService.getApplicationAttempts(request);
  List<ApplicationAttemptReport> attemptReports =
      response.getApplicationAttemptList();
  Assert.assertNotNull(attemptReports);
  Assert.assertEquals(appAttemptId, attemptReports.get(0)
    .getApplicationAttemptId());
  Assert.assertEquals(appAttemptId1, attemptReports.get(1)
    .getApplicationAttemptId());
}
项目:hadoop    文件:YarnClientImpl.java   
@Override
public ApplicationAttemptReport getApplicationAttemptReport(
    ApplicationAttemptId appAttemptId) throws YarnException, IOException {
  try {
    GetApplicationAttemptReportRequest request = Records
        .newRecord(GetApplicationAttemptReportRequest.class);
    request.setApplicationAttemptId(appAttemptId);
    GetApplicationAttemptReportResponse response = rmClient
        .getApplicationAttemptReport(request);
    return response.getApplicationAttemptReport();
  } catch (YarnException e) {
    if (!historyServiceEnabled) {
      // Just throw it as usual if historyService is not enabled.
      throw e;
    }
    // Even if history-service is enabled, treat all exceptions still the same
    // except the following
    if (e.getClass() != ApplicationNotFoundException.class) {
      throw e;
    }
    return historyClient.getApplicationAttemptReport(appAttemptId);
  }
}
项目:hadoop    文件:YarnClientImpl.java   
@Override
public List<ApplicationAttemptReport> getApplicationAttempts(
    ApplicationId appId) throws YarnException, IOException {
  try {
    GetApplicationAttemptsRequest request = Records
        .newRecord(GetApplicationAttemptsRequest.class);
    request.setApplicationId(appId);
    GetApplicationAttemptsResponse response = rmClient
        .getApplicationAttempts(request);
    return response.getApplicationAttemptList();
  } catch (YarnException e) {
    if (!historyServiceEnabled) {
      // Just throw it as usual if historyService is not enabled.
      throw e;
    }
    // Even if history-service is enabled, treat all exceptions still the same
    // except the following
    if (e.getClass() != ApplicationNotFoundException.class) {
      throw e;
    }
    return historyClient.getApplicationAttempts(appId);
  }
}
项目:hadoop    文件:ApplicationCLI.java   
/**
 * Lists the application attempts matching the given applicationid
 * 
 * @param applicationId
 * @throws YarnException
 * @throws IOException
 */
private void listApplicationAttempts(String applicationId) throws YarnException,
    IOException {
  PrintWriter writer = new PrintWriter(
      new OutputStreamWriter(sysout, Charset.forName("UTF-8")));

  List<ApplicationAttemptReport> appAttemptsReport = client
      .getApplicationAttempts(ConverterUtils.toApplicationId(applicationId));
  writer.println("Total number of application attempts " + ":"
      + appAttemptsReport.size());
  writer.printf(APPLICATION_ATTEMPTS_PATTERN, "ApplicationAttempt-Id",
      "State", "AM-Container-Id", "Tracking-URL");
  for (ApplicationAttemptReport appAttemptReport : appAttemptsReport) {
    writer.printf(APPLICATION_ATTEMPTS_PATTERN, appAttemptReport
        .getApplicationAttemptId(), appAttemptReport
        .getYarnApplicationAttemptState(), appAttemptReport
        .getAMContainerId().toString(), appAttemptReport.getTrackingUrl());
  }
  writer.flush();
}
项目:hadoop    文件:TestAHSClient.java   
@Test(timeout = 10000)
public void testGetApplicationAttempts() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final AHSClient client = new MockAHSClient();
  client.init(conf);
  client.start();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  List<ApplicationAttemptReport> reports =
      client.getApplicationAttempts(applicationId);
  Assert.assertNotNull(reports);
  Assert.assertEquals(reports.get(0).getApplicationAttemptId(),
    ApplicationAttemptId.newInstance(applicationId, 1));
  Assert.assertEquals(reports.get(1).getApplicationAttemptId(),
    ApplicationAttemptId.newInstance(applicationId, 2));
  client.stop();
}
项目:hadoop    文件:TestAHSClient.java   
@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final AHSClient client = new MockAHSClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports =
      ((MockAHSClient) client).getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(applicationId, 1);
  ApplicationAttemptReport report =
      client.getApplicationAttemptReport(appAttemptId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getApplicationAttemptId().toString(),
    expectedReports.get(0).getCurrentApplicationAttemptId().toString());
  client.stop();
}
项目:hadoop    文件:TestYarnClient.java   
@Test(timeout = 10000)
public void testGetApplicationAttempts() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  List<ApplicationAttemptReport> reports = client
      .getApplicationAttempts(applicationId);
  Assert.assertNotNull(reports);
  Assert.assertEquals(reports.get(0).getApplicationAttemptId(),
      ApplicationAttemptId.newInstance(applicationId, 1));
  Assert.assertEquals(reports.get(1).getApplicationAttemptId(),
      ApplicationAttemptId.newInstance(applicationId, 2));
  client.stop();
}
项目:hadoop    文件:TestYarnClient.java   
@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports = ((MockYarnClient) client)
      .getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      applicationId, 1);
  ApplicationAttemptReport report = client
      .getApplicationAttemptReport(appAttemptId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getApplicationAttemptId().toString(),
      expectedReports.get(0).getCurrentApplicationAttemptId().toString());
  client.stop();
}
项目:big-c    文件:YarnClientImpl.java   
@Override
public List<ApplicationAttemptReport> getApplicationAttempts(
    ApplicationId appId) throws YarnException, IOException {
  try {
    GetApplicationAttemptsRequest request = Records
        .newRecord(GetApplicationAttemptsRequest.class);
    request.setApplicationId(appId);
    GetApplicationAttemptsResponse response = rmClient
        .getApplicationAttempts(request);
    return response.getApplicationAttemptList();
  } catch (YarnException e) {
    if (!historyServiceEnabled) {
      // Just throw it as usual if historyService is not enabled.
      throw e;
    }
    // Even if history-service is enabled, treat all exceptions still the same
    // except the following
    if (e.getClass() != ApplicationNotFoundException.class) {
      throw e;
    }
    return historyClient.getApplicationAttempts(appId);
  }
}
项目:big-c    文件:TestApplicationHistoryClientService.java   
@Test
public void testApplicationAttempts() throws IOException, YarnException {
  ApplicationId appId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  ApplicationAttemptId appAttemptId1 =
      ApplicationAttemptId.newInstance(appId, 2);
  GetApplicationAttemptsRequest request =
      GetApplicationAttemptsRequest.newInstance(appId);
  GetApplicationAttemptsResponse response =
      clientService.getApplicationAttempts(request);
  List<ApplicationAttemptReport> attemptReports =
      response.getApplicationAttemptList();
  Assert.assertNotNull(attemptReports);
  Assert.assertEquals(appAttemptId, attemptReports.get(0)
    .getApplicationAttemptId());
  Assert.assertEquals(appAttemptId1, attemptReports.get(1)
    .getApplicationAttemptId());
}
项目:aliyun-oss-hadoop-fs    文件:RMAppAttemptImpl.java   
@Override
public ApplicationAttemptReport createApplicationAttemptReport() {
  this.readLock.lock();
  ApplicationAttemptReport attemptReport = null;
  try {
    // AM container maybe not yet allocated. and also unmangedAM doesn't have
    // am container.
    ContainerId amId =
        masterContainer == null ? null : masterContainer.getId();
    attemptReport = ApplicationAttemptReport.newInstance(this
        .getAppAttemptId(), this.getHost(), this.getRpcPort(), this
        .getTrackingUrl(), this.getOriginalTrackingUrl(), this.getDiagnostics(),
            YarnApplicationAttemptState.valueOf(this.getState().toString()),
            amId, this.startTime, this.finishTime);
  } finally {
    this.readLock.unlock();
  }
  return attemptReport;
}
项目:aliyun-oss-hadoop-fs    文件:ApplicationHistoryManagerOnTimelineStore.java   
@Override
public Map<ApplicationAttemptId, ApplicationAttemptReport>
    getApplicationAttempts(ApplicationId appId)
        throws YarnException, IOException {
  ApplicationReportExt app = getApplication(
      appId, ApplicationReportField.USER_AND_ACLS);
  checkAccess(app);
  TimelineEntities entities = timelineDataManager.getEntities(
      AppAttemptMetricsConstants.ENTITY_TYPE,
      new NameValuePair(
          AppAttemptMetricsConstants.PARENT_PRIMARY_FILTER, appId
              .toString()), null, null, null, null, null,
      Long.MAX_VALUE, EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  Map<ApplicationAttemptId, ApplicationAttemptReport> appAttempts =
      new LinkedHashMap<ApplicationAttemptId, ApplicationAttemptReport>();
  for (TimelineEntity entity : entities.getEntities()) {
    ApplicationAttemptReport appAttempt =
        convertToApplicationAttemptReport(entity);
    appAttempts.put(appAttempt.getApplicationAttemptId(), appAttempt);
  }
  return appAttempts;
}
项目:aliyun-oss-hadoop-fs    文件:ApplicationHistoryManagerOnTimelineStore.java   
private ApplicationAttemptReport getApplicationAttempt(
    ApplicationAttemptId appAttemptId, boolean checkACLs)
    throws YarnException, IOException {
  if (checkACLs) {
    ApplicationReportExt app = getApplication(
        appAttemptId.getApplicationId(),
        ApplicationReportField.USER_AND_ACLS);
    checkAccess(app);
  }
  TimelineEntity entity = timelineDataManager.getEntity(
      AppAttemptMetricsConstants.ENTITY_TYPE,
      appAttemptId.toString(), EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  if (entity == null) {
    throw new ApplicationAttemptNotFoundException(
        "The entity for application attempt " + appAttemptId +
        " doesn't exist in the timeline store");
  } else {
    return convertToApplicationAttemptReport(entity);
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestApplicationHistoryClientService.java   
@Test
public void testApplicationAttempts() throws IOException, YarnException {
  ApplicationId appId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  ApplicationAttemptId appAttemptId1 =
      ApplicationAttemptId.newInstance(appId, 2);
  GetApplicationAttemptsRequest request =
      GetApplicationAttemptsRequest.newInstance(appId);
  GetApplicationAttemptsResponse response =
      clientService.getApplicationAttempts(request);
  List<ApplicationAttemptReport> attemptReports =
      response.getApplicationAttemptList();
  Assert.assertNotNull(attemptReports);
  Assert.assertEquals(appAttemptId, attemptReports.get(0)
    .getApplicationAttemptId());
  Assert.assertEquals(appAttemptId1, attemptReports.get(1)
    .getApplicationAttemptId());
}
项目:aliyun-oss-hadoop-fs    文件:YarnClientImpl.java   
@Override
public List<ApplicationAttemptReport> getApplicationAttempts(
    ApplicationId appId) throws YarnException, IOException {
  try {
    GetApplicationAttemptsRequest request = Records
        .newRecord(GetApplicationAttemptsRequest.class);
    request.setApplicationId(appId);
    GetApplicationAttemptsResponse response = rmClient
        .getApplicationAttempts(request);
    return response.getApplicationAttemptList();
  } catch (YarnException e) {
    if (!historyServiceEnabled) {
      // Just throw it as usual if historyService is not enabled.
      throw e;
    }
    // Even if history-service is enabled, treat all exceptions still the same
    // except the following
    if (e.getClass() != ApplicationNotFoundException.class) {
      throw e;
    }
    return historyClient.getApplicationAttempts(appId);
  }
}
项目:aliyun-oss-hadoop-fs    文件:ApplicationCLI.java   
/**
 * Lists the application attempts matching the given applicationid
 * 
 * @param applicationId
 * @throws YarnException
 * @throws IOException
 */
private void listApplicationAttempts(String applicationId) throws YarnException,
    IOException {
  PrintWriter writer = new PrintWriter(
      new OutputStreamWriter(sysout, Charset.forName("UTF-8")));

  List<ApplicationAttemptReport> appAttemptsReport = client
      .getApplicationAttempts(ConverterUtils.toApplicationId(applicationId));
  writer.println("Total number of application attempts " + ":"
      + appAttemptsReport.size());
  writer.printf(APPLICATION_ATTEMPTS_PATTERN, "ApplicationAttempt-Id",
      "State", "AM-Container-Id", "Tracking-URL");
  for (ApplicationAttemptReport appAttemptReport : appAttemptsReport) {
    writer.printf(APPLICATION_ATTEMPTS_PATTERN, appAttemptReport
        .getApplicationAttemptId(), appAttemptReport
        .getYarnApplicationAttemptState(), appAttemptReport
        .getAMContainerId() == null ? "N/A" : appAttemptReport
        .getAMContainerId().toString(), appAttemptReport.getTrackingUrl());
  }
  writer.flush();
}
项目:big-c    文件:TestAHSClient.java   
@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final AHSClient client = new MockAHSClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports =
      ((MockAHSClient) client).getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(applicationId, 1);
  ApplicationAttemptReport report =
      client.getApplicationAttemptReport(appAttemptId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getApplicationAttemptId().toString(),
    expectedReports.get(0).getCurrentApplicationAttemptId().toString());
  client.stop();
}
项目:aliyun-oss-hadoop-fs    文件:TestAHSClient.java   
@Test(timeout = 10000)
public void testGetApplicationAttempts() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final AHSClient client = new MockAHSClient();
  client.init(conf);
  client.start();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  List<ApplicationAttemptReport> reports =
      client.getApplicationAttempts(applicationId);
  Assert.assertNotNull(reports);
  Assert.assertEquals(reports.get(0).getApplicationAttemptId(),
    ApplicationAttemptId.newInstance(applicationId, 1));
  Assert.assertEquals(reports.get(1).getApplicationAttemptId(),
    ApplicationAttemptId.newInstance(applicationId, 2));
  client.stop();
}
项目:aliyun-oss-hadoop-fs    文件:TestAHSClient.java   
@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final AHSClient client = new MockAHSClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports =
      ((MockAHSClient) client).getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(applicationId, 1);
  ApplicationAttemptReport report =
      client.getApplicationAttemptReport(appAttemptId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getApplicationAttemptId().toString(),
    expectedReports.get(0).getCurrentApplicationAttemptId().toString());
  client.stop();
}
项目:aliyun-oss-hadoop-fs    文件:TestYarnClient.java   
@Test(timeout = 10000)
public void testGetApplicationAttempts() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  List<ApplicationAttemptReport> reports = client
      .getApplicationAttempts(applicationId);
  Assert.assertNotNull(reports);
  Assert.assertEquals(reports.get(0).getApplicationAttemptId(),
      ApplicationAttemptId.newInstance(applicationId, 1));
  Assert.assertEquals(reports.get(1).getApplicationAttemptId(),
      ApplicationAttemptId.newInstance(applicationId, 2));
  client.stop();
}
项目:aliyun-oss-hadoop-fs    文件:TestYarnClient.java   
@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports = ((MockYarnClient) client)
      .getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      applicationId, 1);
  ApplicationAttemptReport report = client
      .getApplicationAttemptReport(appAttemptId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getApplicationAttemptId().toString(),
      expectedReports.get(0).getCurrentApplicationAttemptId().toString());
  client.stop();
}
项目:big-c    文件:ApplicationCLI.java   
/**
 * Lists the application attempts matching the given applicationid
 * 
 * @param applicationId
 * @throws YarnException
 * @throws IOException
 */
private void listApplicationAttempts(String applicationId) throws YarnException,
    IOException {
  PrintWriter writer = new PrintWriter(
      new OutputStreamWriter(sysout, Charset.forName("UTF-8")));

  List<ApplicationAttemptReport> appAttemptsReport = client
      .getApplicationAttempts(ConverterUtils.toApplicationId(applicationId));
  writer.println("Total number of application attempts " + ":"
      + appAttemptsReport.size());
  writer.printf(APPLICATION_ATTEMPTS_PATTERN, "ApplicationAttempt-Id",
      "State", "AM-Container-Id", "Tracking-URL");
  for (ApplicationAttemptReport appAttemptReport : appAttemptsReport) {
    writer.printf(APPLICATION_ATTEMPTS_PATTERN, appAttemptReport
        .getApplicationAttemptId(), appAttemptReport
        .getYarnApplicationAttemptState(), appAttemptReport
        .getAMContainerId().toString(), appAttemptReport.getTrackingUrl());
  }
  writer.flush();
}
项目:aliyun-oss-hadoop-fs    文件:TestYarnCLI.java   
@Test
public void testAppAttemptReportWhileContainerIsNotAssigned()
    throws Exception {
  ApplicationCLI cli = createAndGetAppCLI();
  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId attemptId =
      ApplicationAttemptId.newInstance(applicationId, 1);
  ApplicationAttemptReport attemptReport =
      ApplicationAttemptReport.newInstance(attemptId, "host", 124, "url",
          "oUrl", "diagnostics", YarnApplicationAttemptState.SCHEDULED, null,
          1000l, 2000l);
  when(client.getApplicationAttemptReport(any(ApplicationAttemptId.class)))
      .thenReturn(attemptReport);
  int result =
      cli.run(new String[] { "applicationattempt", "-status",
          attemptId.toString() });
  assertEquals(0, result);
  result =
      cli.run(new String[] { "applicationattempt", "-list",
          applicationId.toString() });
  assertEquals(0, result);
}
项目:big-c    文件:TestYarnClient.java   
@Test(timeout = 10000)
public void testGetApplicationAttempts() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  List<ApplicationAttemptReport> reports = client
      .getApplicationAttempts(applicationId);
  Assert.assertNotNull(reports);
  Assert.assertEquals(reports.get(0).getApplicationAttemptId(),
      ApplicationAttemptId.newInstance(applicationId, 1));
  Assert.assertEquals(reports.get(1).getApplicationAttemptId(),
      ApplicationAttemptId.newInstance(applicationId, 2));
  client.stop();
}
项目:big-c    文件:TestYarnClient.java   
@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports = ((MockYarnClient) client)
      .getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      applicationId, 1);
  ApplicationAttemptReport report = client
      .getApplicationAttemptReport(appAttemptId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getApplicationAttemptId().toString(),
      expectedReports.get(0).getCurrentApplicationAttemptId().toString());
  client.stop();
}
项目:big-c    文件:RMAppAttemptImpl.java   
@Override
public ApplicationAttemptReport createApplicationAttemptReport() {
  this.readLock.lock();
  ApplicationAttemptReport attemptReport = null;
  try {
    // AM container maybe not yet allocated. and also unmangedAM doesn't have
    // am container.
    ContainerId amId =
        masterContainer == null ? null : masterContainer.getId();
    attemptReport = ApplicationAttemptReport.newInstance(this
        .getAppAttemptId(), this.getHost(), this.getRpcPort(), this
        .getTrackingUrl(), this.getOriginalTrackingUrl(), this.getDiagnostics(),
        YarnApplicationAttemptState .valueOf(this.getState().toString()), amId);
  } finally {
    this.readLock.unlock();
  }
  return attemptReport;
}
项目:big-c    文件:ApplicationHistoryManagerOnTimelineStore.java   
@Override
public Map<ApplicationAttemptId, ApplicationAttemptReport>
    getApplicationAttempts(ApplicationId appId)
        throws YarnException, IOException {
  ApplicationReportExt app = getApplication(
      appId, ApplicationReportField.USER_AND_ACLS);
  checkAccess(app);
  TimelineEntities entities = timelineDataManager.getEntities(
      AppAttemptMetricsConstants.ENTITY_TYPE,
      new NameValuePair(
          AppAttemptMetricsConstants.PARENT_PRIMARY_FILTER, appId
              .toString()), null, null, null, null, null,
      Long.MAX_VALUE, EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  Map<ApplicationAttemptId, ApplicationAttemptReport> appAttempts =
      new LinkedHashMap<ApplicationAttemptId, ApplicationAttemptReport>();
  for (TimelineEntity entity : entities.getEntities()) {
    ApplicationAttemptReport appAttempt =
        convertToApplicationAttemptReport(entity);
    appAttempts.put(appAttempt.getApplicationAttemptId(), appAttempt);
  }
  return appAttempts;
}
项目:big-c    文件:ApplicationHistoryManagerOnTimelineStore.java   
private ApplicationAttemptReport getApplicationAttempt(
    ApplicationAttemptId appAttemptId, boolean checkACLs)
    throws YarnException, IOException {
  if (checkACLs) {
    ApplicationReportExt app = getApplication(
        appAttemptId.getApplicationId(),
        ApplicationReportField.USER_AND_ACLS);
    checkAccess(app);
  }
  TimelineEntity entity = timelineDataManager.getEntity(
      AppAttemptMetricsConstants.ENTITY_TYPE,
      appAttemptId.toString(), EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  if (entity == null) {
    throw new ApplicationAttemptNotFoundException(
        "The entity for application attempt " + appAttemptId +
        " doesn't exist in the timeline store");
  } else {
    return convertToApplicationAttemptReport(entity);
  }
}
项目:hadoop    文件:GetApplicationAttemptsResponsePBImpl.java   
@Override
public void setApplicationAttemptList(
    List<ApplicationAttemptReport> applicationAttempts) {
  maybeInitBuilder();
  if (applicationAttempts == null) {
    builder.clearApplicationAttempts();
  }
  this.applicationAttemptList = applicationAttempts;
}
项目:hadoop    文件:GetApplicationAttemptsResponsePBImpl.java   
private void initLocalApplicationAttemptsList() {
  if (this.applicationAttemptList != null) {
    return;
  }
  GetApplicationAttemptsResponseProtoOrBuilder p = viaProto ? proto : builder;
  List<ApplicationAttemptReportProto> list = p.getApplicationAttemptsList();
  applicationAttemptList = new ArrayList<ApplicationAttemptReport>();

  for (ApplicationAttemptReportProto a : list) {
    applicationAttemptList.add(convertFromProtoFormat(a));
  }
}
项目:hadoop    文件:GetApplicationAttemptsResponsePBImpl.java   
private void addLocalApplicationAttemptsToProto() {
  maybeInitBuilder();
  builder.clearApplicationAttempts();
  if (applicationAttemptList == null) {
    return;
  }
  Iterable<ApplicationAttemptReportProto> iterable =
      new Iterable<ApplicationAttemptReportProto>() {
        @Override
        public Iterator<ApplicationAttemptReportProto> iterator() {
          return new Iterator<ApplicationAttemptReportProto>() {

            Iterator<ApplicationAttemptReport> iter = applicationAttemptList
              .iterator();

            @Override
            public boolean hasNext() {
              return iter.hasNext();
            }

            @Override
            public ApplicationAttemptReportProto next() {
              return convertToProtoFormat(iter.next());
            }

            @Override
            public void remove() {
              throw new UnsupportedOperationException();

            }
          };

        }
      };
  builder.addAllApplicationAttempts(iterable);
}
项目:hadoop    文件:GetApplicationAttemptReportResponsePBImpl.java   
@Override
public ApplicationAttemptReport getApplicationAttemptReport() {
  if (this.applicationAttemptReport != null) {
    return this.applicationAttemptReport;
  }
  GetApplicationAttemptReportResponseProtoOrBuilder p =
      viaProto ? proto : builder;
  if (!p.hasApplicationAttemptReport()) {
    return null;
  }
  this.applicationAttemptReport =
      convertFromProtoFormat(p.getApplicationAttemptReport());
  return this.applicationAttemptReport;
}
项目:hadoop    文件:GetApplicationAttemptReportResponsePBImpl.java   
@Override
public void setApplicationAttemptReport(
    ApplicationAttemptReport ApplicationAttemptReport) {
  maybeInitBuilder();
  if (ApplicationAttemptReport == null) {
    builder.clearApplicationAttemptReport();
  }
  this.applicationAttemptReport = ApplicationAttemptReport;
}
项目:hadoop    文件:AppAttemptInfo.java   
public AppAttemptInfo(ApplicationAttemptReport appAttempt) {
  appAttemptId = appAttempt.getApplicationAttemptId().toString();
  host = appAttempt.getHost();
  rpcPort = appAttempt.getRpcPort();
  trackingUrl = appAttempt.getTrackingUrl();
  originalTrackingUrl = appAttempt.getOriginalTrackingUrl();
  diagnosticsInfo = appAttempt.getDiagnostics();
  appAttemptState = appAttempt.getYarnApplicationAttemptState();
  if (appAttempt.getAMContainerId() != null) {
    amContainerId = appAttempt.getAMContainerId().toString();
  }
}
项目:hadoop    文件:ClientRMService.java   
@Override
public GetApplicationAttemptsResponse getApplicationAttempts(
    GetApplicationAttemptsRequest request) throws YarnException, IOException {
  ApplicationId appId = request.getApplicationId();
  UserGroupInformation callerUGI;
  try {
    callerUGI = UserGroupInformation.getCurrentUser();
  } catch (IOException ie) {
    LOG.info("Error getting UGI ", ie);
    throw RPCUtil.getRemoteException(ie);
  }
  RMApp application = this.rmContext.getRMApps().get(appId);
  if (application == null) {
    // If the RM doesn't have the application, throw
    // ApplicationNotFoundException and let client to handle.
    throw new ApplicationNotFoundException("Application with id '" + appId
        + "' doesn't exist in RM.");
  }
  boolean allowAccess = checkAccess(callerUGI, application.getUser(),
      ApplicationAccessType.VIEW_APP, application);
  GetApplicationAttemptsResponse response = null;
  if (allowAccess) {
    Map<ApplicationAttemptId, RMAppAttempt> attempts = application
        .getAppAttempts();
    List<ApplicationAttemptReport> listAttempts = 
      new ArrayList<ApplicationAttemptReport>();
    Iterator<Map.Entry<ApplicationAttemptId, RMAppAttempt>> iter = attempts
        .entrySet().iterator();
    while (iter.hasNext()) {
      listAttempts.add(iter.next().getValue()
          .createApplicationAttemptReport());
    }
    response = GetApplicationAttemptsResponse.newInstance(listAttempts);
  } else {
    throw new YarnException("User " + callerUGI.getShortUserName()
        + " does not have privilage to see this aplication " + appId);
  }
  return response;
}
项目:hadoop    文件:ApplicationHistoryManagerImpl.java   
private ApplicationAttemptReport convertToApplicationAttemptReport(
    ApplicationAttemptHistoryData appAttemptHistory) {
  return ApplicationAttemptReport.newInstance(
    appAttemptHistory.getApplicationAttemptId(), appAttemptHistory.getHost(),
    appAttemptHistory.getRPCPort(), appAttemptHistory.getTrackingURL(), null,
    appAttemptHistory.getDiagnosticsInfo(),
    appAttemptHistory.getYarnApplicationAttemptState(),
    appAttemptHistory.getMasterContainerId());
}
项目:hadoop    文件:ApplicationHistoryManagerImpl.java   
@Override
public Map<ApplicationAttemptId, ApplicationAttemptReport>
    getApplicationAttempts(ApplicationId appId) throws IOException {
  Map<ApplicationAttemptId, ApplicationAttemptHistoryData> histData =
      historyStore.getApplicationAttempts(appId);
  HashMap<ApplicationAttemptId, ApplicationAttemptReport> applicationAttemptsReport =
      new HashMap<ApplicationAttemptId, ApplicationAttemptReport>();
  for (Entry<ApplicationAttemptId, ApplicationAttemptHistoryData> entry : histData
    .entrySet()) {
    applicationAttemptsReport.put(entry.getKey(),
      convertToApplicationAttemptReport(entry.getValue()));
  }
  return applicationAttemptsReport;
}