Skip to content

Instantly share code, notes, and snippets.

@dbushenko
Created October 10, 2011 17:31
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/1275875 to your computer and use it in GitHub Desktop.
Save dbushenko/1275875 to your computer and use it in GitHub Desktop.
(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