/** * 将原始数据切割后装入ThreadInfo,并以Key=WaitID,Value= ThreadInfo实体放入到Multimap<String, ThreadInfo>集合中 * ps:Multimap 类似于Map<key,collection>, key:value-> 1:n * * @param rawDatas * @return */ public Multimap<String, ThreadInfo> getThreadInfo(List<String[]> rawDatas) { Multimap<String, ThreadInfo> w_IdMap = HashMultimap.create(); List<ThreadInfo> threadsList = Lists.newArrayList(); for (String[] rawData : rawDatas) { ThreadInfo threadInfo = new ThreadInfo(); Pattern t_id = Pattern.compile("tid=(0x[\\d\\w]+)"); Pattern t_name = Pattern.compile("\"([\\d\\D]*)\""); Pattern w_Id = Pattern.compile("\\[(0x[\\d\\w]+)\\]"); Matcher tIdMatcher = t_id.matcher(rawData[0]); Matcher nameMatcher = t_name.matcher(rawData[0]); Matcher w_IdMatcher = w_Id.matcher(rawData[0]); if (tIdMatcher.find()) { threadInfo.setThreadId(tIdMatcher.group(1)); } if (nameMatcher.find()) { threadInfo.setThreadName(nameMatcher.group(1)); } if (w_IdMatcher.find()) { threadInfo.setWaitThreadId(w_IdMatcher.group(1)); } threadInfo.setThreadCondition(rawData[1]); w_IdMap.put(threadInfo.getWaitThreadId(), threadInfo); } return w_IdMap; }
/** * expand super types after scanning, for super types that were not scanned. this is helpful in * finding the transitive closure without scanning all 3rd party dependencies. it uses {@link * ReflectionUtils#getSuperTypes(Class)}. * * <p>for example, for classes A,B,C where A supertype of B, B supertype of C: * * <ul> * <li>if scanning C resulted in B (B->C in store), but A was not scanned (although A supertype * of B) - then getSubTypes(A) will not return C * <li>if expanding supertypes, B will be expanded with A (A->B in store) - then getSubTypes(A) * will return C * </ul> */ public void expandSuperTypes() { if (store.keySet().contains(index(SubTypesScanner.class))) { Multimap<String, String> mmap = store.get(index(SubTypesScanner.class)); Sets.SetView<String> keys = Sets.difference(mmap.keySet(), Sets.newHashSet(mmap.values())); Multimap<String, String> expand = HashMultimap.create(); for (String key : keys) { expandSupertypes(expand, key, forName(key)); } mmap.putAll(expand); } }