本文整理汇总了Java中backtype.storm.drpc.DRPCSpout类的典型用法代码示例。如果您正苦于以下问题:Java DRPCSpout类的具体用法?Java DRPCSpout怎么用?Java DRPCSpout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DRPCSpout类属于backtype.storm.drpc包,在下文中一共展示了DRPCSpout类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import backtype.storm.drpc.DRPCSpout; //导入依赖的package包/类
public static void main(String[] args) {
TopologyBuilder builder = new TopologyBuilder();
LocalDRPC drpc = new LocalDRPC();
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");
LocalCluster cluster = new LocalCluster();
Config conf = new Config();
cluster.submitTopology("exclaim", conf, builder.createTopology());
System.out.println(drpc.execute("exclamation", "aaa"));
System.out.println(drpc.execute("exclamation", "bbb"));
}
示例2: main
import backtype.storm.drpc.DRPCSpout; //导入依赖的package包/类
public static void main(String[] args) {
TopologyBuilder builder = new TopologyBuilder();
LocalDRPC drpc = new LocalDRPC();
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");
LocalCluster cluster = new LocalCluster();
Config conf = new Config();
cluster.submitTopology("exclaim", conf, builder.createTopology());
System.out.println(drpc.execute("exclamation", "aaa"));
System.out.println(drpc.execute("exclamation", "bbb"));
}
示例3: testDrpc
import backtype.storm.drpc.DRPCSpout; //导入依赖的package包/类
public static void testDrpc() {
TopologyBuilder builder = new TopologyBuilder();
LocalDRPC drpc = new LocalDRPC();
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");
LocalCluster cluster = new LocalCluster();
Config conf = new Config();
cluster.submitTopology("exclaim", conf, builder.createTopology());
JStormUtils.sleepMs(30 * 1000);
try {
System.out.println(drpc.execute("exclamation", "aaa"));
System.out.println(drpc.execute("exclamation", "bbb"));
} catch (Exception e) {
Assert.fail("Failed to test drpc");
}
drpc.shutdown();
cluster.shutdown();
}
示例4: genSpoutIds
import backtype.storm.drpc.DRPCSpout; //导入依赖的package包/类
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;
}
示例5: newDRPCStream
import backtype.storm.drpc.DRPCSpout; //导入依赖的package包/类
private Stream newDRPCStream(DRPCSpout spout) {
// : consider adding a shuffle grouping after the spout to avoid so much routing of the args/return-info all over the place
// (at least until its possible to just pack bolt logic into the spout itself)
Node n = new SpoutNode(getUniqueStreamId(), TridentUtils.getSingleOutputStreamFields(spout), null, spout, SpoutNode.SpoutType.DRPC);
Stream nextStream = addNode(n);
// later on, this will be joined back with return-info and all the results
return nextStream.project(new Fields("args"));
}
示例6: newDRPCStream
import backtype.storm.drpc.DRPCSpout; //导入依赖的package包/类
private Stream newDRPCStream(DRPCSpout spout) {
// TODO: consider adding a shuffle grouping after the spout to avoid so much routing of the args/return-info all over the place
// (at least until its possible to just pack bolt logic into the spout itself)
Node n = new SpoutNode(getUniqueStreamId(), TridentUtils.getSingleOutputStreamFields(spout), null, spout, SpoutNode.SpoutType.DRPC);
Stream nextStream = addNode(n);
// later on, this will be joined back with return-info and all the results
return nextStream.project(new Fields("args"));
}
示例7: initSpout
import backtype.storm.drpc.DRPCSpout; //导入依赖的package包/类
@Override
protected IRichSpout initSpout() {
// TODO Auto-generated method stub
if(this.localDRPC != null) {
//本地部署
return new DRPCSpout(this.getTopologyName(), this.localDRPC);
} else {
//远程部署
return new DRPCSpout(this.getTopologyName());
}
}