Skip to content

Instantly share code, notes, and snippets.

@dbushenko
Created October 9, 2011 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbushenko/1274062 to your computer and use it in GitHub Desktop.
Save dbushenko/1274062 to your computer and use it in GitHub Desktop.
(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