Repository: storm Updated Branches: refs/heads/1.x-branch fe50a1b55 -> 97e7d25fe
STORM-1668: Fix silent failing of flux for setting a non-existent property. Project: http://git-wip-us.apache.org/repos/asf/storm/repo Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/be09c3c1 Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/be09c3c1 Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/be09c3c1 Branch: refs/heads/1.x-branch Commit: be09c3c1fd05ec1ed8f8d7768c4023691946d0e2 Parents: 652d2f6 Author: Priyank <[email protected]> Authored: Wed Mar 30 16:23:05 2016 -0700 Committer: Priyank <[email protected]> Committed: Wed Mar 30 16:27:12 2016 -0700 ---------------------------------------------------------------------- docs/flux.md | 6 ++-- external/flux/README.md | 6 ++-- .../java/org/apache/storm/flux/FluxBuilder.java | 29 ++++++++------------ .../src/test/resources/configs/kafka_test.yaml | 2 +- .../src/main/resources/kafka_spout.yaml | 2 +- 5 files changed, 20 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/storm/blob/be09c3c1/docs/flux.md ---------------------------------------------------------------------- diff --git a/docs/flux.md b/docs/flux.md index 19bb1df..454cad8 100644 --- a/docs/flux.md +++ b/docs/flux.md @@ -408,7 +408,7 @@ JavaBean-like setter methods and fields declared as `public`: # id - "myId" properties: - - name: "forceFromStart" + - name: "ignoreZkOffsets" value: true - name: "scheme" ref: "stringMultiScheme" @@ -416,7 +416,7 @@ JavaBean-like setter methods and fields declared as `public`: In the example above, the `properties` declaration will cause Flux to look for a public method in the `SpoutConfig` with the signature `setForceFromStart(boolean b)` and attempt to invoke it. If a setter method is not found, Flux will then -look for a public instance variable with the name `forceFromStart` and attempt to set its value. +look for a public instance variable with the name `ignoreZkOffsets` and attempt to set its value. References may also be used as property values. @@ -604,7 +604,7 @@ components: # id - "myId" properties: - - name: "forceFromStart" + - name: "ignoreZkOffsets" value: true - name: "scheme" ref: "stringMultiScheme" http://git-wip-us.apache.org/repos/asf/storm/blob/be09c3c1/external/flux/README.md ---------------------------------------------------------------------- diff --git a/external/flux/README.md b/external/flux/README.md index 7043689..586c3ca 100644 --- a/external/flux/README.md +++ b/external/flux/README.md @@ -404,7 +404,7 @@ JavaBean-like setter methods and fields declared as `public`: # id - "myId" properties: - - name: "forceFromStart" + - name: "ignoreZkOffsets" value: true - name: "scheme" ref: "stringMultiScheme" @@ -412,7 +412,7 @@ JavaBean-like setter methods and fields declared as `public`: In the example above, the `properties` declaration will cause Flux to look for a public method in the `SpoutConfig` with the signature `setForceFromStart(boolean b)` and attempt to invoke it. If a setter method is not found, Flux will then -look for a public instance variable with the name `forceFromStart` and attempt to set its value. +look for a public instance variable with the name `ignoreZkOffsets` and attempt to set its value. References may also be used as property values. @@ -603,7 +603,7 @@ components: # id - "myId" properties: - - name: "forceFromStart" + - name: "ignoreZkOffsets" value: true - name: "scheme" ref: "stringMultiScheme" http://git-wip-us.apache.org/repos/asf/storm/blob/be09c3c1/external/flux/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java ---------------------------------------------------------------------- diff --git a/external/flux/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java b/external/flux/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java index c16aa05..00e1201 100644 --- a/external/flux/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java +++ b/external/flux/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java @@ -59,7 +59,7 @@ public class FluxBuilder { * @throws InvocationTargetException */ public static StormTopology buildTopology(ExecutionContext context) throws IllegalAccessException, - InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException { + InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, NoSuchFieldException { StormTopology topology = null; TopologyDef topologyDef = context.getTopologyDef(); @@ -145,7 +145,7 @@ public class FluxBuilder { */ private static void buildStreamDefinitions(ExecutionContext context, TopologyBuilder builder) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, - IllegalAccessException { + IllegalAccessException, NoSuchFieldException { TopologyDef topologyDef = context.getTopologyDef(); // process stream definitions HashMap<String, BoltDeclarer> declarers = new HashMap<String, BoltDeclarer>(); @@ -219,7 +219,7 @@ public class FluxBuilder { } private static void applyProperties(ObjectDef bean, Object instance, ExecutionContext context) throws - IllegalAccessException, InvocationTargetException { + IllegalAccessException, InvocationTargetException, NoSuchFieldException { List<PropertyDef> props = bean.getProperties(); Class clazz = instance.getClass(); if (props != null) { @@ -242,13 +242,8 @@ public class FluxBuilder { } } - private static Field findPublicField(Class clazz, String property, Object arg) { - Field field = null; - try { - field = clazz.getField(property); - } catch (NoSuchFieldException e) { - LOG.warn("Could not find setter or public variable for property: " + property, e); - } + private static Field findPublicField(Class clazz, String property, Object arg) throws NoSuchFieldException { + Field field = clazz.getField(property); return field; } @@ -284,7 +279,7 @@ public class FluxBuilder { } private static Object buildObject(ObjectDef def, ExecutionContext context) throws ClassNotFoundException, - IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { + IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException, NoSuchFieldException { Class clazz = Class.forName(def.getClassName()); Object obj = null; if (def.hasConstructorArgs()) { @@ -313,7 +308,7 @@ public class FluxBuilder { private static StormTopology buildExternalTopology(ObjectDef def, ExecutionContext context) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, - InvocationTargetException { + InvocationTargetException, NoSuchFieldException { Object topologySource = buildObject(def, context); @@ -330,7 +325,7 @@ public class FluxBuilder { private static CustomStreamGrouping buildCustomStreamGrouping(ObjectDef def, ExecutionContext context) throws ClassNotFoundException, - IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { + IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException, NoSuchFieldException { Object grouping = buildObject(def, context); return (CustomStreamGrouping)grouping; } @@ -340,7 +335,7 @@ public class FluxBuilder { * keyed by the component id. */ private static void buildComponents(ExecutionContext context) throws ClassNotFoundException, NoSuchMethodException, - IllegalAccessException, InvocationTargetException, InstantiationException { + IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException { Collection<BeanDef> cDefs = context.getTopologyDef().getComponents(); if (cDefs != null) { for (BeanDef bean : cDefs) { @@ -352,7 +347,7 @@ public class FluxBuilder { private static void buildSpouts(ExecutionContext context, TopologyBuilder builder) throws ClassNotFoundException, - NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { + NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchFieldException { for (SpoutDef sd : context.getTopologyDef().getSpouts()) { IRichSpout spout = buildSpout(sd, context); builder.setSpout(sd.getId(), spout, sd.getParallelism()); @@ -365,7 +360,7 @@ public class FluxBuilder { * in the given spout class. Perform list to array conversion as necessary. */ private static IRichSpout buildSpout(SpoutDef def, ExecutionContext context) throws ClassNotFoundException, - IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { + IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException, NoSuchFieldException { return (IRichSpout)buildObject(def, context); } @@ -374,7 +369,7 @@ public class FluxBuilder { * Attempt to coerce the given constructor arguments to a matching bolt constructor as much as possible. */ private static void buildBolts(ExecutionContext context) throws ClassNotFoundException, IllegalAccessException, - InstantiationException, NoSuchMethodException, InvocationTargetException { + InstantiationException, NoSuchMethodException, InvocationTargetException, NoSuchFieldException { for (BoltDef def : context.getTopologyDef().getBolts()) { Class clazz = Class.forName(def.getClassName()); Object bolt = buildObject(def, context); http://git-wip-us.apache.org/repos/asf/storm/blob/be09c3c1/external/flux/flux-core/src/test/resources/configs/kafka_test.yaml ---------------------------------------------------------------------- diff --git a/external/flux/flux-core/src/test/resources/configs/kafka_test.yaml b/external/flux/flux-core/src/test/resources/configs/kafka_test.yaml index bc01d93..1fb59ca 100644 --- a/external/flux/flux-core/src/test/resources/configs/kafka_test.yaml +++ b/external/flux/flux-core/src/test/resources/configs/kafka_test.yaml @@ -61,7 +61,7 @@ components: # id - "myId" properties: - - name: "forceFromStart" + - name: "ignoreZkOffsets" value: true - name: "scheme" ref: "stringMultiScheme" http://git-wip-us.apache.org/repos/asf/storm/blob/be09c3c1/external/flux/flux-examples/src/main/resources/kafka_spout.yaml ---------------------------------------------------------------------- diff --git a/external/flux/flux-examples/src/main/resources/kafka_spout.yaml b/external/flux/flux-examples/src/main/resources/kafka_spout.yaml index db68b1b..7533ce4 100644 --- a/external/flux/flux-examples/src/main/resources/kafka_spout.yaml +++ b/external/flux/flux-examples/src/main/resources/kafka_spout.yaml @@ -64,7 +64,7 @@ components: # id - "myId" properties: - - name: "forceFromStart" + - name: "ignoreZkOffsets" value: true - name: "scheme" ref: "stringMultiScheme"
