You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2014/06/25 16:02:57 UTC

[1/6] git commit: replacing RunTime.halt() with RunTime.exit() with a special shutdown hook that allows 1 second for cleanup shutdown hooks and then sends kill -9 to process. Added shutdown hooks for supervisor and worker.

Repository: incubator-storm
Updated Branches:
  refs/heads/master 97db22a6e -> 8f2e74933


replacing RunTime.halt() with RunTime.exit() with a special shutdown hook that allows 1 second for cleanup shutdown hooks and then sends kill -9 to process. Added shutdown hooks for supervisor and worker.


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/2c2570fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/2c2570fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/2c2570fc

Branch: refs/heads/master
Commit: 2c2570fcd707b71d69db81736ba703707cee3ae7
Parents: ecac64f
Author: Parth Brahmbhatt <br...@gmail.com>
Authored: Mon Jun 16 14:06:05 2014 -0700
Committer: Parth Brahmbhatt <br...@gmail.com>
Committed: Mon Jun 16 14:06:05 2014 -0700

----------------------------------------------------------------------
 storm-core/src/clj/backtype/storm/cluster.clj   |  2 +-
 .../src/clj/backtype/storm/daemon/common.clj    |  2 +-
 .../src/clj/backtype/storm/daemon/drpc.clj      |  7 ++-
 .../src/clj/backtype/storm/daemon/nimbus.clj    |  6 ++-
 .../clj/backtype/storm/daemon/supervisor.clj    |  5 +-
 .../src/clj/backtype/storm/daemon/worker.clj    | 11 ++--
 storm-core/src/clj/backtype/storm/disruptor.clj |  2 +-
 storm-core/src/clj/backtype/storm/event.clj     |  2 +-
 storm-core/src/clj/backtype/storm/util.clj      | 55 +++++++++++++++-----
 9 files changed, 63 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2c2570fc/storm-core/src/clj/backtype/storm/cluster.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/cluster.clj b/storm-core/src/clj/backtype/storm/cluster.clj
index e370b97..7625c0d 100644
--- a/storm-core/src/clj/backtype/storm/cluster.clj
+++ b/storm-core/src/clj/backtype/storm/cluster.clj
@@ -239,7 +239,7 @@
                          SUPERVISORS-ROOT (issue-callback! supervisors-callback)
                          STORMS-ROOT (issue-map-callback! storm-base-callback (first args))
                          ;; this should never happen
-                         (halt-process! 30 "Unknown callback for subtree " subtree args)))))]
+                         (exit-process! 30 "Unknown callback for subtree " subtree args)))))]
     (doseq [p [ASSIGNMENTS-SUBTREE STORMS-SUBTREE SUPERVISORS-SUBTREE WORKERBEATS-SUBTREE ERRORS-SUBTREE]]
       (mkdirs cluster-state p))
     (reify

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2c2570fc/storm-core/src/clj/backtype/storm/daemon/common.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/daemon/common.clj b/storm-core/src/clj/backtype/storm/daemon/common.clj
index e6bf81a..43746b3 100644
--- a/storm-core/src/clj/backtype/storm/daemon/common.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/common.clj
@@ -104,7 +104,7 @@
         (throw e#))
       (catch Throwable t#
         (log-error t# "Error on initialization of server " ~(str name))
-        (halt-process! 13 "Error on initialization")
+        (exit-process! 13 "Error on initialization")
         )))))
 
 (defn- validate-ids! [^StormTopology topology]

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2c2570fc/storm-core/src/clj/backtype/storm/daemon/drpc.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/daemon/drpc.clj b/storm-core/src/clj/backtype/storm/daemon/drpc.clj
index eb4d6d3..3527b7c 100644
--- a/storm-core/src/clj/backtype/storm/daemon/drpc.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/drpc.clj
@@ -158,10 +158,9 @@
                             (.protocolFactory (TBinaryProtocol$Factory.))
                             (.processor
                               (DistributedRPCInvocations$Processor. service-handler))))]
