hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1333748 - /hadoop/common/trunk/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java
Date Fri, 04 May 2012 03:20:18 GMT
Author: tucu
Date: Fri May  4 03:20:16 2012
New Revision: 1333748

URL: http://svn.apache.org/viewvc?rev=1333748&view=rev
Log:
MAPREDUCE-4205. retrofit all JVM shutdown hooks to use ShutdownHookManager (tucu)

Modified:
    hadoop/common/trunk/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java

Modified: hadoop/common/trunk/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java?rev=1333748&r1=1333747&r2=1333748&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java
(original)
+++ hadoop/common/trunk/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java
Fri May  4 03:20:16 2012
@@ -33,6 +33,7 @@ import org.apache.hadoop.tools.CopyListi
 import org.apache.hadoop.tools.mapred.CopyMapper;
 import org.apache.hadoop.tools.mapred.CopyOutputFormat;
 import org.apache.hadoop.tools.util.DistCpUtils;
+import org.apache.hadoop.util.ShutdownHookManager;
 import org.apache.hadoop.util.Tool;
 import org.apache.hadoop.util.ToolRunner;
 
@@ -49,6 +50,12 @@ import java.util.Random;
  * behaviour.
  */
 public class DistCp extends Configured implements Tool {
+
+  /**
+   * Priority of the ResourceManager shutdown hook.
+   */
+  public static final int SHUTDOWN_HOOK_PRIORITY = 30;
+
   private static final Log LOG = LogFactory.getLog(DistCp.class);
 
   private DistCpOptions inputOptions;
@@ -353,7 +360,8 @@ public class DistCp extends Configured i
       DistCp distCp = new DistCp();
       Cleanup CLEANUP = new Cleanup(distCp);
 
-      Runtime.getRuntime().addShutdownHook(CLEANUP);
+      ShutdownHookManager.get().addShutdownHook(CLEANUP,
+        SHUTDOWN_HOOK_PRIORITY);
       System.exit(ToolRunner.run(getDefaultConf(), distCp, argv));
     }
     catch (Exception e) {
@@ -388,7 +396,7 @@ public class DistCp extends Configured i
     return submitted;
   }
 
-  private static class Cleanup extends Thread {
+  private static class Cleanup implements Runnable {
     private final DistCp distCp;
 
     public Cleanup(DistCp distCp) {



Mime
View raw message