Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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,19 @@ 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());
if (bestAttempt != null && tezCounters != null) {
Copy link
Contributor

@abstractdog abstractdog Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tezCounters != null only if speculation is enabled due to the recent patch, would it make sense to use that condition here for better readability? I guess it would clarify that we only use "this.counter" and this whole stuff in case of speculation
also, we're returning a non-null counter anyway, would this be clearer as:

TezCounters taskCounters = (bestAttempt != null) ? bestAttempt.getCounters() : TaskAttemptImpl.EMPTY_COUNTERS;

if (isSpeculationEnabled){
  tezCounters.incrAllCounters(taskCounters); 
  return tezCounters;
}
return taskCounters;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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

}