-
-      (.addShutdownHook
-        (Runtime/getRuntime)
-        (Thread. (fn [] (.stop handler-server) (.stop invoke-server))))
+      (add-shutdown-hook-with-force-kill-in-1-sec (fn []
+                                                    (.stop handler-server)
+                                                    (.stop invoke-server)))
       (log-message "Starting Distributed RPC servers...")
       (future (.serve invoke-server))
       (.serve handler-server))))

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2c2570fc/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/daemon/nimbus.clj b/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
index bf22a1b..83202d5 100644
--- a/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
@@ -73,7 +73,7 @@
      :validator (new-instance (conf NIMBUS-TOPOLOGY-VALIDATOR))
      :timer (mk-timer :kill-fn (fn [t]
                                  (log-error t "Error when processing event")
-                                 (halt-process! 20 "Error when processing an event")
+                                 (exit-process! 20 "Error when processing an event")
                                  ))
      :scheduler (mk-scheduler conf inimbus)
      }))
@@ -1153,7 +1153,9 @@
                     (.processor (Nimbus$Processor. service-handler))
                     )
        server (THsHaServer. (do (set! (. options maxReadBufferBytes)(conf NIMBUS-THRIFT-MAX-BUFFER-SIZE)) options))]
-    (.addShutdownHook (Runtime/getRuntime) (Thread. (fn [] (.shutdown service-handler) (.stop server))))
+    (add-shutdown-hook-with-force-kill-in-1-sec (fn []
+                                                  (.shutdown service-handler)
+                                                  (.stop server)))
     (log-message "Starting Nimbus server...")
     (.serve server)))
 

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2c2570fc/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/daemon/supervisor.clj b/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
index 7566a79..a0a9cca 100644
--- a/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
@@ -197,7 +197,7 @@
    :curr-assignment (atom nil) ;; used for reporting used ports when heartbeating
    :timer (mk-timer :kill-fn (fn [t]
                                (log-error t "Error when processing event")
-                               (halt-process! 20 "Error when processing an event")
+                               (exit-process! 20 "Error when processing an event")
                                ))
    })
 
