使用其他语言,如c++,python来编写storm计算任务的主要方法可以参见Storm wiki上的说明( https://github.com/nathanmarz/storm/wiki/Using-non-JVM-languages-with-Storm)。这篇wiki说的有点饶,据我理解其基本流程如下:
- 使用A语言实现多语言协议 https://github.com/nathanmarz/storm/wiki/Multilang-protocol; 其实是实现一些消息收发和解析的方法,可以参考官方已经实现的python版本和ruby版本;
- 使用A语言编写spout和bolt,实现计算逻辑;(如一些特定的语言可能得预先在服务器上装环境,或者能将运行时所需的lib都打包到可执行文件中)
- 使用A语言实现topology (参考storm.thrift中的topology设定); spout和bolt可以和topology写到一个文件里
- 使用storm shell(这个命令在shell command wiki里都没详细介绍)将资源文件和代码文件打包并提交,如对于python语言, storm shell resources/ python topology.py arg1 arg2
这条命令首先将 resources/下的文件打成jar包传到nimubs服务器上,然后再调用:
python topology.py arg1 arg2 {nimbus-host} {nimbus-port} {uploaded-jar-location} 命令启动topology。
因此你需要在topology实现topo的组装和提交,即组装一个StormTopology,并且使用这个thrift函数来提交topology到nimbus:
void submitTopology(1: string name, 2: string uploadedJarLocation, 3: string jsonConf, 4: StormTopology topology)
throws (1: AlreadyAliveException e, 2: InvalidTopologyException ite);