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
{ :replication 1 | |
:hosts ["edb1.mycompany.com" "edb2.mycompany.com" "edb3.mycompany.com"] | |
:port 3578 | |
:domains {"tweet-counts" "/data/output/tweet-counts-edb" | |
"influenced-by" "/data/output/influenced-by-edb" | |
"influencer-of" "/data/output/influencer-of-edb" | |
} | |
} |
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
(with-elephant-connection "edb1.mycompany.com" 3578 handler | |
(.getString handler "tweet-counts" "http://backtype.com")) |
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
(defn process-pid | |
"Gets the pid of this JVM. Hacky because Java doesn't provide a real way to do this." | |
[] | |
(let [name (.getName (ManagementFactory/getRuntimeMXBean)) | |
split (.split name "@")] | |
(when-not (= 2 (count split)) | |
(throw (RuntimeException. (str "Got unexpected process name: " name)))) | |
(first split) | |
)) |
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
public static boolean foo() { | |
try { | |
return true; | |
} finally { | |
return false; | |
} | |
} |
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
(defmacro with-var-roots [bindings & body] | |
(let [settings (partition 2 bindings) | |
tmpvars (repeatedly (count settings) (partial gensym "old")) | |
vars (map first settings) | |
savevals (vec (mapcat (fn [t v] [t v]) tmpvars vars)) | |
setters (for [[v s] settings] `(set-var-root ~v ~s)) | |
restorers (map (fn [v s] `(set-var-root ~v ~s)) vars tmpvars) | |
] | |
`(let ~savevals | |
~@setters |
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
(defn hello [] | |
(println "hello")) |
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
TopologyBuilder builder = new TopologyBuilder(); | |
builder.setSpout(1, new KestrelSpout("kestrel.backtype.com", | |
22133, | |
"sentence_queue", | |
new StringScheme())); | |
builder.setBolt(2, new SplitSentence(), 10) | |
.shuffleGrouping(1); | |
builder.setBolt(3, new WordCount(), 20) | |
.fieldsGrouping(2, new Fields("word")); |
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
public class SplitSentence implements IBasicBolt { | |
public void prepare(Map conf, TopologyContext context) { | |
} | |
public void execute(Tuple tuple, BasicOutputCollector collector) { | |
String sentence = tuple.getString(0); | |
for(String word: sentence.split(" ")) { | |
collector.emit(new Values(word)); | |
} | |
} |
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
import storm | |
class SplitSentenceBolt(storm.BasicBolt): | |
def process(self, tup): | |
words = tup.values[0].split(" ") | |
for word in words: | |
storm.emit([word]) |
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
builder.setBolt(4, new MyBolt(), 12) | |
.shuffleGrouping(1) | |
.shuffleGrouping(2) | |
.fieldsGrouping(3, new Fields("id1", "id2")); |