You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ka...@apache.org on 2018/04/10 10:05:20 UTC

[1/3] storm git commit: fix STORM-2979

Repository: storm
Updated Branches:
  refs/heads/master 26818f2b4 -> 8120e15ef


fix STORM-2979

Add in WorkerState an internal list of workerHooks and use it to
start/stop

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

Branch: refs/heads/master
Commit: ce7c716fc55c9af792998c2b3d512018cdbd8bec
Parents: ffa607e
Author: michelo <mi...@michelo-desktop>
Authored: Sat Apr 7 18:13:12 2018 +0200
Committer: michelo <mi...@michelo-desktop>
Committed: Sat Apr 7 18:13:12 2018 +0200

----------------------------------------------------------------------
 .../apache/storm/daemon/worker/WorkerState.java | 28 +++++++++++++-------
 1 file changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/ce7c716f/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java b/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
index 9c7cf9e..b763c8d 100644
--- a/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
+++ b/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
@@ -63,7 +63,7 @@ import org.apache.storm.generated.StreamInfo;
 import org.apache.storm.generated.TopologyStatus;
 import org.apache.storm.grouping.Load;
 import org.apache.storm.grouping.LoadMapping;
-import org.apache.storm.hooks.BaseWorkerHook;
+import org.apache.storm.hooks.IWorkerHook;
 import org.apache.storm.messaging.ConnectionWithStatus;
 import org.apache.storm.messaging.DeserializingConnectionCallback;
 import org.apache.storm.messaging.IConnection;
