TEZ-4350: Remove synchronized from DAGAppMaster.serviceInit (#162)
diff --git a/tez-dag/findbugs-exclude.xml b/tez-dag/findbugs-exclude.xml
index 50422ff..e875583 100644
--- a/tez-dag/findbugs-exclude.xml
+++ b/tez-dag/findbugs-exclude.xml
@@ -154,24 +154,8 @@
<Match>
<Class name="org.apache.tez.dag.app.DAGAppMaster"/>
<Or>
- <Field name="context"/>
- <Field name="clientAMHeartbeatTimeoutIntervalMillis"/>
- <Field name="clientHandler"/>
<Field name="currentDAG"/>
- <Field name="state"/>
- <Field name="taskSchedulerManager"/>
- <Field name="versionMismatch"/>
- <Field name="versionMismatchDiagnostics"/>
- <Field name="containers"/>
- <Field name="currentRecoveryDataDir"/>
- <Field name="execService"/>
- <Field name="historyEventHandler"/>
- <Field name="nodes"/>
- <Field name="recoveryEnabled"/>
- <Field name="isLocal"/>
- <Field name="hadoopShim"/>
- <Field name="containerLauncherManager"/>
- <Field name="taskCommunicatorManager"/>
+ <Field name="lastDAGCompletionTime"/>
</Or>
<Bug pattern="IS2_INCONSISTENT_SYNC"/>
</Match>
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java b/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
index abc10bd..f15c73c 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
@@ -416,7 +416,7 @@
}
@Override
- public synchronized void serviceInit(final Configuration conf) throws Exception {
+ protected void serviceInit(final Configuration conf) throws Exception {
this.amConf = conf;
initResourceCalculatorPlugins();
@@ -1923,7 +1923,7 @@
}
@Override
- public synchronized void serviceStart() throws Exception {
+ public void serviceStart() throws Exception {
//start all the components
startServices();
super.serviceStart();
@@ -2115,57 +2115,55 @@
if (isSession) {
sessionStopped.set(true);
}
- synchronized (this) {
- if (this.dagSubmissionTimer != null) {
- this.dagSubmissionTimer.cancel();
- }
- if (this.clientAMHeartBeatTimeoutService != null) {
- this.clientAMHeartBeatTimeoutService.shutdownNow();
- }
- // release all the held containers before stop services TEZ-2687
- initiateStop();
- stopServices();
+ if (this.dagSubmissionTimer != null) {
+ this.dagSubmissionTimer.cancel();
+ }
+ if (this.clientAMHeartBeatTimeoutService != null) {
+ this.clientAMHeartBeatTimeoutService.shutdownNow();
+ }
+ // release all the held containers before stop services TEZ-2687
+ initiateStop();
+ stopServices();
- // Given pre-emption, we should delete tez scratch dir only if unregister is
- // successful
- boolean deleteTezScratchData = this.amConf.getBoolean(
- TezConfiguration.TEZ_AM_STAGING_SCRATCH_DATA_AUTO_DELETE,
- TezConfiguration.TEZ_AM_STAGING_SCRATCH_DATA_AUTO_DELETE_DEFAULT);
- LOG.debug("Checking whether tez scratch data dir should be deleted, deleteTezScratchData={}",
- deleteTezScratchData);
- if (deleteTezScratchData && this.taskSchedulerManager != null
- && this.taskSchedulerManager.hasUnregistered()) {
- // Delete tez scratch data dir
- if (this.tezSystemStagingDir != null) {
- try {
- this.appMasterUgi.doAs(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() throws Exception {
- FileSystem fs = tezSystemStagingDir.getFileSystem(amConf);
- boolean deletedStagingDir = fs.delete(tezSystemStagingDir, true);
- if (!deletedStagingDir) {
- LOG.warn("Failed to delete tez scratch data dir, path="
- + tezSystemStagingDir);
- } else {
- LOG.info("Completed deletion of tez scratch data dir, path="
- + tezSystemStagingDir);
- }
- return null;
+ // Given pre-emption, we should delete tez scratch dir only if unregister is
+ // successful
+ boolean deleteTezScratchData = this.amConf.getBoolean(
+ TezConfiguration.TEZ_AM_STAGING_SCRATCH_DATA_AUTO_DELETE,
+ TezConfiguration.TEZ_AM_STAGING_SCRATCH_DATA_AUTO_DELETE_DEFAULT);
+ LOG.debug("Checking whether tez scratch data dir should be deleted, deleteTezScratchData={}",
+ deleteTezScratchData);
+ if (deleteTezScratchData && this.taskSchedulerManager != null
+ && this.taskSchedulerManager.hasUnregistered()) {
+ // Delete tez scratch data dir
+ if (this.tezSystemStagingDir != null) {
+ try {
+ this.appMasterUgi.doAs(new PrivilegedExceptionAction<Void>() {
+ @Override
+ public Void run() throws Exception {
+ FileSystem fs = tezSystemStagingDir.getFileSystem(amConf);
+ boolean deletedStagingDir = fs.delete(tezSystemStagingDir, true);
+ if (!deletedStagingDir) {
+ LOG.warn("Failed to delete tez scratch data dir, path="
+ + tezSystemStagingDir);
+ } else {
+ LOG.info("Completed deletion of tez scratch data dir, path="
+ + tezSystemStagingDir);
}
- });
- } catch (IOException e) {
- // Best effort to delete tez scratch data dir
- LOG.warn("Failed to delete tez scratch data dir", e);
- }
+ return null;
+ }
+ });
+ } catch (IOException e) {
+ // Best effort to delete tez scratch data dir
+ LOG.warn("Failed to delete tez scratch data dir", e);
}
}
-
- if (execService != null) {
- execService.shutdownNow();
- }
-
- super.serviceStop();
}
+
+ if (execService != null) {
+ execService.shutdownNow();
+ }
+
+ super.serviceStop();
}
private class DagEventDispatcher implements EventHandler<DAGEvent> {