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/08/06 04:17:37 UTC
[1/2] storm git commit: STORM-966 ConfigValidation.DoubleValidator
doesn't really validate whether the type of the object is a double
Repository: storm
Updated Branches:
refs/heads/0.10.x-branch ac0ae4aad -> 94b4458bc
STORM-966 ConfigValidation.DoubleValidator doesn't really validate whether the type of the object is a double
* replacement of the double validator
* added united tests and changed exception message
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/f84bd01c
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/f84bd01c
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/f84bd01c
Branch: refs/heads/0.10.x-branch
Commit: f84bd01cd4507aec89e19217082df707766a595d
Parents: ac0ae4a
Author: Jerry <jerry@ubuntu.(none)>
Authored: Wed Jul 29 21:00:49 2015 -0700
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Aug 6 11:16:45 2015 +0900
----------------------------------------------------------------------
storm-core/src/jvm/backtype/storm/Config.java | 2 +-
.../src/jvm/backtype/storm/ConfigValidation.java | 15 +++++++--------
.../test/clj/backtype/storm/config_test.clj | 19 ++++++++++++-------
3 files changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/f84bd01c/storm-core/src/jvm/backtype/storm/Config.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/Config.java b/storm-core/src/jvm/backtype/storm/Config.java
index 808572f..1549e1e 100644
--- a/storm-core/src/jvm/backtype/storm/Config.java
+++ b/storm-core/src/jvm/backtype/storm/Config.java
@@ -1134,7 +1134,7 @@ public class Config extends HashMap<String, Object> {
* The percentage of tuples to sample to produce stats for a task.
*/
public static final String TOPOLOGY_STATS_SAMPLE_RATE="topology.stats.sample.rate";
- public static final Object TOPOLOGY_STATS_SAMPLE_RATE_SCHEMA = ConfigValidation.DoubleValidator;
+ public static final Object TOPOLOGY_STATS_SAMPLE_RATE_SCHEMA =ConfigValidation.PositiveNumberValidator;
/**
* The time period that builtin metrics data in bucketed into.
http://git-wip-us.apache.org/repos/asf/storm/blob/f84bd01c/storm-core/src/jvm/backtype/storm/ConfigValidation.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/ConfigValidation.java b/storm-core/src/jvm/backtype/storm/ConfigValidation.java
index 24991d7..c8d0143 100644
--- a/storm-core/src/jvm/backtype/storm/ConfigValidation.java
+++ b/storm-core/src/jvm/backtype/storm/ConfigValidation.java
@@ -236,22 +236,21 @@ public class ConfigValidation {
};
/**
- * Validates a Double.
+ * Validates a Positive Number
*/
- public static Object DoubleValidator = new FieldValidator() {
+ public static Object PositiveNumberValidator = new FieldValidator() {
@Override
public void validateField(String name, Object o) throws IllegalArgumentException {
if (o == null) {
// A null value is acceptable.
return;
}
-
- // we can provide a lenient way to convert int/long to double with losing some precision
- if (o instanceof Number) {
- return;
+ if(o instanceof Number) {
+ if(((Number)o).doubleValue() > 0.0) {
+ return;
+ }
}
-
- throw new IllegalArgumentException("Field " + name + " must be an Double.");
+ throw new IllegalArgumentException("Field " + name + " must be a Positive Number");
}
};
http://git-wip-us.apache.org/repos/asf/storm/blob/f84bd01c/storm-core/test/clj/backtype/storm/config_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/config_test.clj b/storm-core/test/clj/backtype/storm/config_test.clj
index a7498ba..d5f0240 100644
--- a/storm-core/test/clj/backtype/storm/config_test.clj
+++ b/storm-core/test/clj/backtype/storm/config_test.clj
@@ -85,14 +85,19 @@
(is (thrown-cause? java.lang.IllegalArgumentException
(.validateField validator "test" [-100 (inc Integer/MAX_VALUE)])))))
-(deftest test-double-validator
- (let [validator ConfigValidation/DoubleValidator]
+(deftest test-positive-number-validator
+ (let [validator ConfigValidation/PositiveNumberValidator]
(.validateField validator "test" nil)
- (.validateField validator "test" 10)
- ;; we can provide lenient way to convert int/long to double with losing precision
- (.validateField validator "test" Integer/MAX_VALUE)
- (.validateField validator "test" (inc Integer/MAX_VALUE))
- (.validateField validator "test" Double/MAX_VALUE)))
+ (.validateField validator "test" 1.0)
+ (.validateField validator "test" 1)
+ (is (thrown-cause? java.lang.IllegalArgumentException
+ (.validateField validator "test" -1.0)))
+ (is (thrown-cause? java.lang.IllegalArgumentException
+ (.validateField validator "test" -1)))
+ (is (thrown-cause? java.lang.IllegalArgumentException
+ (.validateField validator "test" 0)))
+ (is (thrown-cause? java.lang.IllegalArgumentException
+ (.validateField validator "test" 0.0)))))
(deftest test-topology-workers-is-integer
(let [validator (CONFIG-SCHEMA-MAP TOPOLOGY-WORKERS)]
[2/2] storm git commit: add STORM-966 to CHANGELOG.md
Posted by ka...@apache.org.
add STORM-966 to CHANGELOG.md
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/94b4458b
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/94b4458b
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/94b4458b
Branch: refs/heads/0.10.x-branch
Commit: 94b4458bc683db2ef431f824a7db628be4fc983b
Parents: f84bd01
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Thu Aug 6 11:17:24 2015 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Aug 6 11:17:24 2015 +0900
----------------------------------------------------------------------
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/94b4458b/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index edd66ea..9a92f99 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@
* STORM-793: Made change to logviewer.clj in order to remove the invalid http 500 response
* STORM-139: hashCode does not work for byte[]
* STORM-860: UI: while topology is transitioned to killed, "Activate" button is enabled but not functioning
+ * STORM-966: ConfigValidation.DoubleValidator doesn't really validate whether the type of the object is a double
## 0.10.0-beta1
* STORM-873: Flux does not handle diamond topologies