@@ -95,6 +95,11 @@ public class WorkerState {
     final IContext mqContext;
     private final WorkerTransfer workerTransfer;
     private final BackPressureTracker bpTracker;
+    private final List<IWorkerHook> deserializedWorkerHooks;
+
+    public List<IWorkerHook> getDeserializedWorkerHooks() {
+        return deserializedWorkerHooks;
+    }
 
     public Map getConf() {
         return conf;
@@ -339,6 +344,15 @@ public class WorkerState {
         int maxTaskId = getMaxTaskId(componentToSortedTasks);
         this.workerTransfer = new WorkerTransfer(this, topologyConf, maxTaskId);
         this.bpTracker = new BackPressureTracker(workerId, localTaskIds);
+        // 
+        this.deserializedWorkerHooks = new ArrayList<>();
+        if (topology.is_set_worker_hooks()) {
+            for (ByteBuffer hook : topology.get_worker_hooks()) {
+                byte[] hookBytes = Utils.toByteArray(hook);
+                IWorkerHook hookObject = Utils.javaDeserialize(hookBytes, IWorkerHook.class);
+                deserializedWorkerHooks.add(hookObject);
+            }
+        }    
     }
 
     public void refreshConnections() {
@@ -599,20 +613,16 @@ public class WorkerState {
     public void runWorkerStartHooks() {
         WorkerTopologyContext workerContext = getWorkerTopologyContext();
         if (topology.is_set_worker_hooks()) {
-            for (ByteBuffer hook : topology.get_worker_hooks()) {
-                byte[] hookBytes = Utils.toByteArray(hook);
-                BaseWorkerHook hookObject = Utils.javaDeserialize(hookBytes, BaseWorkerHook.class);
-                hookObject.start(topologyConf, workerContext);
+            for (IWorkerHook hook : getDeserializedWorkerHooks()) {
+                hook.start(topologyConf, workerContext);
             }
         }
     }
 
     public void runWorkerShutdownHooks() {
         if (topology.is_set_worker_hooks()) {
-            for (ByteBuffer hook : topology.get_worker_hooks()) {
-                byte[] hookBytes = Utils.toByteArray(hook);
-                BaseWorkerHook hookObject = Utils.javaDeserialize(hookBytes, BaseWorkerHook.class);
-                hookObject.shutdown();
+            for (IWorkerHook hook : getDeserializedWorkerHooks()) {
+                hook.shutdown();
             }
         }
     }


[2/3] storm git commit: small refactoring

Posted by ka...@apache.org.
small refactoring

Use a private method to deserialize hooks
remove unnecessary if statement

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

Branch: refs/heads/master
Commit: d9a369329b741f3f78c9f62e28768faee7063cbd
Parents: ce7c716
Author: michelo <mi...@michelo-desktop>
Authored: Mon Apr 9 21:38:56 2018 +0200
Committer: michelo <mi...@michelo-desktop>
Committed: Mon Apr 9 21:38:56 2018 +0200

----------------------------------------------------------------------
 .../apache/storm/daemon/worker/WorkerState.java | 34 ++++++++++----------
 1 file changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/d9a36932/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java b/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
index b763c8d..e709d04 100644
--- a/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
+++ b/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
@@ -344,15 +344,7 @@ public class WorkerState {
         int maxTaskId = getMaxTaskId(componentToSortedTasks);
         this.workerTransfer = new WorkerTransfer(this, topologyConf, maxTaskId);
         this.bpTracker = new BackPressureTracker(workerId, localTaskIds);
-        // 
-        this.deserializedWorkerHooks = new ArrayList<>();
-        if (topology.is_set_worker_hooks()) {
-            for (ByteBuffer hook : topology.get_worker_hooks()) {
-                byte[] hookBytes = Utils.toByteArray(hook);
-                IWorkerHook hookObject = Utils.javaDeserialize(hookBytes, IWorkerHook.class);
-                deserializedWorkerHooks.add(hookObject);
-            }
-        }    
+        this.deserializedWorkerHooks = deserializeWorkerHooks();
     }
 
     public void refreshConnections() {
@@ -610,20 +602,28 @@ public class WorkerState {
         }
     }
 
-    public void runWorkerStartHooks() {
-        WorkerTopologyContext workerContext = getWorkerTopologyContext();
+    private List<IWorkerHook> deserializeWorkerHooks() {
+        List<IWorkerHook> myHookList = new ArrayList<>();
         if (topology.is_set_worker_hooks()) {
-            for (IWorkerHook hook : getDeserializedWorkerHooks()) {
-                hook.start(topologyConf, workerContext);
+            for (ByteBuffer hook : topology.get_worker_hooks()) {
+                byte[] hookBytes = Utils.toByteArray(hook);
+                IWorkerHook hookObject = Utils.javaDeserialize(hookBytes, IWorkerHook.class);
+                myHookList.add(hookObject);
             }
         }
+        return myHookList;
+    }
+
+    public void runWorkerStartHooks() {
+        WorkerTopologyContext workerContext = getWorkerTopologyContext();
+        for (IWorkerHook hook : getDeserializedWorkerHooks()) {
+            hook.start(topologyConf, workerContext);
+        }
     }
 
     public void runWorkerShutdownHooks() {
-        if (topology.is_set_worker_hooks()) {
-            for (IWorkerHook hook : getDeserializedWorkerHooks()) {
-                hook.shutdown();
-            }
+        for (IWorkerHook hook : getDeserializedWorkerHooks()) {
+            hook.shutdown();
         }
     }
 


[3/3] storm git commit: Merge branch 'STORM-2979-master' of https://github.com/hummelm/storm into STORM-2979-merge

Posted by ka...@apache.org.
Merge branch 'STORM-2979-master' of https://github.com/hummelm/storm into STORM-2979-merge


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

Branch: refs/heads/master
Commit: 8120e15eff36a1415a6590297f682458c783dd1e
Parents: 26818f2 d9a3693
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Tue Apr 10 19:05:08 2018 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Tue Apr 10 19:05:08 2018 +0900

----------------------------------------------------------------------
 .../apache/storm/daemon/worker/WorkerState.java | 32 +++++++++++++-------
 1 file changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/8120e15e/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
----------------------------------------------------------------------
diff --cc storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
index fc94086,e709d04..0bdf8ba
--- a/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
+++ b/storm-client/src/jvm/org/apache/storm/daemon/worker/WorkerState.java
@@@ -95,8 -95,13 +95,13 @@@ public class WorkerState 
      final IContext mqContext;
      private final WorkerTransfer workerTransfer;
      private final BackPressureTracker bpTracker;
+     private final List<IWorkerHook> deserializedWorkerHooks;
+ 
+     public List<IWorkerHook> getDeserializedWorkerHooks() {
+         return deserializedWorkerHooks;
+     }
  
 -    public Map getConf() {
 +    public Map<String, Object> getConf() {
          return conf;
      }