public class Part04_BasicStateAndDRPC {
private static final Logger log = LoggerFactory.getLogger(Part04_BasicStateAndDRPC.class);
public static void main(String[] args) throws Exception{
FakeTweetGenerator fakeTweets = new FakeTweetGenerator();
FeederBatchSpout testSpout = new FeederBatchSpout(ImmutableList.of("id", "text", "actor", "location", "date"));
Config conf = new Config();
LocalCluster cluster = new LocalCluster();
LocalDRPC drpc = new LocalDRPC();
cluster.submitTopology("state_drpc", conf, basicStateAndDRPC(drpc, testSpout));
// You can use FeederBatchSpout to feed known values to the topology. Very useful for tests.
testSpout.feed(fakeTweets.getNextTweetTuples("ted"));
testSpout.feed(fakeTweets.getNextTweetTuples("ted"));
testSpout.feed(fakeTweets.getNextTweetTuples("mary"));
testSpout.feed(fakeTweets.getNextTweetTuples("jason"));
// This is how you make DRPC calls. First argument must match the function name
// System.out.println(drpc.execute("ping", "ping pang pong"));
// System.out.println(drpc.execute("count", "america america ace ace ace item"));
System.out.println(drpc.execute("count_per_actor", "ted"));