Find the details of someplace where a map has finished
@param mapId the id of the map
@return the task status of the completed task
979961
public synchronized TaskStatus findFinishedMap(int mapId) {
    TaskInProgress tip = maps[mapId];
    if (tip.isComplete()) {
      TaskStatus[] statuses = tip.getTaskStatuses();
      for(int i=0; i < statuses.length; i++) {
        if (statuses[i].getRunState() == TaskStatus.State.SUCCEEDED) {
          return statuses[i];
        }
      }
    }
    return null;
  }
106573
@Override
    public <T> TaskStatus<T> getStatus(long taskId) {
        String owner = getOwner();
        if (owner == null)
            return null;

        TransactionController tranController = new TransactionController();
        TaskRecord taskRecord = null;
        try {
            tranController.preInvoke();
            taskRecord = taskStore.findById(taskId, owner, false);
        } catch (Throwable x) {
            tranController.setFailure(x);
        } finally {
            PersistentStoreException x = tranController.postInvoke(PersistentStoreException.class); // TODO proposed spec class
            if (x != null)
                throw x;
        }

        return taskRecord == null ? null : new TaskStatusImpl<T>(taskRecord, this);
    }
961940
def get_task(task_id, completed=True):
    
    tasks = get_tasks(task_id=task_id, completed=completed)

    if len(tasks) == 0:
        return None

    assert len(tasks) == 1, 'get_task should return at max 1 task for a task id'
    return tasks[0]
446209
public synchronized Task obtainNewMapTask(TaskTrackerStatus tts,
                                            int clusterSize,
                                            int numUniqueHosts,
                                            int maxCacheLevel
                                           ) throws IOException {
    if (status.getRunState() != JobStatus.RUNNING) {
      LOG.info("Cannot create task split for " + profile.getJobID());
      return null;
    }

    int target = findNewMapTask(tts, clusterSize, numUniqueHosts,
                                maxCacheLevel);
    if (target == -1) {
      return null;
    }

    Task result = maps[target].getTaskToRun(tts.getTrackerName());
    if (result != null) {
      addRunningTaskToTIP(maps[target], result.getTaskID(), tts, true);
    }

    return result;
  }
641890
public void completeTask(int taskId) {
		getResourceFactory().getApiResource("/task/" + taskId + "/complete")
				.entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post();
	}
1352455
protected Task getTaskById(String id) {
    return engine.getTaskService().createTaskQuery().taskId(id).initializeFormKeys().singleResult();
  }
482283
public static int getAttemptId(Configuration conf)
      throws IllegalArgumentException {
    if (conf == null) {
      throw new NullPointerException("Conf is null");
    }

    String taskId = conf.get("mapred.task.id");
    if (taskId == null) {
      throw new IllegalArgumentException(
          "Configuration does not contain the property mapred.task.id");
    }

    String[] parts = taskId.split("_");
    if (parts.length != 6 ||
        !parts[0].equals("attempt") ||
        (!"m".equals(parts[3]) && !"r".equals(parts[3]))) {
      throw new IllegalArgumentException(
          "TaskAttemptId string : " + taskId + " is not properly formed");
    }

    return Integer.parseInt(parts[5]);
  }
912587
@Override
  public JobStatus getJobStatus(final JobId jobId) {
    final ZooKeeperClient client = provider.get("getJobStatus");

    final Job job = getJob(client, jobId);
    if (job == null) {
      return null;
    }

    final List<String> hosts;
    try {
      hosts = listJobHosts(client, jobId);
    } catch (JobDoesNotExistException e) {
      return null;
    }

    final ImmutableMap.Builder<String, Deployment> deployments = ImmutableMap.builder();
    final ImmutableMap.Builder<String, TaskStatus> taskStatuses = ImmutableMap.builder();
    for (final String host : hosts) {
      final TaskStatus taskStatus = getTaskStatus(client, host, jobId);
      if (taskStatus != null) {
        taskStatuses.put(host, taskStatus);
      }
      final Deployment deployment = getDeployment(host, jobId);
      if (deployment != null) {
        deployments.put(host, deployment);
      }
    }

    final Map<String, Deployment> deploymentsMap = deployments.build();
    return JobStatus.newBuilder()
        .setJob(job)
        .setDeployments(deploymentsMap)
        .setTaskStatuses(taskStatuses.build())
        .build();
  }
