当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationReport.getApplicationResourceUsageReport方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.api.records.ApplicationReport.getApplicationResourceUsageReport方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationReport.getApplicationResourceUsageReport方法的具体用法?Java ApplicationReport.getApplicationResourceUsageReport怎么用?Java ApplicationReport.getApplicationResourceUsageReport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.api.records.ApplicationReport的用法示例。


在下文中一共展示了ApplicationReport.getApplicationResourceUsageReport方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractInstanceInfo

import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
static InstanceInfo extractInstanceInfo(String clusterName, ApplicationReport report) {
  InstanceMetadata md = getMetadata(report.getApplicationTags());
  if (md == null) {
    return null;
  }

  ApplicationResourceUsageReport usage = report.getApplicationResourceUsageReport();
  InstanceStatus stat = new InstanceStatus()
      .allocatedVCores((long) usage.getUsedResources().getVirtualCores())
      .allocatedMB((long) usage.getUsedResources().getMemory())
      .clusterId(clusterName)
      .applicationId(report.getApplicationId().toString())
      .startedTime(report.getStartTime())
      .runningContainers((long) usage.getNumUsedContainers())
      .trackingUrl(report.getTrackingUrl())
      .state(InstanceStatus.StateEnum.fromValue(report.getYarnApplicationState().toString()));
  return new InstanceInfo(clusterName, report.getApplicationId(), md, stat);
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:19,代码来源:Utils.java

示例2: verifyEnemyAppReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
private void verifyEnemyAppReport(ApplicationReport appReport) {
  Assert.assertEquals("Enemy should not see app host!",
      UNAVAILABLE, appReport.getHost());
  Assert.assertEquals("Enemy should not see app rpc port!",
      -1, appReport.getRpcPort());
  Assert.assertEquals("Enemy should not see app client token!",
      null, appReport.getClientToAMToken());
  Assert.assertEquals("Enemy should not see app diagnostics!",
      UNAVAILABLE, appReport.getDiagnostics());
  Assert.assertEquals("Enemy should not see app tracking url!",
      UNAVAILABLE, appReport.getTrackingUrl());
  Assert.assertEquals("Enemy should not see app original tracking url!",
      UNAVAILABLE, appReport.getOriginalTrackingUrl());
  ApplicationResourceUsageReport usageReport =
      appReport.getApplicationResourceUsageReport();
  Assert.assertEquals("Enemy should not see app used containers",
      -1, usageReport.getNumUsedContainers());
  Assert.assertEquals("Enemy should not see app reserved containers",
      -1, usageReport.getNumReservedContainers());
  Assert.assertEquals("Enemy should not see app used resources",
      -1, usageReport.getUsedResources().getMemory());
  Assert.assertEquals("Enemy should not see app reserved resources",
      -1, usageReport.getReservedResources().getMemory());
  Assert.assertEquals("Enemy should not see app needed resources",
      -1, usageReport.getNeededResources().getMemory());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestApplicationACLs.java

示例3: testGetApplicationReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
@Test
public void testGetApplicationReport() throws Exception {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);

  ApplicationId appId1 = getApplicationId(1);

  ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
  when(
      mockAclsManager.checkAccess(UserGroupInformation.getCurrentUser(),
          ApplicationAccessType.VIEW_APP, null, appId1)).thenReturn(true);

  ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler,
      null, mockAclsManager, null, null);
  try {
    RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
    GetApplicationReportRequest request = recordFactory
        .newRecordInstance(GetApplicationReportRequest.class);
    request.setApplicationId(appId1);
    GetApplicationReportResponse response = 
        rmService.getApplicationReport(request);
    ApplicationReport report = response.getApplicationReport();
    ApplicationResourceUsageReport usageReport = 
        report.getApplicationResourceUsageReport();
    Assert.assertEquals(10, usageReport.getMemorySeconds());
    Assert.assertEquals(3, usageReport.getVcoreSeconds());
    Assert.assertEquals(3, usageReport.getGcoreSeconds());
  } finally {
    rmService.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:TestClientRMService.java

示例4: fromYarn

import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
public static JobStatus fromYarn(ApplicationReport application,
    String jobFile) {
  String trackingUrl = application.getTrackingUrl();
  trackingUrl = trackingUrl == null ? "" : trackingUrl;
  JobStatus jobStatus =
    new JobStatus(
        TypeConverter.fromYarn(application.getApplicationId()),
        0.0f, 0.0f, 0.0f, 0.0f,
        TypeConverter.fromYarn(application.getYarnApplicationState(), application.getFinalApplicationStatus()),
        org.apache.hadoop.mapreduce.JobPriority.NORMAL,
        application.getUser(), application.getName(),
        application.getQueue(), jobFile, trackingUrl, false
    );
  jobStatus.setSchedulingInfo(trackingUrl); // Set AM tracking url
  jobStatus.setStartTime(application.getStartTime());
  jobStatus.setFinishTime(application.getFinishTime());
  jobStatus.setFailureInfo(application.getDiagnostics());
  ApplicationResourceUsageReport resourceUsageReport =
      application.getApplicationResourceUsageReport();
  if (resourceUsageReport != null) {
    jobStatus.setNeededMem(
        resourceUsageReport.getNeededResources().getMemory());
    jobStatus.setNumReservedSlots(
        resourceUsageReport.getNumReservedContainers());
    jobStatus.setNumUsedSlots(resourceUsageReport.getNumUsedContainers());
    jobStatus.setReservedMem(
        resourceUsageReport.getReservedResources().getMemory());
    jobStatus.setUsedMem(resourceUsageReport.getUsedResources().getMemory());
  }
  return jobStatus;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:TypeConverter.java

示例5: testGetApplicationReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
@Test
public void testGetApplicationReport() throws Exception {
  for (int i = 1; i <= 2; ++i) {
    final ApplicationId appId = ApplicationId.newInstance(0, i);
    ApplicationReport app;
    if (callerUGI == null) {
      app = historyManager.getApplication(appId);
    } else {
      app =
          callerUGI.doAs(new PrivilegedExceptionAction<ApplicationReport> () {
        @Override
        public ApplicationReport run() throws Exception {
          return historyManager.getApplication(appId);
        }
      });
    }
    Assert.assertNotNull(app);
    Assert.assertEquals(appId, app.getApplicationId());
    Assert.assertEquals("test app", app.getName());
    Assert.assertEquals("test app type", app.getApplicationType());
    Assert.assertEquals("user1", app.getUser());
    Assert.assertEquals("test queue", app.getQueue());
    Assert.assertEquals(Integer.MAX_VALUE + 2L, app.getStartTime());
    Assert.assertEquals(Integer.MAX_VALUE + 3L, app.getFinishTime());
    Assert.assertTrue(Math.abs(app.getProgress() - 1.0F) < 0.0001);
    // App 2 doesn't have the ACLs, such that the default ACLs " " will be used.
    // Nobody except admin and owner has access to the details of the app.
    if ((i ==  1 && callerUGI != null &&
        callerUGI.getShortUserName().equals("user3")) ||
        (i ==  2 && callerUGI != null &&
        (callerUGI.getShortUserName().equals("user2") ||
            callerUGI.getShortUserName().equals("user3")))) {
      Assert.assertEquals(ApplicationAttemptId.newInstance(appId, -1),
          app.getCurrentApplicationAttemptId());
      Assert.assertEquals(ApplicationHistoryManagerOnTimelineStore.UNAVAILABLE,
          app.getHost());
      Assert.assertEquals(-1, app.getRpcPort());
      Assert.assertEquals(ApplicationHistoryManagerOnTimelineStore.UNAVAILABLE,
          app.getTrackingUrl());
      Assert.assertEquals(ApplicationHistoryManagerOnTimelineStore.UNAVAILABLE,
          app.getOriginalTrackingUrl());
      Assert.assertEquals("", app.getDiagnostics());
    } else {
      Assert.assertEquals(ApplicationAttemptId.newInstance(appId, 1),
          app.getCurrentApplicationAttemptId());
      Assert.assertEquals("test host", app.getHost());
      Assert.assertEquals(100, app.getRpcPort());
      Assert.assertEquals("test tracking url", app.getTrackingUrl());
      Assert.assertEquals("test original tracking url",
          app.getOriginalTrackingUrl());
      Assert.assertEquals("test diagnostics info", app.getDiagnostics());
    }
    ApplicationResourceUsageReport applicationResourceUsageReport =
        app.getApplicationResourceUsageReport();
    Assert.assertEquals(123,
        applicationResourceUsageReport.getMemorySeconds());
    Assert
        .assertEquals(345, applicationResourceUsageReport.getVcoreSeconds());
    Assert
        .assertEquals(345, applicationResourceUsageReport.getGcoreSeconds());
    Assert.assertEquals(FinalApplicationStatus.UNDEFINED,
        app.getFinalApplicationStatus());
    Assert.assertEquals(YarnApplicationState.FINISHED,
        app.getYarnApplicationState());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:67,代码来源:TestApplicationHistoryManagerOnTimelineStore.java

示例6: printApplicationReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
/**
 * Prints the application report for an application id.
 * 
 * @param applicationId
 * @return exitCode
 * @throws YarnException
 */
private int printApplicationReport(String applicationId)
    throws YarnException, IOException {
  ApplicationReport appReport = null;
  try {
    appReport = client.getApplicationReport(ConverterUtils
        .toApplicationId(applicationId));
  } catch (ApplicationNotFoundException e) {
    sysout.println("Application with id '" + applicationId
        + "' doesn't exist in RM or Timeline Server.");
    return -1;
  }
  // Use PrintWriter.println, which uses correct platform line ending.
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  PrintWriter appReportStr = new PrintWriter(
      new OutputStreamWriter(baos, Charset.forName("UTF-8")));
  if (appReport != null) {
    appReportStr.println("Application Report : ");
    appReportStr.print("\tApplication-Id : ");
    appReportStr.println(appReport.getApplicationId());
    appReportStr.print("\tApplication-Name : ");
    appReportStr.println(appReport.getName());
    appReportStr.print("\tApplication-Type : ");
    appReportStr.println(appReport.getApplicationType());
    appReportStr.print("\tUser : ");
    appReportStr.println(appReport.getUser());
    appReportStr.print("\tQueue : ");
    appReportStr.println(appReport.getQueue());
    appReportStr.print("\tStart-Time : ");
    appReportStr.println(appReport.getStartTime());
    appReportStr.print("\tFinish-Time : ");
    appReportStr.println(appReport.getFinishTime());
    appReportStr.print("\tProgress : ");
    DecimalFormat formatter = new DecimalFormat("###.##%");
    String progress = formatter.format(appReport.getProgress());
    appReportStr.println(progress);
    appReportStr.print("\tState : ");
    appReportStr.println(appReport.getYarnApplicationState());
    appReportStr.print("\tFinal-State : ");
    appReportStr.println(appReport.getFinalApplicationStatus());
    appReportStr.print("\tTracking-URL : ");
    appReportStr.println(appReport.getOriginalTrackingUrl());
    appReportStr.print("\tRPC Port : ");
    appReportStr.println(appReport.getRpcPort());
    appReportStr.print("\tAM Host : ");
    appReportStr.println(appReport.getHost());
    appReportStr.print("\tAggregate Resource Allocation : ");

    ApplicationResourceUsageReport usageReport =
        appReport.getApplicationResourceUsageReport();
    if (usageReport != null) {
      //completed app report in the timeline server doesn't have usage report
      appReportStr.print(usageReport.getMemorySeconds() + " MB-seconds, ");
      appReportStr.println(usageReport.getVcoreSeconds() + " vcore-seconds");
      appReportStr.println(usageReport.getGcoreSeconds() + " gcore-seconds");
    } else {
      appReportStr.println("N/A");
    }
    appReportStr.print("\tDiagnostics : ");
    appReportStr.print(appReport.getDiagnostics());
  } else {
    appReportStr.print("Application with id '" + applicationId
        + "' doesn't exist in RM.");
    appReportStr.close();
    sysout.println(baos.toString("UTF-8"));
    return -1;
  }
  appReportStr.close();
  sysout.println(baos.toString("UTF-8"));
  return 0;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:78,代码来源:ApplicationCLI.java


注:本文中的org.apache.hadoop.yarn.api.records.ApplicationReport.getApplicationResourceUsageReport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。