Created
October 9, 2011 19:39
-
-
Save dbushenko/1274062 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
(ns storm-test.core | |
(:import [backtype.storm StormSubmitter LocalCluster]) | |
(:use [backtype.storm clojure config]) | |
(:gen-class)) | |
(defspout dummy-spout ["data"] | |
[conf context collector] | |
(let [data [2 4 8 16 32 64 128 256 512 1024 4096]] | |
(dorun (map #(do | |
(println (str "Spout: " %)) | |
(emit-spout! collector [%])) | |
data)))) | |
(defbolt dummy-bolt [""] | |
[tuple collector] | |
(println (str "Bolt: " (- (first tuple)))) | |
(emit-bolt! collector [(- (first tuple))] :anchor tuple)) | |
(defn make-topology [] | |
(topology | |
{1 (spout-spec dummy-spout)} | |
{2 (bolt-spec {1 :shuffle} dummy-bolt :p 4)})) | |
(defn run-local! [] | |
(let [cluster (LocalCluster.)] | |
(.submitTopology cluster "dummy-topology" {TOPOLOGY-DEBUG true} (make-topology)) | |
(Thread/sleep 10000) | |
(.shutdown cluster) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment