標籤:
轉載:
http://weyo.me/pages/techs/storm-topology-remote-submission/
作為一個懶癌晚期患者,雖然 Storm 只需要一條命令的任務提交方式已經夠簡單了,但還是一直想要有種更簡(tou)單(lan)的方式,比如要是在 Windows 下寫完代碼之後可以直接提交任務而不需要手動把 jar 包拷到伺服器上再提交那定是極好的了。Google了一下終於在牆外找到瞭解決方法: Submitting a topology to Remote Storm Cluster
Storm 叢集配置
- nimbus: "hd124"
- nimbus.port: 6627
提交 Topology
1 2 3 4 5 6 7 8 910111213141516171819 |
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()); |
說明
-
第8行會讀取 Storm 的本地設定檔,如果不指定的話,Utils.readStormConfig() 會讀取 Storm 依賴 jar 包的預設設定檔,如 "\maven\repository\org\apache\storm\storm-core\0.9.3\storm-core-0.9.3.jar\defaults.yaml",如果叢集配置與預設配置有較大不同,還需要修改對應配置資訊。
-
這段代碼需要在 Topology 已經完成打包之後運行,因為需要在程式中指定待提交的 jar 包。可以在 IDE 中安裝 Maven 外掛程式,Topology 開發完成之後直接打包,然後再切換到這段提交代碼中執行提交任務。
-
任務提交完成之後可以在 Storm UI 中查看提交結果。
Reference
- http://stackoverflow.com/questions/15781176/how-to-submit-a-topology-in-storm-production-cluster-using-ide
- 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/
通過 IDE 向 Storm 叢集遠程提交 topology