Skip to content

Commit

Permalink
Use setter & getter.
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushtkn committed Aug 28, 2024
1 parent 9dc1b51 commit 1790462
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
17 changes: 13 additions & 4 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 @@ -937,7 +937,16 @@ 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;
private Date shutdownTime;

public Date getShutdownTime() {
return shutdownTime;
}

public void setShutdownTime(Date shutdownTime) {
this.shutdownTime = shutdownTime;
}

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

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

Expand Down Expand Up @@ -1748,8 +1757,8 @@ public void setQueueName(String queueName) {
}

private String getShutdownTimeString() {
if (shutdownHandler != null && shutdownHandler.shutdownTime != null) {
return " The shutdown hook started at " + shutdownHandler.shutdownTime;
if (shutdownHandler != null && shutdownHandler.getShutdownTime() != null) {
return " The shutdown hook started at " + shutdownHandler.getShutdownTime();
}
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;

import java.io.ByteArrayInputStream;
import java.io.DataInput;
Expand Down Expand Up @@ -508,11 +509,11 @@ public void testGetACLFailure() throws Exception {
() -> dam.getContext().getApplicationACLs());
dam.start();
dam.stop();
dam.mockShutdown.shutdownTime = Date.from(Instant.ofEpochMilli(Time.now()));
Mockito.when(dam.mockShutdown.getShutdownTime()).thenReturn(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());
+ dam.mockShutdown.getShutdownTime(), () -> dam.getContext().getApplicationACLs());
}

@Test
Expand Down

0 comments on commit 1790462

Please sign in to comment.