I am trying to implement Trident+DRPC. I have designed the topology in a way that it does not run indefinitely. I have two separate classes, one for spout implementation and the another one to implement DRPC and Trident. My spout class (a spout that extends IRichSpout) emits the id of the customer. i.e.
public class TriSpout implements IRichSpout{
//some logic here
spoutOutputCollector.emit(new Values(id))
}
Now I got the values from the output collector in another class which implements Trident with DRPC.
public class TriDrpc{
.....
TriSpout spout=new TriSpout1();
TridentTopology topology = new TridentTopology();
TridentState wordCounts =
topology.newStream("spout1",spout)
.parallelismHint(1)
.each(new Fields("id"), new Compute(), new Fields("value"))
.persistentAggregate(new MemoryMapState.Factory(),
new Count(), new Fields("count"))
and the drpc topology def is as follows
topology.newDRPCStream("Calc", drpc)
.each(new Fields("args"), new Split(), new Fields("word"))
.stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count"));
The DRPC request is as follows
public static void main(String[] args) throws Exception {
Config conf = new Config();
if (args.length == 0) {
LocalDRPC drpc = new LocalDRPC();
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("Calculator", conf, buildTopology(drpc));
System.out.println("DRPC RESULT: "
+ drpc.execute("Calc", "id"));
Thread.sleep(1000);
} else {
conf.setNumWorkers(8);
StormSubmitter.submitTopology(args[0], conf, buildTopology(null));
}
}
Now in the above code, in the DRPC request i.e.
System.out.println("DRPC RESULT: " + drpc.execute("Calc", "id"));
The "id"
should be same as the id emitted by the spout i.e I want to know which customer has active account using this id, so I need to send DRPC request for all the id's emitted by the spout. Now the DRPC is in main class, how can I pass the value emitted by the spout to the DRPC Request without specifying the id manually?
Can Someone help please
EDITED WITH NEW INFO