@@ -543,7 +543,8 @@
 (defn -launch [supervisor]
   (let [conf (read-storm-config)]
     (validate-distributed-mode! conf)
-    (mk-supervisor conf nil supervisor)))
+    (let [supervisor (mk-supervisor conf nil supervisor)]
+      (add-shutdown-hook-with-force-kill-in-1-sec #(.shutdown supervisor)))))
 
 (defn standalone-supervisor []
   (let [conf-atom (atom nil)

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2c2570fc/storm-core/src/clj/backtype/storm/daemon/worker.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/daemon/worker.clj b/storm-core/src/clj/backtype/storm/daemon/worker.clj
index 16765d9..74475ee 100644
--- a/storm-core/src/clj/backtype/storm/daemon/worker.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/worker.clj
@@ -170,7 +170,7 @@
 (defn mk-halting-timer [timer-name]
   (mk-timer :kill-fn (fn [t]
                        (log-error t "Error when processing event")
-                       (halt-process! 20 "Error when processing an event")
+                       (exit-process! 20 "Error when processing an event")
                        )
             :timer-name timer-name))
 
@@ -331,7 +331,7 @@
     (:port worker)
     (:transfer-local-fn worker)
     (-> worker :storm-conf (get TOPOLOGY-RECEIVER-BUFFER-SIZE))
-    :kill-fn (fn [t] (halt-process! 11))))
+    :kill-fn (fn [t] (exit-process! 11))))
 
 (defn- close-resources [worker]
   (let [dr (:default-shared-resources worker)]
@@ -442,13 +442,14 @@
 
 (defmethod mk-suicide-fn
   :local [conf]
-  (fn [] (halt-process! 1 "Worker died")))
+  (fn [] (exit-process! 1 "Worker died")))
 
 (defmethod mk-suicide-fn
   :distributed [conf]
-  (fn [] (halt-process! 1 "Worker died")))
+  (fn [] (exit-process! 1 "Worker died")))
 
 (defn -main [storm-id assignment-id port-str worker-id]  
   (let [conf (read-storm-config)]
     (validate-distributed-mode! conf)
-    (mk-worker conf nil storm-id assignment-id (Integer/parseInt port-str) worker-id)))
+    (let [worker (mk-worker conf nil storm-id assignment-id (Integer/parseInt port-str) worker-id)]
+      (add-shutdown-hook-with-force-kill-in-1-sec #(.shutdown worker)))))

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2c2570fc/storm-core/src/clj/backtype/storm/disruptor.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/disruptor.clj b/storm-core/src/clj/backtype/storm/disruptor.clj
index 40b47fc..a723601 100644
--- a/storm-core/src/clj/backtype/storm/disruptor.clj
+++ b/storm-core/src/clj/backtype/storm/disruptor.clj
@@ -89,7 +89,7 @@
 
 (defnk consume-loop*
   [^DisruptorQueue queue handler
-   :kill-fn (fn [error] (halt-process! 1 "Async loop died!"))]
+   :kill-fn (fn [error] (exit-process! 1 "Async loop died!"))]
   (let [ret (async-loop
               (fn [] (consume-batch-when-available queue handler) 0)
               :kill-fn kill-fn

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2c2570fc/storm-core/src/clj/backtype/storm/event.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/event.clj b/storm-core/src/clj/backtype/storm/event.clj
index f92c9bb..00d1c0e 100644
--- a/storm-core/src/clj/backtype/storm/event.clj
+++ b/storm-core/src/clj/backtype/storm/event.clj
@@ -42,7 +42,7 @@
                        (log-message "Event manager interrupted"))
                      (catch Throwable t
                        (log-error t "Error when processing event")
-                       (halt-process! 20 "Error when processing an event")))))]
+                       (exit-process! 20 "Error when processing an event")))))]
     (.setDaemon runner daemon?)
     (.start runner)
     (reify

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2c2570fc/storm-core/src/clj/backtype/storm/util.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/util.clj b/storm-core/src/clj/backtype/storm/util.clj
index 91b0713..db2db4a 100644
--- a/storm-core/src/clj/backtype/storm/util.clj
+++ b/storm-core/src/clj/backtype/storm/util.clj
@@ -312,10 +312,10 @@
   [& vals]
   (byte-array (map byte vals)))
 
-(defn halt-process!
+(defn exit-process!
   [val & msg]
   (log-message "Halting process: " msg)
-  (.halt (Runtime/getRuntime) val))
+  (.exit (Runtime/getRuntime) val))
 
 (defn sum
   [vals]
@@ -388,13 +388,51 @@
     (catch IOException e
       (log-message "Could not extract " dir " from " jarpath))))
 
-(defn ensure-process-killed! [pid]
+(defn sleep-secs [secs]
+  (when (pos? secs)
+    (Time/sleep (* (long secs) 1000))))
+
+(defn sleep-until-secs [target-secs]
+  (Time/sleepUntil (* (long target-secs) 1000)))
+
+(def ^:const sig-kill 9)
+
+(def ^:const sig-term 15)
+
+(defn send-signal-to-process
+  [pid signum]
+  (try-cause
+    (exec-command! (str (if on-windows?
+                          (if (== signum sig-kill) "taskkill /f /pid " "taskkill /pid ")
+                          (str "kill -" signum " "))
+                     pid))
+    (catch ExecuteException e
+      (log-message "Error when trying to kill " pid ". Process is probably already dead."))))
+
+(defn force-kill-process
+  [pid]
+  (send-signal-to-process pid sig-kill))
+
+(defn kill-process-with-sig-term
+  [pid]
+  (send-signal-to-process pid sig-term))
+
+(defn ensure-process-killed!
+  [pid]
   ;; TODO: should probably do a ps ax of some sort to make sure it was killed
   (try-cause
-    (exec-command! (str (if on-windows? "taskkill /f /pid " "kill -9 ") pid))
+    (kill-process-with-sig-term pid)
     (catch ExecuteException e
       (log-message "Error when trying to kill " pid ". Process is probably already dead."))))
 
+(defn add-shutdown-hook-with-force-kill-in-1-sec
+  "adds the user supplied function as a shutdown hook for cleanup.
+   Also adds a function that sleeps for a second and then sends kill -9 to process to avoid any zombie process in case
+   cleanup function hangs."
+  [func]
+  (.addShutdownHook (Runtime/getRuntime) (Thread. #((func)
+                                                     (sleep-secs 1)
+                                                     (force-kill-process (process-pid))))))
 (defnk launch-process [command :environment {}]
   (let [builder (ProcessBuilder. command)
         process-env (.environment builder)]
@@ -402,13 +440,6 @@
       (.put process-env k v))
     (.start builder)))
 
