Search in sources :

Example 1 with DRPCSpout

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;
}
Also used : SpoutNode(org.apache.storm.trident.planner.SpoutNode) ProcessorNode(org.apache.storm.trident.planner.ProcessorNode) Node(org.apache.storm.trident.planner.Node) PartitionNode(org.apache.storm.trident.planner.PartitionNode) SpoutNode(org.apache.storm.trident.planner.SpoutNode) DRPCSpout(org.apache.storm.drpc.DRPCSpout)

Example 2 with DRPCSpout

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"));
        }
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) Config(org.apache.storm.Config) LocalDRPC(org.apache.storm.LocalDRPC) ReturnResults(org.apache.storm.drpc.ReturnResults) DRPCSpout(org.apache.storm.drpc.DRPCSpout) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Aggregations

DRPCSpout (org.apache.storm.drpc.DRPCSpout)2 Config (org.apache.storm.Config)1 LocalCluster (org.apache.storm.LocalCluster)1 LocalTopology (org.apache.storm.LocalCluster.LocalTopology)1 LocalDRPC (org.apache.storm.LocalDRPC)1 ReturnResults (org.apache.storm.drpc.ReturnResults)1 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)1 Node (org.apache.storm.trident.planner.Node)1 PartitionNode (org.apache.storm.trident.planner.PartitionNode)1 ProcessorNode (org.apache.storm.trident.planner.ProcessorNode)1 SpoutNode (org.apache.storm.trident.planner.SpoutNode)1