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


Java TaskAttempt.getProgress方法代码示例

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


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

示例1: getProgress

import org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt; //导入方法依赖的package包/类
@Override
public float getProgress() {
  readLock.lock();
  try {
    TaskAttempt bestAttempt = selectBestAttempt();
    if (bestAttempt == null) {
      return 0f;
    }
    return bestAttempt.getProgress();
  } finally {
    readLock.unlock();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TaskImpl.java

示例2: selectBestAttempt

import org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt; //导入方法依赖的package包/类
private TaskAttempt selectBestAttempt() {
  if (successfulAttempt != null) {
    return attempts.get(successfulAttempt);
  }

  float progress = 0f;
  TaskAttempt result = null;
  for (TaskAttempt at : attempts.values()) {
    switch (at.getState()) {
    
    // ignore all failed task attempts
    case FAILED: 
    case KILLED:
      continue;      
    }      
    if (result == null) {
      result = at; //The first time around
    }
    // calculate the best progress
    float attemptProgress = at.getProgress();
    if (attemptProgress > progress) {
      result = at;
      progress = attemptProgress;
    }
  }
  return result;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TaskImpl.java

示例3: getState

import org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt; //导入方法依赖的package包/类
@Override
public TaskAttemptState getState() {
  if (overridingState != null) {
    return overridingState;
  }
  TaskAttemptState result
      = getProgress() < 1.0F ? TaskAttemptState.RUNNING : TaskAttemptState.SUCCEEDED;

  if (result == TaskAttemptState.SUCCEEDED) {
    overridingState = TaskAttemptState.SUCCEEDED;

    System.out.println("MyTaskAttemptImpl.getState() -- attempt " + myAttemptID + " finished.");

    slotsInUse.addAndGet(- taskTypeSlots(myAttemptID.getTaskId().getTaskType()));

    (myAttemptID.getTaskId().getTaskType() == TaskType.MAP
        ? completedMaps : completedReduces).getAndIncrement();

    // check for a spectacularly successful speculation
    TaskId taskID = myAttemptID.getTaskId();

    Task task = myJob.getTask(taskID);

    for (TaskAttempt otherAttempt : task.getAttempts().values()) {
      if (otherAttempt != this
          && otherAttempt.getState() == TaskAttemptState.RUNNING) {
        // we had two instances running.  Try to determine how much
        //  we might have saved by speculation
        if (getID().getId() > otherAttempt.getID().getId()) {
          // the speculation won
          successfulSpeculations.getAndIncrement();
          float hisProgress = otherAttempt.getProgress();
          long hisStartTime = ((MyTaskAttemptImpl)otherAttempt).startMockTime;
          System.out.println("TLTRE:A speculation finished at time "
              + clock.getTime()
              + ".  The stalled attempt is at " + (hisProgress * 100.0)
              + "% progress, and it started at "
              + hisStartTime + ", which is "
              + (clock.getTime() - hisStartTime) + " ago.");
          long originalTaskEndEstimate
              = (hisStartTime
                  + estimator.estimatedRuntime(otherAttempt.getID()));
          System.out.println(
              "TLTRE: We would have expected the original attempt to take "
              + estimator.estimatedRuntime(otherAttempt.getID())
              + ", finishing at " + originalTaskEndEstimate);
          long estimatedSavings = originalTaskEndEstimate - clock.getTime();
          taskTimeSavedBySpeculation.addAndGet(estimatedSavings);
          System.out.println("TLTRE: The task is " + task.getID());
          slotsInUse.addAndGet(- taskTypeSlots(myAttemptID.getTaskId().getTaskType()));
          ((MyTaskAttemptImpl)otherAttempt).overridingState
              = TaskAttemptState.KILLED;
        } else {
          System.out.println(
              "TLTRE: The normal attempt beat the speculation in "
              + task.getID());
        }
      }
    }
  }

  return result;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:64,代码来源:TestRuntimeEstimators.java


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