storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptgo...@apache.org
Subject [1/5] git commit: STORM-186 fix float secs to millis long convertion
Date Wed, 05 Mar 2014 19:54:08 GMT
Repository: incubator-storm
Updated Branches:
  refs/heads/master d9d637eab -> 3aa6d7b95


STORM-186 fix float secs to millis long convertion


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

Branch: refs/heads/master
Commit: 15c489018c0cc7a32cc8e5c157232da4d1e26f2d
Parents: 254ec13
Author: Kang Xiao <kxiao.tiger@gmail.com>
Authored: Wed Feb 19 00:22:01 2014 +0800
Committer: Kang Xiao <kxiao.tiger@gmail.com>
Committed: Wed Feb 19 00:22:01 2014 +0800

----------------------------------------------------------------------
 storm-core/src/clj/backtype/storm/timer.clj       |  2 +-
 storm-core/src/clj/backtype/storm/util.clj        |  3 +++
 storm-core/test/clj/backtype/storm/utils_test.clj | 11 +++++++++++
 3 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/15c48901/storm-core/src/clj/backtype/storm/timer.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/timer.clj b/storm-core/src/clj/backtype/storm/timer.clj
index f9774b6..78b1f1c 100644
--- a/storm-core/src/clj/backtype/storm/timer.clj
+++ b/storm-core/src/clj/backtype/storm/timer.clj
@@ -82,7 +82,7 @@
   (let [id (uuid)
         ^PriorityQueue queue (:queue timer)]
     (locking (:lock timer)
-      (.add queue [(+ (current-time-millis) (* 1000 (long delay-secs))) afn id])
+      (.add queue [(+ (current-time-millis) (secs-to-millis-long delay-secs)) afn id])
       )))
 
 (defn schedule-recurring [timer delay-secs recur-secs afn]

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/15c48901/storm-core/src/clj/backtype/storm/util.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/util.clj b/storm-core/src/clj/backtype/storm/util.clj
index 2ab30c7..a8f238a 100644
--- a/storm-core/src/clj/backtype/storm/util.clj
+++ b/storm-core/src/clj/backtype/storm/util.clj
@@ -220,6 +220,9 @@
 (defn current-time-millis []
   (Time/currentTimeMillis))
 
+(defn secs-to-millis-long [secs]
+  (long (* 1000 secs)))
+
 (defn clojurify-structure [s]
   (prewalk (fn [x]
               (cond (instance? Map x) (into {} x)

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/15c48901/storm-core/test/clj/backtype/storm/utils_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/utils_test.clj b/storm-core/test/clj/backtype/storm/utils_test.clj
index 99bf7d1..b24db62 100644
--- a/storm-core/test/clj/backtype/storm/utils_test.clj
+++ b/storm-core/test/clj/backtype/storm/utils_test.clj
@@ -62,3 +62,14 @@
     ))
   )
 )
+
+(deftest test-secs-to-millis-long
+  (is (= 0 (secs-to-millis-long 0)))
+  (is (= 2 (secs-to-millis-long 0.002)))
+  (is (= 500 (secs-to-millis-long 0.5)))
+  (is (= 1000 (secs-to-millis-long 1)))
+  (is (= 1080 (secs-to-millis-long 1.08)))
+  (is (= 10000 (secs-to-millis-long 10)))
+  (is (= 10100 (secs-to-millis-long 10.1)))
+)
+


Mime
View raw message