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 2015/09/21 01:15:59 UTC

[1/3] storm git commit: [STORM-1044] Setting dop to zero does not raise an error - added IllegalArgumentException to .setBolt(...), .setSpout(...), and .setStateSpout(...) in TopologyBuilder

Repository: storm
Updated Branches:
  refs/heads/master 18acb8afa -> 2d871005f


[STORM-1044] Setting dop to zero does not raise an error
 - added IllegalArgumentException to .setBolt(...), .setSpout(...), and .setStateSpout(...) in TopologyBuilder


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

Branch: refs/heads/master
Commit: 8ed57abb5a13cf59a66fb7eb3339b27ec2fe3e60
Parents: 0a5426e
Author: mjsax <mj...@informatik.hu-berlin.de>
Authored: Tue Sep 15 13:56:56 2015 +0200
Committer: mjsax <mj...@informatik.hu-berlin.de>
Committed: Wed Sep 16 10:20:07 2015 +0200

----------------------------------------------------------------------
 .../storm/topology/TopologyBuilder.java         | 32 +++++++++----
 .../test/clj/backtype/storm/nimbus_test.clj     | 10 ----
 .../storm/topology/TopologyBuilderTest.java     | 48 ++++++++++++++++++++
 3 files changed, 70 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/8ed57abb/storm-core/src/jvm/backtype/storm/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/topology/TopologyBuilder.java b/storm-core/src/jvm/backtype/storm/topology/TopologyBuilder.java
