use of org.gridkit.jvmtool.stacktrace.analytics.ThreadSnapshotFilter in project jvm-tools by aragozin.
the class CategorizerParser method loadCategories.
public static void loadCategories(Reader source, SimpleCategorizer categorizer, boolean shortNames, final BasicFilterFactory factory) throws IOException {
final Map<String, ThreadSnapshotFilter> filters = new LinkedHashMap<String, ThreadSnapshotFilter>();
@SuppressWarnings("serial") Properties props = new Properties() {
@Override
public synchronized Object put(Object key, Object value) {
String skey = (String) key;
String svalue = (String) value;
if (!skey.endsWith("._")) {
ThreadSnapshotFilter filter = TraceFilterPredicateParser.parseFilter(svalue, factory);
filters.put(skey, filter);
}
return super.put(key, value);
}
};
props.load(source);
for (String cat : filters.keySet()) {
String name = cat;
if (!shortNames) {
String desc = props.getProperty(name + "._");
if (desc != null) {
name = desc;
}
}
categorizer.addCategory(name, filters.get(cat));
}
}
use of org.gridkit.jvmtool.stacktrace.analytics.ThreadSnapshotFilter in project jvm-tools by aragozin.
the class ThreadDumpSource method getFilteredReader.
public EventReader<ThreadSnapshotEvent> getFilteredReader() {
if (traceFilter == null && traceTrim == null && threadName == null && timeRange == null) {
return getUnclassifiedReader();
} else {
EventReader<ThreadSnapshotEvent> reader = getUnclassifiedReader();
if (threadName != null) {
reader = reader.morph(new ThreadNameFilter(threadName));
}
if (timeRange != null) {
String[] lh = timeRange.split("[-]");
if (lh.length != 2) {
host.fail("Invalid time range '" + timeRange + "'", "Valid format yyyy.MM.dd_HH:mm:ss-yyyy.MM.dd_HH:mm:ss hours and higher parts can be ommited");
}
TimeRangeChecker checker = new TimeRangeChecker(lh[0], lh[1], timeZone);
reader = reader.morph(new TimeFilter(checker));
}
try {
CachingFilterFactory factory = new CachingFilterFactory();
if (traceFilter != null) {
ThreadSnapshotFilter ts = TraceFilterPredicateParser.parseFilter(traceFilter, factory);
reader = reader.morph(new ThreadEventFilter(ts));
}
if (traceTrim != null) {
final PositionalStackMatcher mt = TraceFilterPredicateParser.parsePositionMatcher(traceTrim, factory);
reader = reader.morph(new TrimProxy() {
@Override
public ThreadSnapshotEvent morph(ThreadSnapshotEvent event) {
int n = mt.matchNext(event, 0);
if (n >= 0) {
trimPoint = n;
return super.morph(event);
} else {
return null;
}
}
});
}
return reader;
} catch (ParserException e) {
throw host.fail("Failed to parse trace filter - " + e.getMessage() + " at " + e.getOffset() + " [" + e.getParseText() + "]");
}
}
}
Aggregations