通过 IDE 向 Storm 集群远程提交 topology

转载:

http://weyo.me/pages/techs/storm-topology-remote-submission/

http://www.javaworld.com/article/2078672/big-data/open-source-tools-open-source-java-projects-storm.html?page=2

作为一个懒癌晚期患者,虽然 Storm 只需要一条命令的任务提交方式已经够简单了,但还是一直想要有种更简(tou)单(lan)的方式,比如要是在 Windows 下写完代码之后可以直接提交任务而不需要手动把 jar 包拷到服务器上再提交那定是极好的了。谷歌了一下终于在墙外找到了解决方法: Submitting a topology to Remote Storm Cluster

Storm 集群配置

  • nimbus: "hd124"
  • nimbus.port: 6627

提交 Topology

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Config conf = new Config();
conf.setNumWorkers(2);
conf.setDebug(true);
// ...
// topology 其他配置信息等

// 读取本地 Storm 配置文件
Map stormConf = Utils.readStormConfig();
stormConf.put("nimbus.host", "hd124");
stormConf.putAll(conf);

Nimbus.Client client = NimbusClient.getConfiguredClient(stormConf).getClient();
String inputJar = "E:\workspace\storm-demo\target\storm-demo-0.0.5-SNAPSHOT-shade.jar";
NimbusClient nimbus = new NimbusClient(stormConf, "hd124", 6627);

// 使用 StormSubmitter 提交 jar 包
String uploadedJarLocation = StormSubmitter.submitJar(stormConf, inputJar);
String jsonConf = JSONValue.toJSONString(stormConf);
nimbus.getClient().submitTopology("remotetopology", uploadedJarLocation, jsonConf, builder.createTopology());

说明

  1. 第8行会读取 Storm 的本地配置文件,如果不指定的话,Utils.readStormConfig() 会读取 Storm 依赖 jar 包的默认配置文件,如 "maven epositoryorgapachestormstorm-core.9.3storm-core-0.9.3.jardefaults.yaml",如果集群配置与默认配置有较大不同,还需要修改对应配置信息。

  2. 这段代码需要在 Topology 已经完成打包之后运行,因为需要在程序中指定待提交的 jar 包。可以在 IDE 中安装 Maven 插件,Topology 开发完成之后直接打包,然后再切换到这段提交代码中执行提交任务。

  3. 任务提交完成之后可以在 Storm UI 中查看提交结果。


Reference

  1. http://stackoverflow.com/questions/15781176/how-to-submit-a-topology-in-storm-production-cluster-using-ide
  2. http://nishutayaltech.blogspot.in/2014/06/submitting-topology-to-remote-storm.html

再来一个:

http://xumingming.sinaapp.com/117/twitter-storm%E7%9A%84%E4%B8%80%E4%BA%9B%E5%85%B3%E9%94%AE%E6%A6%82%E5%BF%B5/

http://xumingming.sinaapp.com/189/twitter-storm-storm%E7%9A%84%E4%B8%80%E4%BA%9B%E5%B8%B8%E8%A7%81%E6%A8%A1%E5%BC%8F/

原文地址:https://www.cnblogs.com/diyunpeng/p/4620577.html