chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r764144 - in /hadoop/chukwa: branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java trunk/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java
Date Sat, 11 Apr 2009 01:44:18 GMT
Author: eyang
Date: Sat Apr 11 01:44:17 2009
New Revision: 764144

URL: http://svn.apache.org/viewvc?rev=764144&view=rev
Log:
CHUKWA-98.  Added Daemon watcher to capture signal for pid file management. (Cheng Zhang via
Eric Yang)


Added:
    hadoop/chukwa/branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java

Added: hadoop/chukwa/branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java?rev=764144&view=auto
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java
(added)
+++ hadoop/chukwa/branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java
Sat Apr 11 01:44:17 2009
@@ -0,0 +1,28 @@
+package org.apache.hadoop.chukwa.util;
+
+public class DaemonWatcher extends PidFile {
+  private static DaemonWatcher instance = null;
+  
+  public synchronized static DaemonWatcher createInstance(String name) {
+    if(instance == null) {
+      instance = new DaemonWatcher(name);
+      Runtime.getRuntime().addShutdownHook(instance);
+    }
+    return instance;
+  }
+  
+  public static DaemonWatcher getInstance() {
+    return instance;
+  }
+  
+  private DaemonWatcher(String name) {
+    super(name);
+  }
+  
+  public static void bailout(int status) {
+    if(instance != null) {
+      Runtime.getRuntime().removeShutdownHook(instance);
+    }
+    System.exit(status);
+  }
+}

Added: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java?rev=764144&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java (added)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/DaemonWatcher.java Sat Apr
11 01:44:17 2009
@@ -0,0 +1,28 @@
+package org.apache.hadoop.chukwa.util;
+
+public class DaemonWatcher extends PidFile {
+  private static DaemonWatcher instance = null;
+  
+  public synchronized static DaemonWatcher createInstance(String name) {
+    if(instance == null) {
+      instance = new DaemonWatcher(name);
+      Runtime.getRuntime().addShutdownHook(instance);
+    }
+    return instance;
+  }
+  
+  public static DaemonWatcher getInstance() {
+    return instance;
+  }
+  
+  private DaemonWatcher(String name) {
+    super(name);
+  }
+  
+  public static void bailout(int status) {
+    if(instance != null) {
+      Runtime.getRuntime().removeShutdownHook(instance);
+    }
+    System.exit(status);
+  }
+}



Mime
View raw message