use of org.apache.storm.generated.TopologyInfo in project storm by apache.
the class UIHelpers method putTopologyDebugActionSpct.
/**
* 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);
}
use of org.apache.storm.generated.TopologyInfo in project storm by apache.
the class UIHelpers method putTopologyRebalance.
/**
* 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");
}
use of org.apache.storm.generated.TopologyInfo in project storm by apache.
the class UIHelpers method putTopologyKill.
/**
* 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");
}
use of org.apache.storm.generated.TopologyInfo in project storm by apache.
the class UIHelpers method getVisualizationData.
/**
* getVisualizationData.
* @param client client
* @param window window
* @param topoId topoId
* @param sys sys
* @return getVisualizationData
* @throws TException TException
*/
public static Map<String, Object> getVisualizationData(Nimbus.Iface client, String window, String topoId, boolean sys) throws TException {
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);
Map<String, List<ExecutorSummary>> spoutSummaries = getSpoutExecutors(topologyInfo.get_executors(), stormTopology);
Map<String, SpoutSpec> spoutSpecs = stormTopology.get_spouts();
Map<String, Bolt> boltSpecs = stormTopology.get_bolts();
Map<String, Object> result = new HashMap();
for (Map.Entry<String, SpoutSpec> spoutSpecMapEntry : spoutSpecs.entrySet()) {
String spoutComponentId = spoutSpecMapEntry.getKey();
if (spoutSummaries.containsKey(spoutComponentId)) {
Map<String, Object> spoutData = new HashMap();
spoutData.put(":type", "spout");
spoutData.put(":capacity", 0);
Map<String, Map> spoutStreamsStats = StatsUtil.spoutStreamsStats(spoutSummaries.get(spoutComponentId), sys);
spoutData.put(":latency", spoutStreamsStats.get("complete-latencies").get(window));
spoutData.put(":transferred", spoutStreamsStats.get("transferred").get(window));
spoutData.put(":stats", spoutSummaries.get(spoutComponentId).stream().map(UIHelpers::getStatMapFromExecutorSummary).collect(Collectors.toList()));
spoutData.put(":link", UIHelpers.urlFormat("/component.html?id=%s&topology_id=%s", spoutComponentId, topoId));
spoutData.put(":inputs", spoutSpecMapEntry.getValue().get_common().get_inputs().entrySet().stream().map(UIHelpers::getInputMap).collect(Collectors.toList()));
result.put(spoutComponentId, spoutData);
}
}
for (Map.Entry<String, Bolt> boltEntry : boltSpecs.entrySet()) {
String boltComponentId = boltEntry.getKey();
if (boltSummaries.containsKey(boltComponentId) && (sys || !Utils.isSystemId(boltComponentId))) {
Map<String, Object> boltMap = new HashMap();
boltMap.put(":type", "bolt");
boltMap.put(":capacity", StatsUtil.computeBoltCapacity(boltSummaries.get(boltComponentId)));
Map<String, Map> boltStreamsStats = StatsUtil.boltStreamsStats(boltSummaries.get(boltComponentId), sys);
boltMap.put(":latency", boltStreamsStats.get("process-latencies").get(window));
boltMap.put(":transferred", boltStreamsStats.get("transferred").get(window));
boltMap.put(":stats", boltSummaries.get(boltComponentId).stream().map(UIHelpers::getStatMapFromExecutorSummary).collect(Collectors.toList()));
boltMap.put(":link", UIHelpers.urlFormat("/component.html?id=%s&topology_id=%s", boltComponentId, topoId));
boltMap.put(":inputs", boltEntry.getValue().get_common().get_inputs().entrySet().stream().map(UIHelpers::getInputMap).collect(Collectors.toList()));
result.put(boltComponentId, boltMap);
}
}
return result;
}
use of org.apache.storm.generated.TopologyInfo in project storm by apache.
the class GetErrors method main.
/**
* Only get errors for a topology.
* @param args Used to accept the topology name.
* @throws Exception on errors.
*/
public static void main(String[] args) throws Exception {
if (args.length == 0) {
throw new IllegalArgumentException("Topology name must be provided.");
}
final String name = args[0];
NimbusClient.withConfiguredClient(new NimbusClient.WithNimbus() {
@Override
public void run(Nimbus.Iface client) throws Exception {
GetInfoOptions opts = new GetInfoOptions();
opts.set_num_err_choice(NumErrorsChoice.ONE);
Map<String, Object> outputMap = new HashMap<>();
try {
TopologyInfo topologyInfo = client.getTopologyInfoByNameWithOpts(name, opts);
String topologyName = topologyInfo.get_name();
Map<String, List<ErrorInfo>> topologyErrors = topologyInfo.get_errors();
outputMap.put("Topology Name", topologyName);
outputMap.put("Comp-Errors", getComponentErrors(topologyErrors));
} catch (NotAliveException notAliveException) {
outputMap.put("Failure", "No topologies running with name " + name);
}
System.out.println(JSONValue.toJSONString(outputMap));
}
private Map<String, String> getComponentErrors(Map<String, List<ErrorInfo>> topologyErrors) {
Map<String, String> componentErrorMap = new HashMap<>();
for (Map.Entry<String, List<ErrorInfo>> compNameToCompErrors : topologyErrors.entrySet()) {
String compName = compNameToCompErrors.getKey();
List<ErrorInfo> compErrors = compNameToCompErrors.getValue();
if (compErrors != null && !compErrors.isEmpty()) {
ErrorInfo latestError = compErrors.get(0);
componentErrorMap.put(compName, latestError.get_error());
}
}
return componentErrorMap;
}
});
}
Aggregations