2014-09-04 102 views
4

我目前與Windows機器上的Netbeans一起開發拓撲結構。當我部署在本地模式:
LocalCluster cluster = new LocalCluster(); cluster.submitTopology("word-count", conf, builder.createTopology());
一切工作得很好,但是當我嘗試:
StormSubmitter.submitTopology("word", conf, builder.createTopology());
它顯然試圖部署在集羣模式下的拓撲結構和失敗,因爲我沒有上運行的風暴靈氣我本地計算機。我確實在一個數字海洋液滴上部署了風暴,但是我目前(並不方便)的解決方案是複製JAR文件並使用storm jar...命令進行部署。
我的問題是:有沒有辦法告訴Netbeans我的nimbus IP地址是什麼,所以它可以遠程部署它? (並節省我的時間)
預先感謝您!如何開發(本地)並部署Storm拓撲(遠程)?

+0

我花了幾個小時,試圖找到一個解決方案。我知道我可以在本地運行風暴客戶端並使用storm.yaml來配置我的nimbus IP或者使用風暴罐'-c .....'在submitTopology時我們通過的配置中有沒有提到nimbus的方法? – 2014-09-04 21:02:51

回答

5

Check this link
現在我可以在Netbeans中開發拓撲,在本地測試它們,並最終將它們部署到集羣上的Nimbus。這個解決方案對我很好!
加入的conf文件:
conf.put(Config.NIMBUS_HOST, "123.456.789.101); //YOUR NIMBUS'S IP conf.put(Config.NIMBUS_THRIFT_PORT,6627); //int is expected here

此外,添加以下內容: System.setProperty("storm.jar", <path-to-jar>); //link to exact file location (w/ dependencies) 避免以下錯誤:
[main] INFO backtype.storm.StormSubmitter - Jar not uploaded to master yet. Submitting jar... Exception in thread "main" java.lang.RuntimeException: Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.
乾杯!

1

您可以通過使用conf地圖參數的信息..你可以通過一鍵,值對按您的要求

爲接受的參數列表來檢查this網頁..

2

是的,你肯定可以告訴你的拓撲你的nimbus IP。以下是在遠程集羣上提交拓撲的示例代碼。

Map storm_conf = Utils.readStormConfig(); 
storm_conf.put("nimbus.host", "<Nimbus Machine IP>"); 
Client client = NimbusClient.getConfiguredClient(storm_conf) 
           .getClient(); 
String inputJar = "C:\\workspace\\TestStormRunner\\target\\TestStormRunner-0.0.1-SNAPSHOT-jar-with-dependencies.jar"; 
NimbusClient nimbus = new NimbusClient(storm_conf, "<Nimbus Machine IP>", 
           <Nimbus Machine Port>); 
// upload topology jar to Cluster using StormSubmitter 
String uploadedJarLocation = StormSubmitter.submitJar(storm_conf, 
           inputJar); 

String jsonConf = JSONValue.toJSONString(storm_conf); 
nimbus.getClient().submitTopology("testtopology", 
         <uploadedJarLocation>, jsonConf, builder.createTopology()); 

這裏是工作示例:Submitting a topology to Remote Storm Cluster

+0

因此,在這種情況下,應該在TestStormRunner-0.0.1-SNAPSHOT-jar-with-dependencies.jar中定義沒有拓撲類的噴口和螺栓?因爲我們確實在給定的代碼片段 – Humoyun 2015-11-12 02:32:50

+0

中有topologyBuilder不,我們還需要在TestStormRunner中添加拓撲類,因爲從StormSubmitter我們不設置Spout和螺栓。那是在目標拓撲 – 2015-11-12 03:44:10

+0

啊現在我知道我的問題的原因,我在RemoteSubmitter類(它負責發送jar)和topology.jar中都定義了StormSubmitter.submitTopology(...)。據我所知,我應該在RemoteSubmitter和topology.jar中定義setBolt和setSpout,在RemoteSubmitter中定義StormSubmitter.submitTopology(...),而不是在topology.jar中,對吧? – Humoyun 2015-11-12 11:20:49