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


Java ApplicationResourceUsageReport.getUsedResources方法代码示例

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


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

示例1: sendEmailOnShutdown

import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入方法依赖的package包/类
private void sendEmailOnShutdown(Optional<ApplicationReport> applicationReport) {
  String subject = String.format("Gobblin Yarn application %s completed", this.applicationName);

  StringBuilder messageBuilder = new StringBuilder("Gobblin Yarn ApplicationReport:");
  if (applicationReport.isPresent()) {
    messageBuilder.append("\n");
    messageBuilder.append("\tApplication ID: ").append(applicationReport.get().getApplicationId()).append("\n");
    messageBuilder.append("\tApplication attempt ID: ")
        .append(applicationReport.get().getCurrentApplicationAttemptId()).append("\n");
    messageBuilder.append("\tFinal application status: ").append(applicationReport.get().getFinalApplicationStatus())
        .append("\n");
    messageBuilder.append("\tStart time: ").append(applicationReport.get().getStartTime()).append("\n");
    messageBuilder.append("\tFinish time: ").append(applicationReport.get().getFinishTime()).append("\n");

    if (!Strings.isNullOrEmpty(applicationReport.get().getDiagnostics())) {
      messageBuilder.append("\tDiagnostics: ").append(applicationReport.get().getDiagnostics()).append("\n");
    }

    ApplicationResourceUsageReport resourceUsageReport = applicationReport.get().getApplicationResourceUsageReport();
    if (resourceUsageReport != null) {
      messageBuilder.append("\tUsed containers: ").append(resourceUsageReport.getNumUsedContainers()).append("\n");
      Resource usedResource = resourceUsageReport.getUsedResources();
      if (usedResource != null) {
        messageBuilder.append("\tUsed memory (MBs): ").append(usedResource.getMemory()).append("\n");
        messageBuilder.append("\tUsed vcores: ").append(usedResource.getVirtualCores()).append("\n");
      }
    }
  } else {
    messageBuilder.append(' ').append("Not available");
  }

  try {
    EmailUtils.sendEmail(ConfigUtils.configToState(this.config), subject, messageBuilder.toString());
  } catch (EmailException ee) {
    LOGGER.error("Failed to send email notification on shutdown", ee);
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:38,代码来源:GobblinYarnAppLauncher.java

示例2: AppInfo

import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入方法依赖的package包/类
public AppInfo(RMApp app, Boolean hasAccess, String schemePrefix) {
  this.schemePrefix = schemePrefix;
  if (app != null) {
    String trackingUrl = app.getTrackingUrl();
    this.state = app.createApplicationState();
    this.trackingUrlIsNotReady = trackingUrl == null || trackingUrl.isEmpty()
        || YarnApplicationState.NEW == this.state
        || YarnApplicationState.NEW_SAVING == this.state
        || YarnApplicationState.SUBMITTED == this.state
        || YarnApplicationState.ACCEPTED == this.state;
    this.trackingUI = this.trackingUrlIsNotReady ? "UNASSIGNED" : (app
        .getFinishTime() == 0 ? "ApplicationMaster" : "History");
    if (!trackingUrlIsNotReady) {
      this.trackingUrl =
          WebAppUtils.getURLWithScheme(schemePrefix,
              trackingUrl);
      this.trackingUrlPretty = this.trackingUrl;
    } else {
      this.trackingUrlPretty = "UNASSIGNED";
    }
    this.applicationId = app.getApplicationId();
    this.applicationType = app.getApplicationType();
    this.appIdNum = String.valueOf(app.getApplicationId().getId());
    this.id = app.getApplicationId().toString();
    this.user = app.getUser().toString();
    this.name = app.getName().toString();
    this.queue = app.getQueue().toString();
    this.progress = app.getProgress() * 100;
    this.diagnostics = app.getDiagnostics().toString();
    if (diagnostics == null || diagnostics.isEmpty()) {
      this.diagnostics = "";
    }
    if (app.getApplicationTags() != null && !app.getApplicationTags().isEmpty()) {
      this.applicationTags = Joiner.on(',').join(app.getApplicationTags());
    }
    this.finalStatus = app.getFinalApplicationStatus();
    this.clusterId = ResourceManager.getClusterTimeStamp();
    if (hasAccess) {
      this.startedTime = app.getStartTime();
      this.finishedTime = app.getFinishTime();
      this.elapsedTime = Times.elapsed(app.getStartTime(),
          app.getFinishTime());

      RMAppAttempt attempt = app.getCurrentAppAttempt();
      if (attempt != null) {
        Container masterContainer = attempt.getMasterContainer();
        if (masterContainer != null) {
          this.amContainerLogsExist = true;
          this.amContainerLogs = WebAppUtils.getRunningLogURL(
              schemePrefix + masterContainer.getNodeHttpAddress(),
              ConverterUtils.toString(masterContainer.getId()),
              app.getUser());
          this.amHostHttpAddress = masterContainer.getNodeHttpAddress();
        }
        
        ApplicationResourceUsageReport resourceReport = attempt
            .getApplicationResourceUsageReport();
        if (resourceReport != null) {
          Resource usedResources = resourceReport.getUsedResources();
          allocatedMB = usedResources.getMemory();
          allocatedVCores = usedResources.getVirtualCores();
          runningContainers = resourceReport.getNumUsedContainers();
        }
      }
    }

    // copy preemption info fields
    RMAppMetrics appMetrics = app.getRMAppMetrics();
    numAMContainerPreempted =
        appMetrics.getNumAMContainersPreempted();
    preemptedResourceMB =
        appMetrics.getResourcePreempted().getMemory();
    numNonAMContainerPreempted =
        appMetrics.getNumNonAMContainersPreempted();
    preemptedResourceVCores =
        appMetrics.getResourcePreempted().getVirtualCores();
    memorySeconds = appMetrics.getMemorySeconds();
    vcoreSeconds = appMetrics.getVcoreSeconds();
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:81,代码来源:AppInfo.java

示例3: AppInfo

import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; //导入方法依赖的package包/类
public AppInfo(RMApp app, Boolean hasAccess, String schemePrefix) {
  this.schemePrefix = schemePrefix;
  if (app != null) {
    String trackingUrl = app.getTrackingUrl();
    this.state = app.createApplicationState();
    this.trackingUrlIsNotReady = trackingUrl == null || trackingUrl.isEmpty()
        || YarnApplicationState.NEW == this.state
        || YarnApplicationState.NEW_SAVING == this.state
        || YarnApplicationState.SUBMITTED == this.state
        || YarnApplicationState.ACCEPTED == this.state;
    this.trackingUI = this.trackingUrlIsNotReady ? "UNASSIGNED" : (app
        .getFinishTime() == 0 ? "ApplicationMaster" : "History");
    if (!trackingUrlIsNotReady) {
      this.trackingUrl =
          WebAppUtils.getURLWithScheme(schemePrefix,
              trackingUrl);
      this.trackingUrlPretty = this.trackingUrl;
    } else {
      this.trackingUrlPretty = "UNASSIGNED";
    }
    this.applicationId = app.getApplicationId();
    this.applicationType = app.getApplicationType();
    this.appIdNum = String.valueOf(app.getApplicationId().getId());
    this.id = app.getApplicationId().toString();
    this.user = app.getUser().toString();
    this.name = app.getName().toString();
    this.queue = app.getQueue().toString();
    this.progress = app.getProgress() * 100;
    this.diagnostics = app.getDiagnostics().toString();
    if (diagnostics == null || diagnostics.isEmpty()) {
      this.diagnostics = "";
    }
    if (app.getApplicationTags() != null && !app.getApplicationTags().isEmpty()) {
      this.applicationTags = Joiner.on(',').join(app.getApplicationTags());
    }
    this.finalStatus = app.getFinalApplicationStatus();
    this.clusterId = ResourceManager.getClusterTimeStamp();
    if (hasAccess) {
      this.startedTime = app.getStartTime();
      this.finishedTime = app.getFinishTime();
      this.elapsedTime = Times.elapsed(app.getStartTime(),
          app.getFinishTime());

      RMAppAttempt attempt = app.getCurrentAppAttempt();
      if (attempt != null) {
        Container masterContainer = attempt.getMasterContainer();
        if (masterContainer != null) {
          this.amContainerLogsExist = true;
          this.amContainerLogs = WebAppUtils.getRunningLogURL(
              schemePrefix + masterContainer.getNodeHttpAddress(),
              ConverterUtils.toString(masterContainer.getId()),
              app.getUser());
          this.amHostHttpAddress = masterContainer.getNodeHttpAddress();
        }
        
        ApplicationResourceUsageReport resourceReport = attempt
            .getApplicationResourceUsageReport();
        if (resourceReport != null) {
          Resource usedResources = resourceReport.getUsedResources();
          allocatedMB = usedResources.getMemory();
          allocatedVCores = usedResources.getVirtualCores();
          runningContainers = resourceReport.getNumUsedContainers();
        }
      }
    }
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:68,代码来源:AppInfo.java


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