Skip to content

Commit

Permalink
TEZ-4561: Improve reported exception when DAGAppMaster is shutting down.
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushtkn committed Aug 16, 2024
1 parent cd6ceec commit 00a4dfa
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -936,7 +937,7 @@ public void handle(DAGAppMasterEvent event) {
protected class DAGAppMasterShutdownHandler {
private AtomicBoolean shutdownHandled = new AtomicBoolean(false);
private long sleepTimeBeforeExit = TezConstants.TEZ_DAG_SLEEP_TIME_BEFORE_EXIT;

Date shutdownTime;
void setSleepTimeBeforeExit(long sleepTimeBeforeExit) {
this.sleepTimeBeforeExit = sleepTimeBeforeExit;
}
Expand All @@ -954,6 +955,7 @@ public void shutdown(boolean now) {

synchronized (shutdownHandlerRunning) {
shutdownHandlerRunning.set(true);
shutdownTime = new Date(System.currentTimeMillis());
}
LOG.info("Handling DAGAppMaster shutdown");

Expand Down Expand Up @@ -1680,9 +1682,11 @@ public HadoopShim getHadoopShim() {

@Override
public Map<ApplicationAccessType, String> getApplicationACLs() {
if (getServiceState() != STATE.STARTED) {
STATE serviceState = getServiceState();
if (serviceState != STATE.STARTED) {
throw new TezUncheckedException(
"Cannot get ApplicationACLs before all services have started");
"Cannot get ApplicationACLs before all services have started, The current service state is " + serviceState
+ getShutdownTimeString());
}
return taskSchedulerManager.getApplicationAcls();
}
Expand Down Expand Up @@ -1743,6 +1747,13 @@ public void setQueueName(String queueName) {
}
}

private String getShutdownTimeString() {
if (shutdownHandler != null && shutdownHandler.shutdownTime != null) {
return " The shutdown hook started at " + shutdownHandler.shutdownTime;
}
return "";
}

private static class ServiceWithDependency implements ServiceStateChangeListener {
ServiceWithDependency(Service service) {
this.service = service;
Expand Down

0 comments on commit 00a4dfa

Please sign in to comment.