918450
private void moveMapCoordinateElementInMap(final String id) {
        if (getInitialized() && null != id) {
            final WeakReference<MapCoordinateElement> weakReference = mapCoordinateElements.get(id);
            if (null != weakReference) {
                final MapCoordinateElement mapCoordinateElement = weakReference.get();
                if (null != mapCoordinateElement) {
                    if (logger.isTraceEnabled()) {
                        logger.trace("move element in OpenLayers map to {}", mapCoordinateElement);
                    }
                    jsMapView.call("moveMapObject", mapCoordinateElement.getId(),
                            mapCoordinateElement.getPosition().getLatitude(),
                            mapCoordinateElement.getPosition().getLongitude());
                }
            }
        }
    }
1357702
def _check_mr_state(cls, state, mr_id):
    
    if state is None:
      logging.warning(
          "Mapreduce State for job %s is missing. Dropping Task.",
          mr_id)
      return False
    if not state.active:
      logging.warning(
          "Mapreduce %s is not active. Looks like spurious task "
          "execution. Dropping Task.", mr_id)
      return False
    return True
568428
@Override
  public TaskStatus getTaskStatus(final JobId jobId) {
    final byte[] data = taskStatuses.get(jobId.toString());
    if (data == null) {
      return null;
    }
    try {
      return parse(data, TaskStatus.class);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
35617
public void logTaskFinished(TaskID taskId, String taskType,
                              long finishTime, Counters counters) {

    if (disableHistory) {
      return;
    }

    JobID id = taskId.getJobID();
    if (!this.jobId.equals(id)) {
      throw new RuntimeException("JobId from task: " + id +
          " does not match expected: " + jobId);
    }

    if (null != writers) {
      log(writers, RecordTypes.Task,
          new Keys[]{Keys.TASKID, Keys.TASK_TYPE,
                     Keys.TASK_STATUS, Keys.FINISH_TIME,
                     Keys.COUNTERS},
          new String[]{ taskId.toString(), taskType, Values.SUCCESS.name(),
                        String.valueOf(finishTime),
                        counters.makeEscapedCompactString()});
    }
  }
251732
@Override
  public int compareTo(org.apache.hadoop.mapreduce.ID o) {
    JVMId that = (JVMId)o;
    int jobComp = this.jobId.compareTo(that.jobId);
    if(jobComp == 0) {
      if(this.isMap == that.isMap) {
        return this.id - that.id;
      } else {
        return this.isMap ? -1 : 1;
      }
    } else {
      return jobComp;
    }
  }
1323529
public ParallelTask getTaskFromInProgressMap(String jobId) {
        if (!inprogressTaskMap.containsKey(jobId))
            return null;
        return inprogressTaskMap.get(jobId);
    }
773558
public synchronized void setFinished(final int taskId) {
    final TaskEntity task = getTask(taskId, runningTasks);
    runningTasks.remove(task);
    finishedTasks.add(task);
  }
211863
@Override
	public Task findTask(Long taskId) {
		check();
		Task task = null;
		if( this.pessimisticLocking ) {
			return this.em.find( TaskImpl.class, taskId, lockMode );
        }
		task = this.em.find( TaskImpl.class, taskId );
		return task;
	}
462087
void update(JobStatus status) {
    this.status = status;
    try {
      this.counters = running.getCounters();
      this.completed = running.isComplete();
      this.successful = running.isSuccessful();
      this.mapProgress = running.mapProgress();
      this.reduceProgress = running.reduceProgress();
      // running.getTaskCompletionEvents(fromEvent);

    } catch (IOException ioe) {
      ioe.printStackTrace();
    }

    this.completedMaps = (int) (this.totalMaps * this.mapProgress);
    this.completedReduces = (int) (this.totalReduces * this.reduceProgress);
  }