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);
}
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);
}
}
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;
}
Aggregations