3、SpringBoot集成Storm WorldCount
RandomSentenceSpout
//数据源,在已知的英文句子中,随机发送一条句子出去。
public class RandomSentenceSpout extends BaseRichSpout {
//用来收集Spout输出的tuple
private SpoutOutputCollector collector;
private Random random;
//该方法调用一次,主要由storm框架传入SpoutOutputCollector
@Override
public void open(Map map, TopologyContext topologyContext, SpoutOutputCollector spoutOutputCollector) {
this.collector = collector;
random = new Random();
//连接kafka mysql ,打开本地文件
}
/**
* 上帝之手
* while(true)
* spout.nextTuple()
*/
@Override
public void nextTuple() {
String[] sentences = new String[]{
"the cow jumped over the moon","the dog jumped over the moon",
"the pig jumped over the gun","the fish jumped over the moon","the duck jumped over the moon",
"the man jumped over the sun","the girl jumped over the sun","the boy jumped over the sun"
};
String sentence = sentences[random.nextInt(sentences.length)];
collector.emit(new Values(sentence));
System.out.println("RandomSentenceSpout 发送数据:"+sentence);
}
//消息源可以发射多条消息流stream
@Override
public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
outputFieldsDeclarer.declare(new Fields("sentence"));
}
}
3、SpringBoot集成Storm WorldCount的更多相关文章
- 3、SpringBoot 集成Storm wordcount
WordCountBolt public class WordCountBolt extends BaseBasicBolt { private Map<String,Integer> c ...
- 【springBoot】springBoot集成redis的key,value序列化的相关问题
使用的是maven工程 springBoot集成redis默认使用的是注解,在官方文档中只需要2步; 1.在pom文件中引入即可 <dependency> <groupId>o ...
- SpringBoot集成security
本文就SpringBoot集成Security的使用步骤做出解释说明.
- springboot集成Actuator
Actuator监控端点,主要用来监控与管理. 原生端点主要分为三大类:应用配置类.度量指标类.操作控制类. 应用配置类:获取应用程序中加载的配置.环境变量.自动化配置报告等与SpringBoot应用 ...
- SpringBoot集成Shiro并用MongoDB做Session存储
之前项目鉴权一直使用的Shiro,那是在Spring MVC里面使用的比较多,而且都是用XML来配置,用Shiro来做权限控制相对比较简单而且成熟,而且我一直都把Shiro的session放在mong ...
- SpringBoot集成redis的key,value序列化的相关问题
使用的是maven工程 springBoot集成redis默认使用的是注解,在官方文档中只需要2步; 1.在pom文件中引入即可 <dependency> <groupId>o ...
- springboot集成mybatis(二)
上篇文章<springboot集成mybatis(一)>介绍了SpringBoot集成MyBatis注解版.本文还是使用上篇中的案例,咱们换个姿势来一遍^_^ 二.MyBatis配置版(X ...
- springboot集成mybatis(一)
MyBatis简介 MyBatis本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation迁移到了google code,并且改名为MyB ...
- springboot集成redis(mybatis、分布式session)
安装Redis请参考:<CentOS快速安装Redis> 一.springboot集成redis并实现DB与缓存同步 1.添加redis及数据库相关依赖(pom.xml) <depe ...
随机推荐
- dtNavMeshQuery::findLocalNeighbourhood m_tinyNodePool->getNode dtHashRef整数哈希 getPortalPoints dtOverlapPolyPoly2D
dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float* centerPos, const float radiu ...
- php发送邮箱重置密码链接,并在重置成功后使链接失效 (ThinkPHP5)
/** * 重置密码页,验证链接有效性,页面发送邮件调用sendResetPwdEmail()方法 */ public function resetPwd() { $param = input('') ...
- 扫毒>>观后感
观后感 中学时期,甚至在小学时期,那个很懵懂的年龄, 看了什么电影,去了哪里,都要写观后感. 那个时候觉得观后感很玄学,为啥看的电影都一样,去的地方都一样, 为啥人家的观后感貌似说的真的有那么点道理, ...
- 香茅油:不只是驱虫剂 new
如果您是芳香疗法的爱好者,香茅油对您来说可能并不陌生.香茅油还经常被添加到各种个人护理和清洁产品中,给人们带来多种益处. 什么是香茅油? 香茅精油是从香茅属 (Cymbopogon ) 植物家族中提取 ...
- [dev] Go的协程切换问题
子标题:runtime.Gosched() 是干嘛用的? 1. go程序都有一个环境变量,做线程数设置 GOMAXPROCS 2. 当协程数小于等于线程数的时候,程序行为上与多线程没有区别. 3. 当 ...
- Gitbook在Windows上安装
GitBook是基于Nodejs,使用Git/Github和Markdown制作电子书的命令行工具. 1.安装Nodejs 首先,安装Nodejs,官网地址:https://nodejs.org/en ...
- flask微服务框架的初步接触
测试2个关联的系统接口时,经常会遇到被测试系统或被测app的处理内部处理流程会依赖另一个系统的接口返回结果,这时,常用的做法就是写一个模拟测试桩,用作返回请求时的结果.java可以用servicele ...
- match 和 lastIndex 字符串检测差异
match .replace .search 这写不能识别特殊字符 indexOf .indexof 能识别特殊字符 str.lastIndexOf('a') > -1 // 通过lastInd ...
- mysql 查询 最大值,最小值,第二大,第三大 一共四个值
最大值:select max(num) from table 第二大值:select max(num) from tablewhere num not in(select max(num) from ...
- Cross-Origin跨域问题
为什么会跨域,要先了解浏览器的同源策略SOP(Same Orign Policy) https://segmentfault.com/a/1190000015597029 同源: 如果两个页面的协议 ...