Search in sources :

Example 1 with ReturnResults

use of org.apache.storm.drpc.ReturnResults 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

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 DRPCSpout (org.apache.storm.drpc.DRPCSpout)1 ReturnResults (org.apache.storm.drpc.ReturnResults)1 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)1