use of com.creditease.uav.threadanalysis.server.da.ThreadChain in project uavstack by uavorg.
the class ThreadAnalyser method findThreadChain.
/**
* 查找线程依赖
*
* @param record
* @param threadId
* @return
*/
public List<ThreadObject> findThreadChain(List<Map<String, Object>> record, String threadId) {
ThreadDigraph digraph = new ThreadDigraph(parseThreads(record));
ThreadChain chain = new ThreadChain(digraph);
ThreadObject thread = digraph.thread(threadId);
return chain.getChain(thread);
}
use of com.creditease.uav.threadanalysis.server.da.ThreadChain in project uavstack by uavorg.
the class ThreadAnalyser method queryMutilDumpGraph.
/**
* @param threadIds
* @param records
* @return
*/
public Map<String, Object> queryMutilDumpGraph(List<String> threadIds, List<List<Map<String, Object>>> records) {
List<ThreadDigraph> dumps = new ArrayList<>();
for (List<Map<String, Object>> record : records) {
List<ThreadObject> threads = parseThreads(record);
dumps.add(new ThreadDigraph(threads));
}
List<Map<String, Object>> nodes = new ArrayList<>();
List<Map<String, Object>> edges = new ArrayList<>();
for (String threadId : threadIds) {
String timeSeries = null;
for (ThreadDigraph tg : dumps) {
ThreadChain threadChain = new ThreadChain(tg);
ThreadObject thread = tg.thread(threadId);
List<ThreadObject> chain = threadChain.getChain(thread);
if (chain == null) {
continue;
}
String from = null;
for (ThreadObject to : chain) {
String id = to.getId() + "_" + to.getTime();
Map<String, Object> node = new HashMap<>();
node.put("id", id);
node.put("name", DateTimeHelper.toStandardDateFormat(to.getTime()) + "\n" + to.getName());
node.put("type", "Thread");
node.put("tip", to.getInfo().split("\n")[0]);
node.put("msg", to.getInfo());
if (to.getThreadState() != null) {
node.put("state", to.getThreadState().toString());
}
nodes.add(node);
if (from != null) {
Map<String, Object> edge = new HashMap<>();
edge.put("from", from);
edge.put("to", id);
edges.add(edge);
}
from = id;
}
ThreadObject ts = chain.get(0);
if (timeSeries == null) {
timeSeries = ts.getId() + "_" + ts.getTime();
} else {
String nextTimeSeries = ts.getId() + "_" + ts.getTime();
Map<String, Object> edge = new HashMap<>();
edge.put("from", timeSeries);
edge.put("to", nextTimeSeries);
edge.put("dashes", true);
edges.add(edge);
timeSeries = nextTimeSeries;
}
}
}
Map<String, Object> graph = new HashMap<>();
graph.put("nodes", nodes);
graph.put("edges", edges);
return graph;
}
Aggregations