Search in sources :

Example 1 with ComponentPageInfo

use of org.apache.storm.generated.ComponentPageInfo in project storm by apache.

the class TopoWrap method getLogUrls.

public List<ExecutorURL> getLogUrls(final String componentId) throws TException, MalformedURLException {
    ComponentPageInfo componentPageInfo = cluster.getNimbusClient().getComponentPageInfo(id, componentId, null, false);
    Map<String, ComponentAggregateStats> windowToStats = componentPageInfo.get_window_to_stats();
    ComponentAggregateStats allTimeStats = windowToStats.get(":all-time");
    //Long emitted = (Long) allTimeStats.getFieldValue(ComponentAggregateStats._Fields.findByName("emitted"));
    List<ExecutorAggregateStats> execStats = componentPageInfo.get_exec_stats();
    Set<ExecutorURL> urls = new HashSet<>();
    for (ExecutorAggregateStats execStat : execStats) {
        ExecutorSummary execSummary = execStat.get_exec_summary();
        String host = execSummary.get_host();
        int executorPort = execSummary.get_port();
        //http://supervisor2:8000/download/DemoTest-26-1462229009%2F6703%2Fworker.log
        //http://supervisor2:8000/log?file=SlidingWindowCountTest-9-1462388349%2F6703%2Fworker.log
        int logViewerPort = 8000;
        ExecutorURL executorURL = new ExecutorURL(componentId, host, logViewerPort, executorPort, id);
        urls.add(executorURL);
    }
    return new ArrayList<>(urls);
}
Also used : ComponentPageInfo(org.apache.storm.generated.ComponentPageInfo) ExecutorAggregateStats(org.apache.storm.generated.ExecutorAggregateStats) ArrayList(java.util.ArrayList) ComponentAggregateStats(org.apache.storm.generated.ComponentAggregateStats) HashSet(java.util.HashSet) ExecutorSummary(org.apache.storm.generated.ExecutorSummary)

Example 2 with ComponentPageInfo

use of org.apache.storm.generated.ComponentPageInfo in project storm by apache.

the class Nimbus method getComponentPageInfo.

@Override
public ComponentPageInfo getComponentPageInfo(String topoId, String componentId, String window, boolean includeSys) throws NotAliveException, AuthorizationException, TException {
    try {
        getComponentPageInfoCalls.mark();
        CommonTopoInfo info = getCommonTopoInfo(topoId, "getComponentPageInfo");
        if (info.base == null) {
            throw new NotAliveException(topoId);
        }
        StormTopology topology = info.topology;
        Map<String, Object> topoConf = info.topoConf;
        Assignment assignment = info.assignment;
        Map<List<Long>, List<Object>> exec2NodePort = new HashMap<>();
        Map<String, String> nodeToHost;
        Map<List<Long>, List<Object>> exec2HostPort = new HashMap<>();
        if (assignment != null) {
            Map<List<Long>, NodeInfo> execToNodeInfo = assignment.get_executor_node_port();
            nodeToHost = assignment.get_node_host();
            for (Entry<List<Long>, NodeInfo> entry : execToNodeInfo.entrySet()) {
                NodeInfo ni = entry.getValue();
                List<Object> nodePort = Arrays.asList(ni.get_node(), ni.get_port_iterator().next());
                List<Object> hostPort = Arrays.asList(nodeToHost.get(ni.get_node()), ni.get_port_iterator().next());
                exec2NodePort.put(entry.getKey(), nodePort);
                exec2HostPort.put(entry.getKey(), hostPort);
            }
        } else {
            nodeToHost = Collections.emptyMap();
        }
        ComponentPageInfo compPageInfo = StatsUtil.aggCompExecsStats(exec2HostPort, info.taskToComponent, info.beats, window, includeSys, topoId, topology, componentId);
        if (compPageInfo.get_component_type() == ComponentType.SPOUT) {
            compPageInfo.set_resources_map(setResourcesDefaultIfNotSet(ResourceUtils.getSpoutsResources(topology, topoConf), componentId, topoConf));
        } else {
            //bolt
            compPageInfo.set_resources_map(setResourcesDefaultIfNotSet(ResourceUtils.getBoltsResources(topology, topoConf), componentId, topoConf));
        }
        compPageInfo.set_topology_name(info.topoName);
        compPageInfo.set_errors(stormClusterState.errors(topoId, componentId));
        compPageInfo.set_topology_status(extractStatusStr(info.base));
        if (info.base.is_set_component_debug()) {
            DebugOptions debug = info.base.get_component_debug().get(componentId);
            if (debug != null) {
                compPageInfo.set_debug_options(debug);
            }
        }
        // Add the event logger details.
        Map<String, List<Integer>> compToTasks = Utils.reverseMap(info.taskToComponent);
        if (compToTasks.containsKey(StormCommon.EVENTLOGGER_COMPONENT_ID)) {
            List<Integer> tasks = compToTasks.get(StormCommon.EVENTLOGGER_COMPONENT_ID);
            tasks.sort(null);
            // Find the task the events from this component route to.
            int taskIndex = TupleUtils.chooseTaskIndex(Collections.singletonList(componentId), tasks.size());
            int taskId = tasks.get(taskIndex);
            String host = null;
            Integer port = null;
            for (Entry<List<Long>, List<Object>> entry : exec2HostPort.entrySet()) {
                int start = entry.getKey().get(0).intValue();
                int end = entry.getKey().get(1).intValue();
                if (taskId >= start && taskId <= end) {
                    host = (String) entry.getValue().get(0);
                    port = ((Number) entry.getValue().get(1)).intValue();
                    break;
                }
            }
            if (host != null && port != null) {
                compPageInfo.set_eventlog_host(host);
                compPageInfo.set_eventlog_port(port);
            }
        }
        return compPageInfo;
    } catch (Exception e) {
        LOG.warn("getComponentPageInfo exception. (topo id='{}')", topoId, e);
        if (e instanceof TException) {
            throw (TException) e;
        }
        throw new RuntimeException(e);
    }
}
Also used : TException(org.apache.thrift.TException) HashMap(java.util.HashMap) StormTopology(org.apache.storm.generated.StormTopology) DebugOptions(org.apache.storm.generated.DebugOptions) Assignment(org.apache.storm.generated.Assignment) SchedulerAssignment(org.apache.storm.scheduler.SchedulerAssignment) NotAliveException(org.apache.storm.generated.NotAliveException) ArrayList(java.util.ArrayList) List(java.util.List) DataPoint(org.apache.storm.metric.api.DataPoint) AuthorizationException(org.apache.storm.generated.AuthorizationException) NotAliveException(org.apache.storm.generated.NotAliveException) InterruptedIOException(java.io.InterruptedIOException) TException(org.apache.thrift.TException) IOException(java.io.IOException) AlreadyAliveException(org.apache.storm.generated.AlreadyAliveException) KeyAlreadyExistsException(org.apache.storm.generated.KeyAlreadyExistsException) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) BindException(java.net.BindException) ComponentPageInfo(org.apache.storm.generated.ComponentPageInfo) NodeInfo(org.apache.storm.generated.NodeInfo)

