use of org.apache.storm.drpc.DRPCSpout in project storm by apache.
the class TridentTopology method genSpoutIds.
private static Map<Node, String> genSpoutIds(Collection<SpoutNode> spoutNodes) {
Map<Node, String> ret = new HashMap<>();
int ctr = 0;
for (SpoutNode n : spoutNodes) {
if (n.type == SpoutNode.SpoutType.BATCH) {
// if Batch spout then id contains txId
ret.put(n, "spout-" + n.txId);
} else if (n.type == SpoutNode.SpoutType.DRPC) {
//if DRPC spout then id contains function
ret.put(n, "spout-" + ((DRPCSpout) n.spout).get_function() + ctr);
ctr++;
} else {
ret.put(n, "spout" + ctr);
ctr++;
}
}
return ret;
}
use of org.apache.storm.drpc.DRPCSpout in project storm by apache.
the class ManualDRPC method main.
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
try (LocalDRPC drpc = new LocalDRPC();
LocalCluster cluster = new LocalCluster()) {
DRPCSpout spout = new DRPCSpout("exclamation", drpc);
builder.setSpout("drpc", spout);
builder.setBolt("exclaim", new ExclamationBolt(), 3).shuffleGrouping("drpc");
builder.setBolt("return", new ReturnResults(), 3).shuffleGrouping("exclaim");
Config conf = new Config();
try (LocalTopology topo = cluster.submitTopology("exclaim", conf, builder.createTopology())) {
System.out.println(drpc.execute("exclamation", "aaa"));
System.out.println(drpc.execute("exclamation", "bbb"));
}
}
}
Aggregations