Search in sources :

Example 6 with TopologyInfo

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);
}
Also used : GetInfoOptions(org.apache.storm.generated.GetInfoOptions) TopologyInfo(org.apache.storm.generated.TopologyInfo)

Example 7 with TopologyInfo

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");
}
Also used : GetInfoOptions(org.apache.storm.generated.GetInfoOptions) TopologyInfo(org.apache.storm.generated.TopologyInfo) RebalanceOptions(org.apache.storm.generated.RebalanceOptions)

Example 8 with TopologyInfo

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");
}
Also used : GetInfoOptions(org.apache.storm.generated.GetInfoOptions) KillOptions(org.apache.storm.generated.KillOptions) TopologyInfo(org.apache.storm.generated.TopologyInfo)

Example 9 with TopologyInfo

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;
}
Also used : GetInfoOptions(org.apache.storm.generated.GetInfoOptions) HashMap(java.util.HashMap) StormTopology(org.apache.storm.generated.StormTopology) Bolt(org.apache.storm.generated.Bolt) SpoutSpec(org.apache.storm.generated.SpoutSpec) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) NavigableMap(java.util.NavigableMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) TopologyInfo(org.apache.storm.generated.TopologyInfo)

Example 10 with TopologyInfo

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;
        }
    });
}
Also used : GetInfoOptions(org.apache.storm.generated.GetInfoOptions) ErrorInfo(org.apache.storm.generated.ErrorInfo) NimbusClient(org.apache.storm.utils.NimbusClient) NotAliveException(org.apache.storm.generated.NotAliveException) NotAliveException(org.apache.storm.generated.NotAliveException) Nimbus(org.apache.storm.generated.Nimbus) List(java.util.List) Map(java.util.Map) HashMap(java.util.HashMap) TopologyInfo(org.apache.storm.generated.TopologyInfo)

Aggregations

TopologyInfo (org.apache.storm.generated.TopologyInfo)23 ExecutorSummary (org.apache.storm.generated.ExecutorSummary)12 GetInfoOptions (org.apache.storm.generated.GetInfoOptions)9 Map (java.util.Map)8 HashMap (java.util.HashMap)7 List (java.util.List)7 ArrayList (java.util.ArrayList)6 TopologySummary (org.apache.storm.generated.TopologySummary)6 ExecutorStats (org.apache.storm.generated.ExecutorStats)5 SpoutStats (org.apache.storm.generated.SpoutStats)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 HashSet (java.util.HashSet)4 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)4 AuthorizationException (org.apache.storm.generated.AuthorizationException)4 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)4 StormTopology (org.apache.storm.generated.StormTopology)4 File (java.io.File)3 IOException (java.io.IOException)3 Collectors (java.util.stream.Collectors)3 Config (org.apache.storm.Config)3