GetInfoOptions getInfoOptions = new GetInfoOptions(); getInfoOptions.set_num_err_choice(NumErrorsChoice.ONE); TopologyInfo topologyInfo = client.getTopologyInfoWithOpts(topoId, getInfoOptions); StormTopology stormTopology = client.getTopology(topoId); Map<String, List<ExecutorSummary>> boltSummaries = getBoltExecutors(topologyInfo.get_executors(), stormTopology, sys);
@Override public void run(Nimbus.Iface client) throws Exception { GetInfoOptions opts = new GetInfoOptions(); opts.set_num_err_choice(NumErrorsChoice.ONE); String topologyId = Utils.getTopologyId(name, client); TopologyInfo topologyInfo = null; if (topologyId != null) { topologyInfo = client.getTopologyInfoWithOpts(topologyId, opts); } Map<String, Object> outputMap = new HashMap<>(); if (topologyId == null || topologyInfo == null) { outputMap.put("Failure", "No topologies running with name " + name); } else { String topologyName = topologyInfo.get_name(); Map<String, List<ErrorInfo>> topologyErrors = topologyInfo.get_errors(); outputMap.put("Topology Name", topologyName); outputMap.put("Comp-Errors", getComponentErrors(topologyErrors)); } System.out.println(JSONValue.toJSONString(outputMap)); }
GetInfoOptions getInfoOpts = new GetInfoOptions(); getInfoOpts.set_num_err_choice(NumErrorsChoice.NONE); TopologyInfo info = client.getTopologyInfoWithOpts(id, getInfoOpts); for (ExecutorSummary es : info.get_executors()) { if (_component.equals(es.get_component_id())) {
private HashSet<String> getComponents(Nimbus.Iface client, String topology) throws Exception { HashSet<String> components = new HashSet<>(); ClusterSummary clusterSummary = client.getClusterInfo(); TopologySummary topologySummary = null; for (TopologySummary ts : clusterSummary.get_topologies()) { if (topology.equals(ts.get_name())) { topologySummary = ts; break; } } if (topologySummary == null) { throw new IllegalArgumentException("topology: " + topology + " not found"); } else { String id = topologySummary.get_id(); GetInfoOptions getInfoOpts = new GetInfoOptions(); getInfoOpts.set_num_err_choice(NumErrorsChoice.NONE); TopologyInfo info = client.getTopologyInfoWithOpts(id, getInfoOpts); for (ExecutorSummary es : info.get_executors()) { components.add(es.get_component_id()); } } return components; }
/** * putTopologyRebalance. * @param client client * @param id id * @param waitTime waitTime * @return putTopologyRebalance * @throws TException TException */ public static Map<String, Object> putTopologyRebalance( Nimbus.Iface client, String id, String waitTime) throws TException { GetInfoOptions getInfoOptions = new GetInfoOptions(); getInfoOptions.set_num_err_choice(NumErrorsChoice.NONE); TopologyInfo topologyInfo = client.getTopologyInfoWithOpts(id, getInfoOptions); RebalanceOptions rebalanceOptions = new RebalanceOptions(); rebalanceOptions.set_wait_secs(Integer.parseInt(waitTime)); client.rebalance(topologyInfo.get_name(), rebalanceOptions); return getTopologyOpResponse(id, "rebalance"); }
/** * putTopologyKill. * @param client client * @param id id * @param waitTime waitTime * @return putTopologyKill * @throws TException TException */ public static Map<String, Object> putTopologyKill(Nimbus.Iface client, String id, String waitTime) throws TException { GetInfoOptions getInfoOptions = new GetInfoOptions(); getInfoOptions.set_num_err_choice(NumErrorsChoice.NONE); TopologyInfo topologyInfo = client.getTopologyInfoWithOpts(id, getInfoOptions); KillOptions killOptions = new KillOptions(); killOptions.set_wait_secs(Integer.parseInt(waitTime)); client.killTopologyWithOpts(topologyInfo.get_name(), killOptions); return getTopologyOpResponse(id, "kill"); }
/** * putTopologyDebugActionSpct. * @param client client * @param id id * @param action action * @param spct spct * @param component component * @return putTopologyDebugActionSpct * @throws TException TException */ public static Map<String, Object> putTopologyDebugActionSpct( Nimbus.Iface client, String id, String action, String spct, String component) throws TException { GetInfoOptions getInfoOptions = new GetInfoOptions(); getInfoOptions.set_num_err_choice(NumErrorsChoice.NONE); TopologyInfo topologyInfo = client.getTopologyInfoWithOpts(id, getInfoOptions); client.debug(topologyInfo.get_name(), component, action.equals("enable"), Integer.parseInt(spct)); return getTopologyOpResponse(id, "debug/" + action); }
/** * putTopologyActivate. * @param client client * @param id id * @return putTopologyActivate * @throws TException TException */ public static Map<String, Object> putTopologyActivate(Nimbus.Iface client, String id) throws TException { GetInfoOptions getInfoOptions = new GetInfoOptions(); getInfoOptions.set_num_err_choice(NumErrorsChoice.NONE); TopologyInfo topologyInfo = client.getTopologyInfoWithOpts(id, getInfoOptions); client.activate(topologyInfo.get_name()); return getTopologyOpResponse(id, "activate"); }
/** * putTopologyDeactivate. * @param client client * @param id id * @return putTopologyDeactivate * @throws TException TException */ public static Map<String, Object> putTopologyDeactivate(Nimbus.Iface client, String id) throws TException { GetInfoOptions getInfoOptions = new GetInfoOptions(); getInfoOptions.set_num_err_choice(NumErrorsChoice.NONE); TopologyInfo topologyInfo = client.getTopologyInfoWithOpts(id, getInfoOptions); client.deactivate(topologyInfo.get_name()); return getTopologyOpResponse(id, "deactivate"); }