通過 IDE 向 Storm 叢集遠程提交 topology

來源:互聯網
上載者:User

標籤:

轉載:

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());
說明
  1. 第8行會讀取 Storm 的本地設定檔,如果不指定的話,Utils.readStormConfig() 會讀取 Storm 依賴 jar 包的預設設定檔,如 "\maven\repository\org\apache\storm\storm-core\0.9.3\storm-core-0.9.3.jar\defaults.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/

通過 IDE 向 Storm 叢集遠程提交 topology

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.