我目前在Windows机器上与Netbeans合作开发拓扑。在本地模式下部署时:LocalCluster cluster = new LocalCluster();
cluster.submitTopology("word-count", conf, builder.createTopology());
一切都很好,但当我尝试时:StormSubmitter.submitTopology("word", conf, builder.createTopology());
它显然试图以集群模式部署拓扑,但失败了,因为我的本地计算机上没有运行storm-nimbus。我确实在一个Digital Ocean液滴上部署了storm,但我目前(而且不方便)的解决方案是复制JAR文件并使用storm jar...
命令进行部署
我的问题是:有没有办法告诉Netbeans我的nimbus IP地址是什么,这样它就可以远程部署它?(节省我的时间)
提前谢谢!
检查此链接
现在我可以在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.
干杯
是的,你肯定可以告诉你的拓扑关于你的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());
以下是工作示例:向远程风暴集群提交拓扑
您可以使用conf
映射参数传递这些信息。。您可以根据自己的要求传递密钥、值对
有关可接受参数的列表,请查看此页。。