我跟随了以下帖子中的一个例子
How to submit a topology in storm production cluster using IDE
Below is my implementation
TopologyBuilder builder = new TopologyBuilder();
Map storm_conf = Utils.readStormConfig();
storm_conf.put("nimbus.host", "localhost");
Nimbus.Client client = NimbusClient.getConfiguredClient(storm_conf)
.getClient();
String inputJar = "/home/user/TestType-1.0.jar";
NimbusClient nimbus = null;
try {
nimbus = new NimbusClient(storm_conf, "localhost", 6627);
} catch (TTransportException e) {
System.out.println("unable to connect to client");
e.printStackTrace();
}
System.setProperty("storm.jar", "/home/user/TestType-1.0.jar");
String jsonConf = JSONValue.toJSONString(storm_conf);
try {
nimbus.getClient().submitTopology("SellerPageTypeTopology",
"/home/user/TestType-1.0.jar", jsonConf, builder.createTopology());
} catch (AlreadyAliveException e) {
e.printStackTrace();
} catch (InvalidTopologyException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
我能够成功部署拓扑。在风暴Ui我能看到拓扑活跃,但缺少喷口和螺栓细节。知道我错过了什么。谢谢你的帮助。
答案 0 :(得分:0)
您创建了一个空拓扑,然后提交了它。您的喷口和螺栓没有显示,因为您还没有将它们添加到TopologyBuilder中:
Config config = new Config();
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(MY_SPOUT_ID, mySpout);
builder.setBolt(MY_BOLT1_ID, myBolt1, 2).shuffleGrouping(MY_SPOUT_ID);
builder.setBolt(MY_BOLT2_ID, myBolt2).shuffleGrouping(MY_SPOUT_ID);