index 806549a..4d5a0bd 100644
--- a/storm-core/src/jvm/backtype/storm/topology/TopologyBuilder.java
+++ b/storm-core/src/jvm/backtype/storm/topology/TopologyBuilder.java
@@ -123,8 +123,9 @@ public class TopologyBuilder {
      * @param id the id of this component. This id is referenced by other components that want to consume this bolt's outputs.
      * @param bolt the bolt
      * @return use the returned object to declare the inputs to this component
+     * @throws IllegalArgumentException if {@code parallelism_hint} is not positive
      */
-    public BoltDeclarer setBolt(String id, IRichBolt bolt) {
+    public BoltDeclarer setBolt(String id, IRichBolt bolt) throws IllegalArgumentException {
         return setBolt(id, bolt, null);
     }
 
@@ -135,8 +136,9 @@ public class TopologyBuilder {
      * @param bolt the bolt
      * @param parallelism_hint the number of tasks that should be assigned to execute this bolt. Each task will run on a thread in a process somewhere around the cluster.
      * @return use the returned object to declare the inputs to this component
+     * @throws IllegalArgumentException if {@code parallelism_hint} is not positive
      */
-    public BoltDeclarer setBolt(String id, IRichBolt bolt, Number parallelism_hint) {
+    public BoltDeclarer setBolt(String id, IRichBolt bolt, Number parallelism_hint) throws IllegalArgumentException {
         validateUnusedId(id);
         initCommon(id, bolt, parallelism_hint);
         _bolts.put(id, bolt);
@@ -152,8 +154,9 @@ public class TopologyBuilder {
      * @param id the id of this component. This id is referenced by other components that want to consume this bolt's outputs.
      * @param bolt the basic bolt
      * @return use the returned object to declare the inputs to this component
+     * @throws IllegalArgumentException if {@code parallelism_hint} is not positive
      */
-    public BoltDeclarer setBolt(String id, IBasicBolt bolt) {
+    public BoltDeclarer setBolt(String id, IBasicBolt bolt) throws IllegalArgumentException {
         return setBolt(id, bolt, null);
     }
 
@@ -167,8 +170,9 @@ public class TopologyBuilder {
      * @param bolt the basic bolt
      * @param parallelism_hint the number of tasks that should be assigned to execute this bolt. Each task will run on a thread in a process somwehere around the cluster.
      * @return use the returned object to declare the inputs to this component
+     * @throws IllegalArgumentException if {@code parallelism_hint} is not positive
      */
-    public BoltDeclarer setBolt(String id, IBasicBolt bolt, Number parallelism_hint) {
+    public BoltDeclarer setBolt(String id, IBasicBolt bolt, Number parallelism_hint) throws IllegalArgumentException {
         return setBolt(id, new BasicBoltExecutor(bolt), parallelism_hint);
     }
 
@@ -177,8 +181,9 @@ public class TopologyBuilder {
      *
      * @param id the id of this component. This id is referenced by other components that want to consume this spout's outputs.
      * @param spout the spout
+     * @throws IllegalArgumentException if {@code parallelism_hint} is not positive
      */
-    public SpoutDeclarer setSpout(String id, IRichSpout spout) {
+    public SpoutDeclarer setSpout(String id, IRichSpout spout) throws IllegalArgumentException {
         return setSpout(id, spout, null);
     }
 
@@ -190,19 +195,20 @@ public class TopologyBuilder {
      * @param id the id of this component. This id is referenced by other components that want to consume this spout's outputs.
      * @param parallelism_hint the number of tasks that should be assigned to execute this spout. Each task will run on a thread in a process somwehere around the cluster.
      * @param spout the spout
+     * @throws IllegalArgumentException if {@code parallelism_hint} is not positive
      */
-    public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelism_hint) {
+    public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelism_hint) throws IllegalArgumentException {
         validateUnusedId(id);
         initCommon(id, spout, parallelism_hint);
         _spouts.put(id, spout);
         return new SpoutGetter(id);
     }
 
-    public void setStateSpout(String id, IRichStateSpout stateSpout) {
+    public void setStateSpout(String id, IRichStateSpout stateSpout) throws IllegalArgumentException {
         setStateSpout(id, stateSpout, null);
     }
 
-    public void setStateSpout(String id, IRichStateSpout stateSpout, Number parallelism_hint) {
+    public void setStateSpout(String id, IRichStateSpout stateSpout, Number parallelism_hint) throws IllegalArgumentException {
         validateUnusedId(id);
         // TODO: finish
     }
@@ -229,10 +235,16 @@ public class TopologyBuilder {
         return ret;        
     }
     
-    private void initCommon(String id, IComponent component, Number parallelism) {
+    private void initCommon(String id, IComponent component, Number parallelism) throws IllegalArgumentException {
         ComponentCommon common = new ComponentCommon();
         common.set_inputs(new HashMap<GlobalStreamId, Grouping>());
-        if(parallelism!=null) common.set_parallelism_hint(parallelism.intValue());
+        if(parallelism!=null) {
+            int dop = parallelism.intValue();
+            if(dop < 1) {
+                throw new IllegalArgumentException("Parallelism must be positive.");
+            }
+            common.set_parallelism_hint(dop);
+        }
         Map conf = component.getComponentConfiguration();
         if(conf!=null) common.set_json_conf(JSONValue.toJSONString(conf));
         _commons.put(id, common);

http://git-wip-us.apache.org/repos/asf/storm/blob/8ed57abb/storm-core/test/clj/backtype/storm/nimbus_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/nimbus_test.clj b/storm-core/test/clj/backtype/storm/nimbus_test.clj
index cbd88c4..2bfcc60 100644
--- a/storm-core/test/clj/backtype/storm/nimbus_test.clj
+++ b/storm-core/test/clj/backtype/storm/nimbus_test.clj
@@ -846,16 +846,6 @@
                   NIMBUS-SLOTS-PER-TOPOLOGY 8}]
     (letlocals
       (bind topology (thrift/mk-topology
-                        {"1" (thrift/mk-spout-spec (TestPlannerSpout. true) :parallelism-hint 0 :conf {TOPOLOGY-TASKS 1})}
-                        {}))
-     
-      (is (thrown? InvalidTopologyException
-        (submit-local-topology (:nimbus cluster)
-                               "test"
-                               {}
-                               topology)))
-                               
-      (bind topology (thrift/mk-topology
                         {"1" (thrift/mk-spout-spec (TestPlannerSpout. true) :parallelism-hint 1 :conf {TOPOLOGY-TASKS 1})}
                         {}))
       (is (thrown? InvalidTopologyException

http://git-wip-us.apache.org/repos/asf/storm/blob/8ed57abb/storm-core/test/jvm/backtype/storm/topology/TopologyBuilderTest.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/backtype/storm/topology/TopologyBuilderTest.java b/storm-core/test/jvm/backtype/storm/topology/TopologyBuilderTest.java
new file mode 100644
index 0000000..934bd69
--- /dev/null
+++ b/storm-core/test/jvm/backtype/storm/topology/TopologyBuilderTest.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package backtype.storm.topology;
+
+import org.junit.Test;
+
+import static org.mockito.Mockito.mock;
+
+public class TopologyBuilderTest {
+    private final TopologyBuilder builder = new TopologyBuilder();
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testSetRichBolt() {
+        builder.setBolt("bolt", mock(IRichBolt.class), 0);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testSetBasicBolt() {
+        builder.setBolt("bolt", mock(IBasicBolt.class), 0);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testSetSpout() {
+        builder.setSpout("spout", mock(IRichSpout.class), 0);
+    }
+
+    // TODO enable if setStateSpout gets implemented
+//    @Test(expected = IllegalArgumentException.class)
+//    public void testSetStateSpout() {
+//        builder.setStateSpout("stateSpout", mock(IRichStateSpout.class), 0);
+//    }
+
+}
\ No newline at end of file


[3/3] storm git commit: add STORM-1044 to CHANGELOG.md

Posted by ka...@apache.org.
add STORM-1044 to CHANGELOG.md

* also add Matthias J. Sax to contributor list


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

Branch: refs/heads/master
Commit: 2d871005ff8fa0fffc4b7f47a5f564df73c8842c
Parents: cf61b46
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Mon Sep 21 08:12:04 2015 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Mon Sep 21 08:12:04 2015 +0900

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


http://git-wip-us.apache.org/repos/asf/storm/blob/2d871005/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 18a3d08..ed07617 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -57,6 +57,7 @@
  * STORM-949: On the topology summary UI page, last shown error should have the time and date
 
 ## 0.10.0-beta2
+ * STORM-1044: Setting dop to zero does not raise an error
  * STORM-1050: Topologies with same name run on one cluster
  * STORM-1005: Supervisor do not get running workers after restart.
  * STORM-803: Better CI logs

http://git-wip-us.apache.org/repos/asf/storm/blob/2d871005/README.markdown
----------------------------------------------------------------------
diff --git a/README.markdown b/README.markdown
index cd5ed80..8f13af3 100644
--- a/README.markdown
+++ b/README.markdown
@@ -229,6 +229,7 @@ under the License.
 * Abhishek Agarwal ([@abhishekagarwal87](https://github.com/abhishekagarwal87))
 * chenyuzhao ([@danny0405](https://github.com/danny0405))
 * Michael Schonfeld ([@schonfeld](https://github.com/schonfeld))
+* Matthias J. Sax ([@mjsax](https://github.com/mjsax))
 
 ## Acknowledgements
 


[2/3] storm git commit: Merge branch 'storm-1044-dop' of https://github.com/mjsax/storm into STORM-1044

Posted by ka...@apache.org.
Merge branch 'storm-1044-dop' of https://github.com/mjsax/storm into STORM-1044


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

Branch: refs/heads/master
Commit: cf61b46319469bd4ac223be6859f061ad9c197e4
Parents: 18acb8a 8ed57ab
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Mon Sep 21 07:47:10 2015 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Mon Sep 21 07:47:10 2015 +0900

----------------------------------------------------------------------
 .../storm/topology/TopologyBuilder.java         | 32 +++++++++----
 .../test/clj/backtype/storm/nimbus_test.clj     | 10 ----
 .../storm/topology/TopologyBuilderTest.java     | 48 ++++++++++++++++++++
 3 files changed, 70 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/cf61b463/storm-core/src/jvm/backtype/storm/topology/TopologyBuilder.java
----------------------------------------------------------------------