Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to develop (locally) and deploy Storm Topology (remotely)?

I currently work with Netbeans on Windows machine to develop topologies. When I deploy in local mode:
LocalCluster cluster = new LocalCluster(); cluster.submitTopology("word-count", conf, builder.createTopology());
everything works just fine, but when I try to :
StormSubmitter.submitTopology("word", conf, builder.createTopology());
it obviously tries to deploy the topology in a cluster mode and fails since I dont have storm nimbus running on my local computer. I do have storm deployed on one Digital Ocean droplet, but my current (and not convenient) solution is to copy the JAR file and use the storm jar... command to deploy.
My question is: is there a way to tell Netbeans what is my nimbus IP address, so it can deploy it remotely? (and save me the time)
Thank you in advance!

like image 455
Zack S Avatar asked Feb 13 '23 02:02

Zack S


2 Answers

Check this link
Now I can develope topologies in Netbeans, test them locally, and eventually deploy them to my Nimbus on the cluster. This solution works great for me!!!
Add to conf file:
conf.put(Config.NIMBUS_HOST, "123.456.789.101); //YOUR NIMBUS'S IP conf.put(Config.NIMBUS_THRIFT_PORT,6627); //int is expected here

Also, add the following : System.setProperty("storm.jar", <path-to-jar>); //link to exact file location (w/ dependencies) to avoid the following error:
[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.
Cheers!

like image 183
Zack S Avatar answered Feb 15 '23 11:02

Zack S


Yeah, definitely you can tell your topology about your nimbus IP. Following is the example code to submit topology on remote cluster.

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());

Here is the working example : Submitting a topology to Remote Storm Cluster

like image 42
Nishu Tayal Avatar answered Feb 15 '23 11:02

Nishu Tayal