You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2014/08/25 20:21:50 UTC

[6/9] git commit: 1. fix test case passed on original code; 2. use count-by

1. fix test case passed on original code; 2. use count-by


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

Branch: refs/heads/master
Commit: d6a71142eec6f669f335312f418134960143fdbc
Parents: 3a20181
Author: Kang Xiao <kx...@gmail.com>
Authored: Thu Aug 14 00:34:06 2014 +0800
Committer: Kang Xiao <kx...@gmail.com>
Committed: Thu Aug 14 00:34:06 2014 +0800

----------------------------------------------------------------------
 .../src/clj/backtype/storm/scheduler/EvenScheduler.clj       | 2 +-
 storm-core/test/clj/backtype/storm/scheduler_test.clj        | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/d6a71142/storm-core/src/clj/backtype/storm/scheduler/EvenScheduler.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/scheduler/EvenScheduler.clj b/storm-core/src/clj/backtype/storm/scheduler/EvenScheduler.clj
index e377c13..25ba03b 100644
--- a/storm-core/src/clj/backtype/storm/scheduler/EvenScheduler.clj
+++ b/storm-core/src/clj/backtype/storm/scheduler/EvenScheduler.clj
@@ -22,7 +22,7 @@
     :implements [backtype.storm.scheduler.IScheduler]))
 
 (defn sort-slots [all-slots]
-  (let [split-up (sort #(> (count %1) (count %2)) (vals (group-by first all-slots)))]
+  (let [split-up (sort-by count > (vals (group-by first all-slots)))]
     (apply interleave-all split-up)
     ))
 

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/d6a71142/storm-core/test/clj/backtype/storm/scheduler_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/scheduler_test.clj b/storm-core/test/clj/backtype/storm/scheduler_test.clj
index a11e6b1..9744ac6 100644
--- a/storm-core/test/clj/backtype/storm/scheduler_test.clj
+++ b/storm-core/test/clj/backtype/storm/scheduler_test.clj
@@ -262,6 +262,10 @@
     ))
 
 (deftest test-sort-slots
+  ;; test supervisor1 and supervisor2 has the same free slot
+  (is (= '(["supervisor1" 6700] ["supervisor2" 6700]
+           ["supervisor1" 6701] ["supervisor2" 6701])
+         (sort-slots [["supervisor1" 6700] ["supervisor1" 6701] ["supervisor2" 6700] ["supervisor2" 6701]])))
   ;; test supervisor2 has more free slots
   (is (= '(["supervisor2" 6700] ["supervisor1" 6700]
            ["supervisor2" 6701] ["supervisor1" 6701]
@@ -278,9 +282,5 @@
                       ["supervisor2" 6700] ["supervisor2" 6701] ["supervisor2" 6702]
                       ["supervisor3" 6700] ["supervisor3" 6701] ["supervisor3" 6702] ["supervisor3" 6703]
                       ])))
-  ;; test supervisor1 and supervisor2 has the same free slot
-  (is (= '(["supervisor1" 6700] ["supervisor2" 6700]
-           ["supervisor1" 6701] ["supervisor2" 6701])
-         (sort-slots [["supervisor1" 6700] ["supervisor1" 6701] ["supervisor2" 6700] ["supervisor2" 6701]])))
     )