You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cu...@apache.org on 2006/04/25 21:26:24 UTC
svn commit: r396959 - in /lucene/hadoop/trunk: CHANGES.txt
src/java/org/apache/hadoop/mapred/TaskTracker.java
Author: cutting
Date: Tue Apr 25 12:26:21 2006
New Revision: 396959
URL: http://svn.apache.org/viewcvs?rev=396959&view=rev
Log:
Fix HADOOP-160. Remove some uneeded synchronization around time-consuming operations in the TaskTracker.
Modified:
lucene/hadoop/trunk/CHANGES.txt
lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/TaskTracker.java
Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/CHANGES.txt?rev=396959&r1=396958&r2=396959&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Tue Apr 25 12:26:21 2006
@@ -90,6 +90,9 @@
implementations for writing metric data to a file and for sending
it to Ganglia. (David Bowen via cutting)
+25. Fix HADOOP-160. Remove some uneeded synchronization around
+ time-consuming operations in the TaskTracker. (omalley via cutting)
+
Release 0.1.1 - 2006-04-08
Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/TaskTracker.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/TaskTracker.java?rev=396959&r1=396958&r2=396959&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/TaskTracker.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/TaskTracker.java Tue Apr 25 12:26:21 2006
@@ -338,6 +338,8 @@
} else {
reduceTotal++;
}
+ }
+ synchronized (tip) {
try {
tip.launchTask();
} catch (Throwable ie) {
@@ -424,7 +426,7 @@
* Some fields in the Task object need to be made machine-specific.
* So here, edit the Task's fields appropriately.
*/
- void localizeTask(Task t) throws IOException {
+ private void localizeTask(Task t) throws IOException {
this.jobConf.deleteLocalFiles(SUBDIR + "/" + task.getTaskId());
Path localJobFile =
this.jobConf.getLocalPath(SUBDIR+"/"+t.getTaskId()+"/"+"job.xml");
@@ -460,7 +462,7 @@
/**
*/
- public TaskStatus createStatus() {
+ public synchronized TaskStatus createStatus() {
TaskStatus status = new TaskStatus(task.getTaskId(), task.isMapTask(), progress, runstate, diagnosticInfo.toString(), (stateString == null) ? "" : stateString, "");
if (diagnosticInfo.length() > 0) {
diagnosticInfo = new StringBuffer();
@@ -520,7 +522,7 @@
/**
* The task has actually finished running.
*/
- public synchronized void taskFinished() {
+ public void taskFinished() {
long start = System.currentTimeMillis();
//
@@ -538,13 +540,17 @@
// Change state to success or failure, depending on whether
// task was 'done' before terminating
//
- if (done) {
- runstate = TaskStatus.SUCCEEDED;
- } else {
- if (!wasKilled) {
- failures += 1;
- }
- runstate = TaskStatus.FAILED;
+ boolean needCleanup = false;
+ synchronized (this) {
+ if (done) {
+ runstate = TaskStatus.SUCCEEDED;
+ } else {
+ if (!wasKilled) {
+ failures += 1;
+ }
+ runstate = TaskStatus.FAILED;
+ }
+ needCleanup = wasKilled || runstate == TaskStatus.FAILED;
}
//
@@ -553,7 +559,7 @@
// if the task succeeded, and its results might be useful
// later on to downstream job processing.
//
- if (wasKilled || runstate == TaskStatus.FAILED) {
+ if (needCleanup) {
try {
cleanup();
} catch (IOException ie) {
@@ -594,10 +600,8 @@
if (runstate == TaskStatus.SUCCEEDED) {
LOG.info("Reporting output lost:"+task.getTaskId());
runstate = TaskStatus.FAILED; // change status to failure
- synchronized (TaskTracker.this) { // force into next heartbeat
- runningTasks.put(task.getTaskId(), this);
- mapTotal++;
- }
+ runningTasks.put(task.getTaskId(), this);
+ mapTotal++;
} else {
LOG.warning("Output already reported lost:"+task.getTaskId());
}
@@ -699,8 +703,11 @@
/**
* The task is no longer running. It may not have completed successfully
*/
- synchronized void reportTaskFinished(String taskid) {
- TaskInProgress tip = (TaskInProgress) tasks.get(taskid);
+ void reportTaskFinished(String taskid) {
+ TaskInProgress tip;
+ synchronized (this) {
+ tip = (TaskInProgress) tasks.get(taskid);
+ }
if (tip != null) {
tip.taskFinished();
} else {