You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by pt...@apache.org on 2015/06/03 19:35:35 UTC

[21/50] [abbrv] storm git commit: improve error logging

improve error logging


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

Branch: refs/heads/master
Commit: 01702dc503e4f5fbcc499dcae48bb3ffad1229db
Parents: ae305c7
Author: P. Taylor Goetz <pt...@gmail.com>
Authored: Wed Apr 8 01:10:30 2015 -0400
Committer: P. Taylor Goetz <pt...@gmail.com>
Committed: Wed Apr 8 01:10:30 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/storm/flux/FluxBuilder.java |  9 +-
 .../java/org/apache/storm/flux/TCKTest.java     | 10 ++
 .../src/test/resources/configs/bad_hbase.yaml   | 98 ++++++++++++++++++++
 3 files changed, 114 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/01702dc5/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java
----------------------------------------------------------------------
diff --git a/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java b/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java
index 964c62e..57237b6 100644
--- a/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java
+++ b/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java
@@ -286,7 +286,10 @@ public class FluxBuilder {
                 LOG.debug("Found something seemingly compatible, attempting invocation...");
                 obj = con.newInstance(getArgsWithListCoercian(cArgs, con.getParameterTypes()));
             } else {
-                throw new IllegalArgumentException("Couldn't find a suitable constructor.");
+                String msg = String.format("Couldn't find a suitable constructor for class '%s' with arguments '%s'.",
+                        clazz.getName(),
+                        cArgs);
+                throw new IllegalArgumentException(msg);
             }
         } else {
             obj = clazz.newInstance();
@@ -419,9 +422,9 @@ public class FluxBuilder {
                 Object[] methodArgs = getArgsWithListCoercian(args, method.getParameterTypes());
                 method.invoke(instance, methodArgs);
             } else {
-                LOG.warn("Unable to find method '{}' in class '{}' with arguments {}.",
+                String msg = String.format("Unable to find configuration method '%s' in class '%s' with arguments %s.",
                         new Object[]{methodName, clazz.getName(), args});
-                throw new IllegalArgumentException("Configuration method not found.");
+                throw new IllegalArgumentException(msg);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/storm/blob/01702dc5/flux-core/src/test/java/org/apache/storm/flux/TCKTest.java
----------------------------------------------------------------------
diff --git a/flux-core/src/test/java/org/apache/storm/flux/TCKTest.java b/flux-core/src/test/java/org/apache/storm/flux/TCKTest.java
index 27abfbe..9456d1b 100644
--- a/flux-core/src/test/java/org/apache/storm/flux/TCKTest.java
+++ b/flux-core/src/test/java/org/apache/storm/flux/TCKTest.java
@@ -91,6 +91,16 @@ public class TCKTest {
         topology.validate();
     }
 
+    @Test(expected = IllegalArgumentException.class)
+    public void testBadHbase() throws Exception {
+        TopologyDef topologyDef = FluxParser.parseResource("/configs/bad_hbase.yaml", false, true, null, false);
+        Config conf = FluxBuilder.buildConfig(topologyDef);
+        ExecutionContext context = new ExecutionContext(topologyDef, conf);
+        StormTopology topology = FluxBuilder.buildTopology(context);
+        assertNotNull(topology);
+        topology.validate();
+    }
+
     @Test
     public void testIncludes() throws Exception {
         TopologyDef topologyDef = FluxParser.parseResource("/configs/include_test.yaml", false, true, null, false);

http://git-wip-us.apache.org/repos/asf/storm/blob/01702dc5/flux-core/src/test/resources/configs/bad_hbase.yaml
----------------------------------------------------------------------
diff --git a/flux-core/src/test/resources/configs/bad_hbase.yaml b/flux-core/src/test/resources/configs/bad_hbase.yaml
new file mode 100644
index 0000000..5d91400
--- /dev/null
+++ b/flux-core/src/test/resources/configs/bad_hbase.yaml
@@ -0,0 +1,98 @@
+# 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.
+
+# Test ability to wire together shell spouts/bolts
+---
+
+# topology definition
+# name to be used when submitting
+name: "hbase-wordcount"
+
+# Components
+# Components are analagous to Spring beans. They are meant to be used as constructor,
+# property(setter), and builder arguments.
+#
+# for the time being, components must be declared in the order they are referenced
+
+components:
+  - id: "columnFields"
+    className: "backtype.storm.tuple.Fields"
+    constructorArgs:
+      - ["word"]
+
+  - id: "counterFields"
+    className: "backtype.storm.tuple.Fields"
+    constructorArgs:
+      # !!! the following won't work, and should thow an IllegalArgumentException...
+      - "count"
+
+  - id: "mapper"
+    className: "org.apache.storm.hbase.bolt.mapper.SimpleHBaseMapper"
+    configMethods:
+      - name: "withRowKeyField"
+        args: ["word"]
+      - name: "withColumnFields"
+        args: [ref: "columnFields"]
+      - name: "withCounterFields"
+        args: [ref: "counterFields"]
+      - name: "withColumnFamily"
+        args: ["cf"]
+
+# topology configuration
+# this will be passed to the submitter as a map of config options
+#
+config:
+  topology.workers: 1
+  hbase.conf:
+    hbase.rootdir: "hdfs://hadoop:54310/hbase"
+    hbase.zookeeper.quorum: "hadoop"
+
+# spout definitions
+spouts:
+  - id: "word-spout"
+    className: "backtype.storm.testing.TestWordSpout"
+    parallelism: 1
+
+# bolt definitions
+
+bolts:
+  - id: "count-bolt"
+    className: "backtype.storm.testing.TestWordCounter"
+
+  - id: "hbase-bolt"
+    className: "org.apache.storm.hbase.bolt.HBaseBolt"
+    constructorArgs:
+      - "WordCount" # HBase table name
+      - ref: "mapper"
+    configMethods:
+      - name: "withConfigKey"
+        args: ["hbase.conf"]
+    parallelism: 1
+
+
+streams:
+  - name: "" # name isn't used (placeholder for logging, UI, etc.)
+    from: "word-spout"
+    to: "count-bolt"
+    grouping:
+      type: SHUFFLE
+
+  - name: "" # name isn't used (placeholder for logging, UI, etc.)
+    from: "count-bolt"
+    to: "hbase-bolt"
+    grouping:
+      type: FIELDS
+      args: ["word"]
\ No newline at end of file