Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.NodeId;
Expand Down Expand Up @@ -63,13 +64,20 @@ public void setLocalityCounter(DAGCounter localityCounter) {
}
}
}

@VisibleForTesting
public void setCounters(TezCounters counters) {
this.counters = counters;
}
}

Task getTask();
TaskAttemptReport getReport();
List<String> getDiagnostics();
TaskAttemptTerminationCause getTerminationCause();
TezCounters getCounters();
@VisibleForTesting
void setCounters(TezCounters counters);
float getProgress();
TaskAttemptState getState();
TaskAttemptState getStateNoLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,17 @@ public TezCounters getCounters() {
readLock.unlock();
}
}

@VisibleForTesting
@Override
public void setCounters(TezCounters counters) {
writeLock.lock();
try {
reportedStatus.setCounters(counters);
} finally {
writeLock.unlock();
}
}

TaskStatistics getStatistics() {
return this.statistics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,20 @@ public TaskReport getReport() {

@Override
public TezCounters getCounters() {
TezCounters counters = new TezCounters();
counters.incrAllCounters(this.counters);
TezCounters tezCounters = null;
if (getVertex().isSpeculationEnabled()) {
tezCounters = new TezCounters();
tezCounters.incrAllCounters(this.counters);
}
readLock.lock();
try {
TaskAttempt bestAttempt = selectBestAttempt();
if (bestAttempt != null) {
counters.incrAllCounters(bestAttempt.getCounters());
TezCounters taskCounters = (bestAttempt != null) ? bestAttempt.getCounters() : TaskAttemptImpl.EMPTY_COUNTERS;
if (getVertex().isSpeculationEnabled()) {
tezCounters.incrAllCounters(taskCounters);
return tezCounters;
}
return counters;
return taskCounters;
} finally {
readLock.unlock();
}
Expand Down Expand Up @@ -1522,10 +1527,9 @@ public void transition(TaskImpl task, TaskEvent event) {
void setCounters(TezCounters counters) {
try {
writeLock.lock();
this.counters = counters;
selectBestAttempt().setCounters(counters);
} finally {
writeLock.unlock();
}
}

}