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 2015/11/24 18:57:19 UTC

[12/16] storm git commit: add javadocs

add javadocs


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

Branch: refs/heads/master
Commit: dfc33ec3dee8968b9d337323ca42e178de8dbd53
Parents: 07d9733
Author: Michael Schonfeld <mi...@schonfeld.org>
Authored: Wed Nov 18 10:44:17 2015 -0500
Committer: Michael Schonfeld <mi...@schonfeld.org>
Committed: Mon Nov 23 18:50:55 2015 -0500

----------------------------------------------------------------------
 .../src/clj/backtype/storm/daemon/worker.clj    |  1 -
 .../backtype/storm/hooks/BaseWorkerHook.java    | 20 ++++++++++++++++++--
 .../jvm/backtype/storm/hooks/IWorkerHook.java   | 19 ++++++++++++++++++-
 3 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/dfc33ec3/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 f522b02..c0a99de 100644
--- a/storm-core/src/clj/backtype/storm/daemon/worker.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/worker.clj
@@ -680,7 +680,6 @@
 
                     (close-resources worker)
 
-                    ;; TODO: here need to invoke the "shutdown" method of WorkerHook
                     (log-message "Trigger any worker shutdown hooks")
                     (run-worker-shutdown-hooks worker)
 

http://git-wip-us.apache.org/repos/asf/storm/blob/dfc33ec3/storm-core/src/jvm/backtype/storm/hooks/BaseWorkerHook.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/hooks/BaseWorkerHook.java b/storm-core/src/jvm/backtype/storm/hooks/BaseWorkerHook.java
index e04f19b..029f671 100644
--- a/storm-core/src/jvm/backtype/storm/hooks/BaseWorkerHook.java
+++ b/storm-core/src/jvm/backtype/storm/hooks/BaseWorkerHook.java
@@ -23,15 +23,31 @@ import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
 
+/**
+ * A BaseWorkerHook is a noop implementation of IWorkerHook. You
+ * may extends this class and implement any and/or all methods you
+ * need for your workers.
+ */
 public class BaseWorkerHook implements IWorkerHook, Serializable {
     private static final long serialVersionUID = 2589466485198339529L;
 
+    /**
+     * This method is called when a worker is started
+     *
+     * @param stormConf The Storm configuration for this worker
+     * @param context This object can be used to get information about this worker's place within the topology
+     * @param taskIds A list of Integers denoting the task IDs assigned to this worker
+     */
     @Override
-    public void start(Map stormConf, WorkerTopologyContext context, List taskIds) {
-
+    public void start(Map stormConf, WorkerTopologyContext context, List<Integer> taskIds) {
+        // NOOP
     }
 
+    /**
+     * This method is called right before a worker shuts down
+     */
     @Override
     public void shutdown() {
+        // NOOP
     }
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/dfc33ec3/storm-core/src/jvm/backtype/storm/hooks/IWorkerHook.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/hooks/IWorkerHook.java b/storm-core/src/jvm/backtype/storm/hooks/IWorkerHook.java
index 6c2bab2..6584883 100644
--- a/storm-core/src/jvm/backtype/storm/hooks/IWorkerHook.java
+++ b/storm-core/src/jvm/backtype/storm/hooks/IWorkerHook.java
@@ -23,7 +23,24 @@ import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
 
+/**
+ * An IWorkerHook represents a topology component that can be executed
+ * when a worker starts, and when a worker shuts down. It can be useful
+ * when you want to execute operations before topology processing starts,
+ * or cleanup operations before your workers shut down.
+ */
 public interface IWorkerHook extends Serializable {
-    void start(Map stormConf, WorkerTopologyContext context, List taskIds);
+    /**
+     * This method is called when a worker is started
+     *
+     * @param stormConf The Storm configuration for this worker
+     * @param context This object can be used to get information about this worker's place within the topology
+     * @param taskIds A list of Integers denoting the task IDs assigned to this worker
+     */
+    void start(Map stormConf, WorkerTopologyContext context, List<Integer> taskIds);
+
+    /**
+     * This method is called right before a worker shuts down
+     */
     void shutdown();
 }
\ No newline at end of file