use of org.apache.storm.generated.ProfileAction in project storm by apache.
the class Nimbus method getComponentPendingProfileActions.
@Override
public List<ProfileRequest> getComponentPendingProfileActions(String id, String componentId, ProfileAction action) throws TException {
try {
getComponentPendingProfileActionsCalls.mark();
CommonTopoInfo info = getCommonTopoInfo(id, "getComponentPendingProfileActions");
Map<String, String> nodeToHost = info.assignment.get_node_host();
Map<List<? extends Number>, List<Object>> exec2hostPort = new HashMap<>();
for (Entry<List<Long>, NodeInfo> entry : info.assignment.get_executor_node_port().entrySet()) {
NodeInfo ni = entry.getValue();
List<Object> hostPort = Arrays.asList(nodeToHost.get(ni.get_node()), ni.get_port_iterator().next().intValue());
exec2hostPort.put(entry.getKey(), hostPort);
}
List<Map<String, Object>> nodeInfos = StatsUtil.extractNodeInfosFromHbForComp(exec2hostPort, info.taskToComponent, false, componentId);
List<ProfileRequest> ret = new ArrayList<>();
for (Map<String, Object> ni : nodeInfos) {
String niHost = (String) ni.get("host");
int niPort = ((Integer) ni.get("port")).intValue();
ProfileRequest newestMatch = null;
long reqTime = -1;
for (ProfileRequest req : stormClusterState.getTopologyProfileRequests(id)) {
String expectedHost = req.get_nodeInfo().get_node();
int expectedPort = req.get_nodeInfo().get_port_iterator().next().intValue();
ProfileAction expectedAction = req.get_action();
if (niHost.equals(expectedHost) && niPort == expectedPort && action == expectedAction) {
long time = req.get_time_stamp();
if (time > reqTime) {
reqTime = time;
newestMatch = req;
}
}
}
if (newestMatch != null) {
ret.add(newestMatch);
}
}
LOG.info("Latest profile actions for topology {} component {} {}", id, componentId, ret);
return ret;
} catch (Exception e) {
LOG.warn("Get comp actions topology exception. (topology id='{}')", id, e);
if (e instanceof TException) {
throw (TException) e;
}
throw new RuntimeException(e);
}
}
use of org.apache.storm.generated.ProfileAction in project storm by apache.
the class BasicContainer method runProfiling.
@Override
public boolean runProfiling(ProfileRequest request, boolean stop) throws IOException, InterruptedException {
_type.assertFull();
String targetDir = ConfigUtils.workerArtifactsRoot(_conf, _topologyId, _port);
@SuppressWarnings("unchecked") Map<String, String> env = (Map<String, String>) _topoConf.get(Config.TOPOLOGY_ENVIRONMENT);
if (env == null) {
env = new HashMap<String, String>();
}
String str = ConfigUtils.workerArtifactsPidPath(_conf, _topologyId, _port);
String workerPid = _ops.slurpString(new File(str)).trim();
ProfileAction profileAction = request.get_action();
String logPrefix = "ProfilerAction process " + _topologyId + ":" + _port + " PROFILER_ACTION: " + profileAction + " ";
List<String> command = mkProfileCommand(profileAction, stop, workerPid, targetDir);
File targetFile = new File(targetDir);
if (command.size() > 0) {
return runProfilingCommand(command, env, logPrefix, targetFile);
}
LOG.warn("PROFILING REQUEST NOT SUPPORTED {} IGNORED...", request);
return true;
}
Aggregations