use of org.gridkit.jvmtool.stacktrace.analytics.ThreadEventFilter 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