当前位置: 首页>>代码示例>>Java>>正文


Java TwitterSampleSpout类代码示例

本文整理汇总了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();
}
 
开发者ID:ziyunhx,项目名称:storm-net-adapter,代码行数:27,代码来源:PrintSampleStream.java

示例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();
	}
 
开发者ID:axbaretto,项目名称:flink,代码行数:33,代码来源:PrintSampleStream.java


注:本文中的org.apache.storm.starter.spout.TwitterSampleSpout类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。