Skip to content

Instantly share code, notes, and snippets.

{ :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"
}
}
(with-elephant-connection "edb1.mycompany.com" 3578 handler
(.getString handler "tweet-counts" "http://backtype.com"))
(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)
))
public static boolean foo() {
try {
return true;
} finally {
return false;
}
}
(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
(defn hello []
(println "hello"))
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"));
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));
}
}
import storm
class SplitSentenceBolt(storm.BasicBolt):
def process(self, tup):
words = tup.values[0].split(" ")
for word in words:
storm.emit([word])
builder.setBolt(4, new MyBolt(), 12)
.shuffleGrouping(1)
.shuffleGrouping(2)
.fieldsGrouping(3, new Fields("id1", "id2"));