use of backtype.storm.generated.TopologyInfo in project jstorm by alibaba.
the class gray_upgrade method upgradeTopology.
private static void upgradeTopology(String topologyName, String component, List<String> workers, int workerNum) throws Exception {
Map conf = Utils.readStormConfig();
NimbusClient client = NimbusClient.getConfiguredClient(conf);
try {
String topologyId = client.getClient().getTopologyId(topologyName);
Map stormConf = (Map) Utils.from_json(client.getClient().getTopologyConf(topologyId));
// check if TM is a separate worker
TopologyInfo topologyInfo = client.getClient().getTopologyInfo(topologyId);
for (TaskSummary taskSummary : topologyInfo.get_tasks()) {
if (!taskSummary.get_status().equalsIgnoreCase("active")) {
CommandLineUtil.error("Some of the tasks are not in ACTIVE state, cannot perform the upgrade!");
return;
}
}
if (!ConfigExtension.isTmSingleWorker(stormConf, topologyInfo.get_topology().get_numWorkers())) {
CommandLineUtil.error("Gray upgrade requires that topology master to be a single worker, " + "cannot perform the upgrade!");
return;
}
client.getClient().grayUpgrade(topologyName, component, workers, workerNum);
CommandLineUtil.success("Successfully submit command gray_upgrade " + topologyName);
} catch (Exception ex) {
CommandLineUtil.error("Failed to perform gray_upgrade: " + ex.getMessage());
ex.printStackTrace();
} finally {
if (client != null) {
client.close();
}
}
}
Aggregations