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

qncylg1j  于 2021-06-21  发布在  Storm
关注(0)|答案(3)|浏览(406)

我目前在windows机器上与netbeans合作开发拓扑。在本地模式下部署时: LocalCluster cluster = new LocalCluster(); cluster.submitTopology("word-count", conf, builder.createTopology()); 一切正常,但当我尝试: StormSubmitter.submitTopology("word", conf, builder.createTopology()); 很明显,它试图以集群模式部署拓扑,但失败了,因为我的本地计算机上没有运行storm nimbus。我确实在一个数字海洋水滴上部署了storm,但我目前(不方便)的解决方案是复制jar文件并使用 storm jar... 要部署的命令。
我的问题是:有没有办法告诉netbeans我的nimbus ip地址是什么,这样它就可以远程部署它了(节省我的时间)
提前谢谢!

xv8emn3q

xv8emn3q1#

检查此链接
现在我可以在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. 干杯!

xzabzqsa

xzabzqsa2#

是的,当然你可以告诉你的拓扑结构关于你的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());

下面是一个工作示例:向远程storm群集提交拓扑

hmtdttj4

hmtdttj43#

您可以使用 conf Map参数。。您可以根据需要传递密钥、值对
有关可接受参数的列表,请查看此页。。

相关问题