Created
October 10, 2011 17:31
-
-
Save dbushenko/1275875 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def *data* [2 4 8 16 32 64 128 256 512 1024 4096 2 4 8 16 32 64 128 256 512 1024 4096]) | |
(defspout number-spout ["number"] | |
[conf context collector] | |
(spout | |
(nextTuple [] | |
(Thread/sleep 100) | |
(emit-spout! collector [(next *data*)])) | |
(ack [id]))) | |
(defbolt neg-bolt ["neg"] [tuple collector] | |
(let [result (- (.getInteger tuple 0) )] | |
(emit-bolt! collector [result] :anchor tuple :p 4) | |
(ack! collector tuple))) | |
(defn mk-topology [] | |
(topology | |
{1 (spout-spec number-spout)} | |
{2 (bolt-spec {1 :shuffle} neg-bolt)})) | |
(defn run-local! [] | |
(let [cluster (LocalCluster.)] | |
(.submitTopology cluster "test" {TOPOLOGY-DEBUG true} (mk-topology)) | |
(Thread/sleep 1000) | |
(.shutdown cluster))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment