use of org.apache.storm.drpc.LinearDRPCTopologyBuilder in project storm by apache.
the class ReachTopology method construct.
public static LinearDRPCTopologyBuilder construct() {
LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder("reach");
builder.addBolt(new GetTweeters(), 4);
builder.addBolt(new GetFollowers(), 12).shuffleGrouping();
builder.addBolt(new PartialUniquer(), 6).fieldsGrouping(new Fields("id", "follower"));
builder.addBolt(new CountAggregator(), 3).fieldsGrouping(new Fields("id"));
return builder;
}
use of org.apache.storm.drpc.LinearDRPCTopologyBuilder in project storm by apache.
the class ReachTopology method main.
public static void main(String[] args) throws Exception {
LinearDRPCTopologyBuilder builder = construct();
Config conf = new Config();
conf.setNumWorkers(6);
String topoName = "reach-drpc";
if (args.length > 0) {
topoName = args[0];
}
StormSubmitter.submitTopologyWithProgressBar(topoName, conf, builder.createRemoteTopology());
try (DRPCClient drpc = DRPCClient.getConfiguredClient(conf)) {
String[] urlsToTry = new String[] { "foo.com/blog/1", "engineering.twitter.com/blog/5", "notaurl.com" };
for (String url : urlsToTry) {
System.out.println("Reach of " + url + ": " + drpc.execute("reach", url));
}
}
}
use of org.apache.storm.drpc.LinearDRPCTopologyBuilder in project storm by apache.
the class BasicDRPCTopology method main.
public static void main(String[] args) throws Exception {
Config conf = new Config();
String topoName = "DRPCExample";
String function = "exclamation";
if (args != null) {
if (args.length > 0) {
topoName = args[0];
}
if (args.length > 1) {
function = args[1];
}
}
LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder(function);
builder.addBolt(new ExclaimBolt(), 3);
conf.setNumWorkers(3);
StormSubmitter.submitTopologyWithProgressBar(topoName, conf, builder.createRemoteTopology());
if (args != null && args.length > 2) {
try (DRPCClient drpc = DRPCClient.getConfiguredClient(conf)) {
for (int i = 2; i < args.length; i++) {
String word = args[i];
System.out.println("Result for \"" + word + "\": " + drpc.execute(function, word));
}
}
}
}
Aggregations