-(defn sleep-secs [secs]
-  (when (pos? secs)
-    (Time/sleep (* (long secs) 1000))))
-
-(defn sleep-until-secs [target-secs]
-  (Time/sleepUntil (* (long target-secs) 1000)))
-
 (defprotocol SmartThread
   (start [this])
   (join [this])
@@ -418,7 +449,7 @@
 ;; afn returns amount of time to sleep
 (defnk async-loop [afn
                    :daemon false
-                   :kill-fn (fn [error] (halt-process! 1 "Async loop died!"))
+                   :kill-fn (fn [error] (exit-process! 1 "Async loop died!"))
                    :priority Thread/NORM_PRIORITY
                    :factory? false
                    :start true


[6/6] git commit: Added STORM-183 to CHANGELOG and README

Posted by bo...@apache.org.
Added STORM-183 to CHANGELOG and README


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/8f2e7493
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/8f2e7493
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/8f2e7493

Branch: refs/heads/master
Commit: 8f2e749333f5a3cd810349ce799c68bc22fd0c43
Parents: c755088
Author: Robert (Bobby) Evans <bo...@apache.org>
Authored: Wed Jun 25 08:57:41 2014 -0500
Committer: Robert (Bobby) Evans <bo...@apache.org>
Committed: Wed Jun 25 08:57:41 2014 -0500

----------------------------------------------------------------------
 CHANGELOG.md    | 1 +
 README.markdown | 1 +
 2 files changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/8f2e7493/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5a32ea0..38c1f7d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
  * STORM-360: Add node details for Error Topology and Component pages
  * STORM-54: Per-Topology Classpath and Environment for Workers
  * STORM-355: excluding outdated netty transitively included via curator
+ * STORM-183: Replacing RunTime.halt() with RunTime.exit()
 
 ## 0.9.2-incubating
  * STORM-66: send taskid on initial handshake

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/8f2e7493/README.markdown
----------------------------------------------------------------------
diff --git a/README.markdown b/README.markdown
index 970e5a4..e2890c0 100644
--- a/README.markdown
+++ b/README.markdown
@@ -146,6 +146,7 @@ under the License.
 * Aaron Zimmerman ([@aaronzimmerman](https://github.com/aaronzimmerman))
 * Albert Chu ([@chu11](https://github.com/chu11))
 * Krystian Nowak ([@krystiannowak](https://github.com/krystiannowak))
+* Parth-Brahmbhatt ([@Parth-Brahmbhatt](https://github.com/Parth-Brahmbhatt))
 
 ## Acknowledgements
 


[4/6] git commit: STORM-183: Replacing RunTime.halt() with RunTime.exit() with a special shutdown hook that allows 1 second for cleanup shutdown hooks and then sends kill -9 to process. Added shutdown hooks for supervisor and worker.

Posted by bo...@apache.org.
STORM-183: Replacing RunTime.halt() with RunTime.exit() with a special shutdown hook that allows 1 second for cleanup shutdown hooks and then sends kill -9 to process. Added shutdown hooks for supervisor and worker.


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/f3646c42
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/f3646c42
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/f3646c42

Branch: refs/heads/master
Commit: f3646c42ff4bcbcf685357d31326e5a62ad241d4
Parents: cca3527
Author: Parth Brahmbhatt <br...@gmail.com>
Authored: Mon Jun 16 14:06:05 2014 -0700
Committer: Parth Brahmbhatt <br...@gmail.com>
Committed: Fri Jun 20 12:28:51 2014 -0700

----------------------------------------------------------------------
 storm-core/src/clj/backtype/storm/daemon/supervisor.clj | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/f3646c42/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/daemon/supervisor.clj b/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
index 1cc4814..1c0e996 100644
--- a/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
@@ -172,14 +172,13 @@
     (when thread-pid
       (psim/kill-process thread-pid))
     (doseq [pid pids]
-      (kill-process-with-sig-term pid)
-      (try
-        (rmpath (worker-pid-path conf id pid))
-        (catch Exception e)) ;; on windows, the supervisor may still holds the lock on the worker directory
-      )
+      (kill-process-with-sig-term pid))
     (if-not (empty? pids) (sleep-secs 1)) ;; allow 1 second for execution of cleanup threads on worker.
     (doseq [pid pids]
-      (force-kill-process pid))
+      (force-kill-process pid)
+      (try
+        (rmpath (worker-pid-path conf id pid))
+        (catch Exception e))) ;; on windows, the supervisor may still holds the lock on the worker directory
     (try-cleanup-worker conf id))
   (log-message "Shut down " (:supervisor-id supervisor) ":" id))
 


[5/6] git commit: Merge branch 'STORM-183' of https://github.com/Parth-Brahmbhatt/incubator-storm into STORM-183

Posted by bo...@apache.org.
Merge branch 'STORM-183' of https://github.com/Parth-Brahmbhatt/incubator-storm into STORM-183

STORM-183: Replacing RunTime.halt() with RunTime.exit()


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/c7550881
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/c7550881
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/c7550881

Branch: refs/heads/master
Commit: c7550881325dab70b56919c56ad6218802c45e47
Parents: 97db22a f3646c4
Author: Robert (Bobby) Evans <bo...@apache.org>
Authored: Wed Jun 25 08:50:10 2014 -0500
Committer: Robert (Bobby) Evans <bo...@apache.org>
Committed: Wed Jun 25 08:50:10 2014 -0500

----------------------------------------------------------------------
 storm-core/src/clj/backtype/storm/cluster.clj   |  2 +-
 .../src/clj/backtype/storm/daemon/common.clj    |  2 +-
 .../src/clj/backtype/storm/daemon/drpc.clj      |  7 ++-
 .../src/clj/backtype/storm/daemon/nimbus.clj    |  6 ++-
 .../clj/backtype/storm/daemon/supervisor.clj    | 13 +++--
 .../src/clj/backtype/storm/daemon/worker.clj    | 11 +++--
 storm-core/src/clj/backtype/storm/disruptor.clj |  2 +-
 storm-core/src/clj/backtype/storm/event.clj     |  2 +-
 storm-core/src/clj/backtype/storm/util.clj      | 50 +++++++++++++++-----
 9 files changed, 62 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/c7550881/storm-core/src/clj/backtype/storm/cluster.clj
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/c7550881/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/c7550881/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/c7550881/storm-core/src/clj/backtype/storm/util.clj
----------------------------------------------------------------------


[3/6] git commit: STORM-183: Replacing RunTime.halt() with RunTime.exit() with a special shutdown hook that allows 1 second for cleanup shutdown hooks and then sends kill -9 to process. Added shutdown hooks for supervisor and worker.

Posted by bo...@apache.org.
STORM-183: Replacing RunTime.halt() with RunTime.exit() with a special shutdown hook that allows 1 second for cleanup shutdown hooks and then sends kill -9 to process. Added shutdown hooks for supervisor and worker.


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/cca35276
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/cca35276
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/cca35276

Branch: refs/heads/master
Commit: cca35276d2b8e38f5a89c6ecc4e0ce7ef04a14c2
Parents: de8855d
Author: Parth Brahmbhatt <br...@gmail.com>
Authored: Mon Jun 16 14:06:05 2014 -0700
Committer: Parth Brahmbhatt <br...@gmail.com>
Committed: Tue Jun 17 09:42:55 2014 -0700

----------------------------------------------------------------------
 storm-core/src/clj/backtype/storm/daemon/supervisor.clj | 5 ++++-
 storm-core/src/clj/backtype/storm/util.clj              | 8 --------
 2 files changed, 4 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/cca35276/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/daemon/supervisor.clj b/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
index a0a9cca..1cc4814 100644
--- a/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/supervisor.clj
@@ -172,11 +172,14 @@
     (when thread-pid
       (psim/kill-process thread-pid))
     (doseq [pid pids]
-      (ensure-process-killed! pid)
+      (kill-process-with-sig-term pid)
       (try
         (rmpath (worker-pid-path conf id pid))
         (catch Exception e)) ;; on windows, the supervisor may still holds the lock on the worker directory
       )
+    (if-not (empty? pids) (sleep-secs 1)) ;; allow 1 second for execution of cleanup threads on worker.
+    (doseq [pid pids]
+      (force-kill-process pid))
     (try-cleanup-worker conf id))
   (log-message "Shut down " (:supervisor-id supervisor) ":" id))
 

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/cca35276/storm-core/src/clj/backtype/storm/util.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/util.clj b/storm-core/src/clj/backtype/storm/util.clj
index 4ca2951..8ef5d19 100644
--- a/storm-core/src/clj/backtype/storm/util.clj
+++ b/storm-core/src/clj/backtype/storm/util.clj
@@ -417,14 +417,6 @@
   [pid]
   (send-signal-to-process pid sig-term))
 
-(defn ensure-process-killed!
-  [pid]
-  ;; TODO: should probably do a ps ax of some sort to make sure it was killed
-  (try-cause
-    (kill-process-with-sig-term pid)
-    (catch ExecuteException e
-      (log-message "Error when trying to kill " pid ". Process is probably already dead."))))
-
 (defn add-shutdown-hook-with-force-kill-in-1-sec
   "adds the user supplied function as a shutdown hook for cleanup.
    Also adds a function that sleeps for a second and then sends kill -9 to process to avoid any zombie process in case


[2/6] git commit: STORM-183: Replacing RunTime.halt() with RunTime.exit() with a special shutdown hook that allows 1 second for cleanup shutdown hooks and then sends kill -9 to process. Added shutdown hooks for supervisor and worker.

Posted by bo...@apache.org.
STORM-183: Replacing RunTime.halt() with RunTime.exit() with a special shutdown hook that allows 1 second for cleanup shutdown hooks and then sends kill -9 to process. Added shutdown hooks for supervisor and worker.


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/de8855d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/de8855d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/de8855d1

Branch: refs/heads/master
Commit: de8855d1dd6fbbfe431c33d49013a19881548732
Parents: 2c2570f
Author: Parth Brahmbhatt <br...@gmail.com>
Authored: Mon Jun 16 14:06:05 2014 -0700
Committer: Parth Brahmbhatt <br...@gmail.com>
Committed: Mon Jun 16 15:21:04 2014 -0700

----------------------------------------------------------------------
 storm-core/src/clj/backtype/storm/util.clj | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/de8855d1/storm-core/src/clj/backtype/storm/util.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/util.clj b/storm-core/src/clj/backtype/storm/util.clj
index db2db4a..4ca2951 100644
--- a/storm-core/src/clj/backtype/storm/util.clj
+++ b/storm-core/src/clj/backtype/storm/util.clj
@@ -430,9 +430,10 @@
    Also adds a function that sleeps for a second and then sends kill -9 to process to avoid any zombie process in case
    cleanup function hangs."
   [func]
-  (.addShutdownHook (Runtime/getRuntime) (Thread. #((func)
-                                                     (sleep-secs 1)
-                                                     (force-kill-process (process-pid))))))
+  (.addShutdownHook (Runtime/getRuntime) (Thread. #(func)))
+  (.addShutdownHook (Runtime/getRuntime) (Thread. #((sleep-secs 1)
+                                                    (.halt (Runtime/getRuntime) 20)))))
+
 (defnk launch-process [command :environment {}]
   (let [builder (ProcessBuilder. command)
         process-env (.environment builder)]