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
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;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's strange that this separate string generation method takes care of the closing point of the previous sentence, I believe that should go back to getApplicationACLs

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved the "." back to the {{getApplicationACLs}}

}
return "";
}

private static class ServiceWithDependency implements ServiceStateChangeListener {
ServiceWithDependency(Service service) {
this.service = service;
Expand Down
28 changes: 25 additions & 3 deletions tez-dag/src/test/java/org/apache/tez/dag/app/TestDAGAppMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
import org.apache.hadoop.security.token.SecretManager;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
import org.apache.hadoop.util.Progressable;
import org.apache.hadoop.test.LambdaTestUtils;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ContainerId;
Expand All @@ -49,6 +50,7 @@
import org.apache.tez.dag.api.NamedEntityDescriptor;
import org.apache.tez.dag.api.TezConfiguration;
import org.apache.tez.dag.api.TezConstants;
import org.apache.tez.dag.api.TezUncheckedException;
import org.apache.tez.dag.api.UserPayload;
import org.apache.tez.dag.api.records.DAGProtos;
import org.apache.tez.dag.api.records.DAGProtos.AMPluginDescriptorProto;
Expand All @@ -73,12 +75,12 @@
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.URI;
import java.nio.ByteBuffer;
import java.time.Instant;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -493,6 +495,26 @@ public void testDagCredentialsWithMerge() throws Exception {
testDagCredentials(true);
}

@Test
public void testGetACLFailure() throws Exception {
ApplicationId appId = ApplicationId.newInstance(1, 1);
ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 2);
DAGAppMasterForTest dam = new DAGAppMasterForTest(attemptId, true);
TezConfiguration conf = new TezConfiguration(false);
conf.setBoolean(TezConfiguration.DAG_RECOVERY_ENABLED, false);
dam.init(conf);
LambdaTestUtils.intercept(TezUncheckedException.class,
"Cannot get ApplicationACLs before all services have started, The current service state is INITED",
() -> dam.getContext().getApplicationACLs());
dam.start();
dam.stop();
dam.mockShutdown.shutdownTime = Date.from(Instant.ofEpochMilli(Time.now()));
LambdaTestUtils.intercept(TezUncheckedException.class,
" Cannot get ApplicationACLs before all services have started, "
+ "The current service state is STOPPED. The shutdown hook started at "
+ dam.mockShutdown.shutdownTime, () -> dam.getContext().getApplicationACLs());
}

@Test
public void testBadProgress() throws Exception {
TezConfiguration conf = new TezConfiguration();
Expand Down