如何开发(本地)和部署Storm拓扑(远程)?

时间:2014-09-04 20:51:58

标签: java netbeans cluster-computing apache-storm nimbus

我目前在Windows机器上与Netbeans合作开发拓扑。当我以本地模式部署时:
LocalCluster cluster = new LocalCluster(); cluster.submitTopology("word-count", conf, builder.createTopology()); 一切都很好,但是当我尝试: StormSubmitter.submitTopology("word", conf, builder.createTopology());
它显然试图以集群模式部署拓扑并失败,因为我没有在我的本地计算机上运行风暴云。我确实在一个Digital Ocean Droplet上部署了storm,但我当前(并不方便)的解决方案是复制JAR文件并使用storm jar...命令进行部署。
我的问题是:有没有办法告诉Netbeans我的nimbus IP地址是什么,所以可以远程部署它? (并节省时间)
提前谢谢!

3 个答案:

答案 0 :(得分:5)

<强> Check this link
现在我可以在Netbeans中开发拓扑,在本地测试它们,并最终将它们部署到集群上的Nimbus。这个解决方案对我很有用!!!
添加到配置文件:
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 :(得分: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

答案 2 :(得分:1)

您可以使用conf地图参数传递这些信息..您可以根据自己的要求传递密钥,值对

有关已接受参数的列表,请检查this页面..