Search in sources :

Example 1 with ParserException

use of org.gridkit.jvmtool.stacktrace.analytics.ParserException 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() + "]");
        }
    }
}
Also used : ParserException(org.gridkit.jvmtool.stacktrace.analytics.ParserException) TimeRangeChecker(org.gridkit.jvmtool.stacktrace.analytics.TimeRangeChecker) ThreadSnapshotFilter(org.gridkit.jvmtool.stacktrace.analytics.ThreadSnapshotFilter) ThreadSnapshotEvent(org.gridkit.jvmtool.codec.stacktrace.ThreadSnapshotEvent) ThreadEventFilter(org.gridkit.jvmtool.stacktrace.analytics.ThreadEventFilter) PositionalStackMatcher(org.gridkit.jvmtool.stacktrace.analytics.PositionalStackMatcher) CachingFilterFactory(org.gridkit.jvmtool.stacktrace.analytics.CachingFilterFactory)

Aggregations

ThreadSnapshotEvent (org.gridkit.jvmtool.codec.stacktrace.ThreadSnapshotEvent)1 CachingFilterFactory (org.gridkit.jvmtool.stacktrace.analytics.CachingFilterFactory)1 ParserException (org.gridkit.jvmtool.stacktrace.analytics.ParserException)1 PositionalStackMatcher (org.gridkit.jvmtool.stacktrace.analytics.PositionalStackMatcher)1 ThreadEventFilter (org.gridkit.jvmtool.stacktrace.analytics.ThreadEventFilter)1 ThreadSnapshotFilter (org.gridkit.jvmtool.stacktrace.analytics.ThreadSnapshotFilter)1 TimeRangeChecker (org.gridkit.jvmtool.stacktrace.analytics.TimeRangeChecker)1