|
@@ -978,35 +978,39 @@ class JobInProgress {
|
|
|
/*
|
|
|
* Return task cleanup attempt if any, to run on a given tracker
|
|
|
*/
|
|
|
- public synchronized Task obtainTaskCleanupTask(TaskTrackerStatus tts,
|
|
|
+ public Task obtainTaskCleanupTask(TaskTrackerStatus tts,
|
|
|
boolean isMapSlot)
|
|
|
throws IOException {
|
|
|
- if (this.status.getRunState() != JobStatus.RUNNING ||
|
|
|
- jobFailed || jobKilled) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- String taskTracker = tts.getTrackerName();
|
|
|
- if (!shouldRunOnTaskTracker(taskTracker)) {
|
|
|
+ if (!tasksInited.get()) {
|
|
|
return null;
|
|
|
}
|
|
|
- TaskAttemptID taskid = null;
|
|
|
- TaskInProgress tip = null;
|
|
|
- if (isMapSlot) {
|
|
|
- if (!mapCleanupTasks.isEmpty()) {
|
|
|
- taskid = mapCleanupTasks.remove(0);
|
|
|
- tip = maps[taskid.getTaskID().getId()];
|
|
|
+ synchronized (this) {
|
|
|
+ if (this.status.getRunState() != JobStatus.RUNNING ||
|
|
|
+ jobFailed || jobKilled) {
|
|
|
+ return null;
|
|
|
}
|
|
|
- } else {
|
|
|
- if (!reduceCleanupTasks.isEmpty()) {
|
|
|
- taskid = reduceCleanupTasks.remove(0);
|
|
|
- tip = reduces[taskid.getTaskID().getId()];
|
|
|
+ String taskTracker = tts.getTrackerName();
|
|
|
+ if (!shouldRunOnTaskTracker(taskTracker)) {
|
|
|
+ return null;
|
|
|
}
|
|
|
+ TaskAttemptID taskid = null;
|
|
|
+ TaskInProgress tip = null;
|
|
|
+ if (isMapSlot) {
|
|
|
+ if (!mapCleanupTasks.isEmpty()) {
|
|
|
+ taskid = mapCleanupTasks.remove(0);
|
|
|
+ tip = maps[taskid.getTaskID().getId()];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!reduceCleanupTasks.isEmpty()) {
|
|
|
+ taskid = reduceCleanupTasks.remove(0);
|
|
|
+ tip = reduces[taskid.getTaskID().getId()];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tip != null) {
|
|
|
+ return tip.addRunningTask(taskid, taskTracker, true);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
- if (tip != null) {
|
|
|
- return tip.addRunningTask(taskid, taskTracker, true);
|
|
|
- }
|
|
|
- return null;
|
|
|
}
|
|
|
|
|
|
public synchronized Task obtainNewLocalMapTask(TaskTrackerStatus tts,
|
|
@@ -1111,9 +1115,6 @@ class JobInProgress {
|
|
|
* @return true/false
|
|
|
*/
|
|
|
private synchronized boolean canLaunchJobCleanupTask() {
|
|
|
- if (!tasksInited.get()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
// check if the job is running
|
|
|
if (status.getRunState() != JobStatus.RUNNING &&
|
|
|
status.getRunState() != JobStatus.PREP) {
|
|
@@ -2444,6 +2445,7 @@ class JobInProgress {
|
|
|
*/
|
|
|
synchronized void garbageCollect() {
|
|
|
// Let the JobTracker know that a job is complete
|
|
|
+ jobtracker.storeCompletedJob(this);
|
|
|
jobtracker.finalizeJob(this);
|
|
|
|
|
|
try {
|
|
@@ -2467,8 +2469,7 @@ class JobInProgress {
|
|
|
// Delete temp dfs dirs created if any, like in case of
|
|
|
// speculative exn of reduces.
|
|
|
Path tempDir = new Path(jobtracker.getSystemDir(), jobId.toString());
|
|
|
- FileSystem fs = tempDir.getFileSystem(conf);
|
|
|
- fs.delete(tempDir, true);
|
|
|
+ new CleanupQueue().addToQueue(conf,tempDir);
|
|
|
} catch (IOException e) {
|
|
|
LOG.warn("Error cleaning up "+profile.getJobID()+": "+e);
|
|
|
}
|
|
@@ -2479,6 +2480,7 @@ class JobInProgress {
|
|
|
this.runningMapCache = null;
|
|
|
this.nonRunningReduces = null;
|
|
|
this.runningReduces = null;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|