storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kabh...@apache.org
Subject [1/6] storm git commit: STORM-966 ConfigValidation.DoubleValidator doesn't really validate whether the type of the object is a double
Date Thu, 06 Aug 2015 02:14:36 GMT
Repository: storm
Updated Branches:
  refs/heads/master ac14de3ea -> 544e55cb8


STORM-966 ConfigValidation.DoubleValidator doesn't really validate whether the type of the
object is a double


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

Branch: refs/heads/master
Commit: db503a4576499f4fd89ea9566b14fdc7ade0b5a4
Parents: c3a9385
Author: Jerry <jerry@ubuntu.(none)>
Authored: Wed Jul 29 21:00:49 2015 -0700
Committer: Jerry <jerry@ubuntu.(none)>
Committed: Wed Jul 29 21:00:49 2015 -0700

----------------------------------------------------------------------
 storm-core/src/jvm/backtype/storm/Config.java   |  2 +-
 .../jvm/backtype/storm/ConfigValidation.java    | 20 --------------------
 .../test/clj/backtype/storm/config_test.clj     |  9 ---------
 3 files changed, 1 insertion(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/db503a45/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 58e2a4a..0dd489e 100644
--- a/storm-core/src/jvm/backtype/storm/Config.java
+++ b/storm-core/src/jvm/backtype/storm/Config.java
@@ -1194,7 +1194,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 = Number.class;
 
     /**
      * The time period that builtin metrics data in bucketed into.

http://git-wip-us.apache.org/repos/asf/storm/blob/db503a45/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 ce0f3de..a6e3057 100644
--- a/storm-core/src/jvm/backtype/storm/ConfigValidation.java
+++ b/storm-core/src/jvm/backtype/storm/ConfigValidation.java
@@ -254,26 +254,6 @@ public class ConfigValidation {
     };
 
     /**
-     * Validates a Double.
-     */
-    public static Object DoubleValidator = 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;
-            }
-
-            throw new IllegalArgumentException("Field " + name + " must be an Double.");
-        }
-    };
-
-    /**
      * Validates a power of 2.
      */
     public static Object PowerOf2Validator = new FieldValidator() {

http://git-wip-us.apache.org/repos/asf/storm/blob/db503a45/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 9750185..ac80b14 100644
--- a/storm-core/test/clj/backtype/storm/config_test.clj
+++ b/storm-core/test/clj/backtype/storm/config_test.clj
@@ -99,15 +99,6 @@
     (is (thrown-cause? java.lang.IllegalArgumentException
           (.validateField validator "test" [-100 (inc Integer/MAX_VALUE)])))))
 
-(deftest test-double-validator
-  (let [validator ConfigValidation/DoubleValidator]
-    (.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)))
-
 (deftest test-topology-workers-is-integer
   (let [validator (CONFIG-SCHEMA-MAP TOPOLOGY-WORKERS)]
     (.validateField validator "test" 42)


Mime
View raw message