本文整理汇总了Java中org.apache.storm.starter.spout.TwitterSampleSpout类的典型用法代码示例。如果您正苦于以下问题:Java TwitterSampleSpout类的具体用法?Java TwitterSampleSpout怎么用?Java TwitterSampleSpout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TwitterSampleSpout类属于org.apache.storm.starter.spout包,在下文中一共展示了TwitterSampleSpout类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.storm.starter.spout.TwitterSampleSpout; //导入依赖的package包/类
public static void main(String[] args) {
String consumerKey = args[0];
String consumerSecret = args[1];
String accessToken = args[2];
String accessTokenSecret = args[3];
String[] arguments = args.clone();
String[] keyWords = Arrays.copyOfRange(arguments, 4, arguments.length);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("twitter", new TwitterSampleSpout(consumerKey, consumerSecret,
accessToken, accessTokenSecret, keyWords));
builder.setBolt("print", new PrinterBolt())
.shuffleGrouping("twitter");
Config conf = new Config();
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10000);
cluster.shutdown();
}
示例2: main
import org.apache.storm.starter.spout.TwitterSampleSpout; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
if (args.length < 4) {
System.err.println(
"Usage: PrintSampleStream <consumer-key> <consumer-secret> <access-token> <access-token-secret>");
return;
}
String consumerKey = args[0];
String consumerSecret = args[1];
String accessToken = args[2];
String accessTokenSecret = args[3];
// keywords start with the 5th parameter
String[] keyWords = Arrays.copyOfRange(args, 4, args.length);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("twitter", new TwitterSampleSpout(consumerKey, consumerSecret,
accessToken, accessTokenSecret, keyWords));
builder.setBolt("print", new PrinterBolt())
.shuffleGrouping("twitter");
Config conf = new Config();
final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
cluster.submitTopology("Print", conf, FlinkTopology.createTopology(builder));
Utils.sleep(10 * 1000);
cluster.shutdown();
}