Example 3 with ComponentPageInfo

use of org.apache.storm.generated.ComponentPageInfo in project storm by apache.

the class StatsUtil method thriftifyCompPageData.

private static ComponentPageInfo thriftifyCompPageData(String topologyId, StormTopology topology, String compId, Map<String, Object> data) {
    ComponentPageInfo ret = new ComponentPageInfo();
    ret.set_component_id(compId);
    Map win2stats = new HashMap();
    putKV(win2stats, EMITTED, getMapByKey(data, WIN_TO_EMITTED));
    putKV(win2stats, TRANSFERRED, getMapByKey(data, WIN_TO_TRANSFERRED));
    putKV(win2stats, ACKED, getMapByKey(data, WIN_TO_ACKED));
    putKV(win2stats, FAILED, getMapByKey(data, WIN_TO_FAILED));
    String compType = (String) data.get(TYPE);
    if (compType.equals(SPOUT)) {
        ret.set_component_type(ComponentType.SPOUT);
        putKV(win2stats, COMP_LATENCY, getMapByKey(data, WIN_TO_COMP_LAT));
    } else {
        ret.set_component_type(ComponentType.BOLT);
        putKV(win2stats, EXEC_LATENCY, getMapByKey(data, WIN_TO_EXEC_LAT));
        putKV(win2stats, PROC_LATENCY, getMapByKey(data, WIN_TO_PROC_LAT));
        putKV(win2stats, EXECUTED, getMapByKey(data, WIN_TO_EXECUTED));
    }
    win2stats = swapMapOrder(win2stats);
    List<ExecutorAggregateStats> execStats = new ArrayList<>();
    List executorStats = (List) getByKey(data, EXECUTOR_STATS);
    if (executorStats != null) {
        for (Object o : executorStats) {
            execStats.add(thriftifyExecAggStats(compId, compType, (Map) o));
        }
    }
    Map gsid2inputStats, sid2outputStats;
    if (compType.equals(SPOUT)) {
        Map tmp = new HashMap();
        for (Object k : win2stats.keySet()) {
            tmp.put(k, thriftifySpoutAggStats((Map) win2stats.get(k)));
        }
        win2stats = tmp;
        gsid2inputStats = null;
        sid2outputStats = thriftifySpoutOutputStats(getMapByKey(data, SID_TO_OUT_STATS));
    } else {
        Map tmp = new HashMap();
        for (Object k : win2stats.keySet()) {
            tmp.put(k, thriftifyBoltAggStats((Map) win2stats.get(k)));
        }
        win2stats = tmp;
        gsid2inputStats = thriftifyBoltInputStats(getMapByKey(data, CID_SID_TO_IN_STATS));
        sid2outputStats = thriftifyBoltOutputStats(getMapByKey(data, SID_TO_OUT_STATS));
    }
    ret.set_num_executors(getByKeyOr0(data, NUM_EXECUTORS).intValue());
    ret.set_num_tasks(getByKeyOr0(data, NUM_TASKS).intValue());
    ret.set_topology_id(topologyId);
    ret.set_topology_name(null);
    ret.set_window_to_stats(win2stats);
    ret.set_sid_to_output_stats(sid2outputStats);
    ret.set_exec_stats(execStats);
    ret.set_gsid_to_input_stats(gsid2inputStats);
    return ret;
}
Also used : ComponentPageInfo(org.apache.storm.generated.ComponentPageInfo) HashMap(java.util.HashMap) ExecutorAggregateStats(org.apache.storm.generated.ExecutorAggregateStats) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)3 ComponentPageInfo (org.apache.storm.generated.ComponentPageInfo)3 HashMap (java.util.HashMap)2 List (java.util.List)2 ExecutorAggregateStats (org.apache.storm.generated.ExecutorAggregateStats)2 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 BindException (java.net.BindException)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)1 Assignment (org.apache.storm.generated.Assignment)1 AuthorizationException (org.apache.storm.generated.AuthorizationException)1 ComponentAggregateStats (org.apache.storm.generated.ComponentAggregateStats)1 DebugOptions (org.apache.storm.generated.DebugOptions)1 ExecutorSummary (org.apache.storm.generated.ExecutorSummary)1 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)1 KeyAlreadyExistsException (org.apache.storm.generated.KeyAlreadyExistsException)1 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)1 NodeInfo (org.apache.storm.generated.NodeInfo)1