com.ibm.dtfj.analyzer.util
Class ThreadFilter

java.lang.Object
  extended by com.ibm.dtfj.analyzer.util.ThreadFilter

public class ThreadFilter
extends java.lang.Object

Some simple utility methods to subset the various entities in a Java runtime. They are intended to be used as a filter pipe so we start with the iterator over all threads and then filter out threads which match given patterns. When doing String matching this class can operate either in simple matching mode or in regular expression mode. In simple mode we employ a simple pattern syntax in which the wildcard characters *,? and # can be used to indicate matching. A ? will match any character, a # will match any numeric char (0-9) and a * will match any number of characters. Thus ?* matches "Some","No", "n", but does NOT match "" #* matches "1Some","0No", "7", but does NOT match "" or "L" In regular expression mode we use the Java regular expressions which are similar to Perl and POSIX except in some corner cases.


Constructor Summary
ThreadFilter()
          Build a thread filter where matching is done by a simple matcher which understands the wildcard characters *, ?
ThreadFilter(boolean regularExpressionMatching)
          Build a thread filter and control the matching which can be done either by a simple matcher which understands the wildcard characters *, ?
 
Method Summary
 java.lang.String decodeModifiers(int mod)
          Decode the modifiers into a string form
 IAnalysisReport print(java.lang.String title, java.util.Iterator list, int depth, IAnalyzerBase a)
          A utility print method which will produce a titled report that shows the items in the given iterator which should in general all be of the same class.
 java.util.Iterator threadsByDepth(java.util.Iterator thrds, int depth, boolean deeper, IAnalyzerBase a)
          Return a subset of the threads which match the depth constraint specified by the parameters.
 java.util.Iterator threadsByName(java.util.Iterator thrds, java.lang.String name, IAnalyzerBase a)
          Return a subset of the threads whose name matches the given pattern.
 java.util.Iterator threadsInMethods(java.util.Iterator thrds, java.lang.String cls, java.lang.String met, int depth, IAnalyzerBase a)
          Return a subset of the threads which are currently in methods matching a pattern of class name, method name and stack depth.
 java.util.Iterator threadsInNativeMethods(java.util.Iterator thrds, int depth, IAnalyzerBase a)
          Return a subset of the threads which are currently in native methods
 java.util.Iterator threadsWithNativeThreadsIn(java.util.Iterator input, java.lang.String lib, java.lang.String proc, int depth, IAnalyzerBase a)
          Return a subset of the threads which are associated with native threads that are currently in native methods matching a pattern of proceure name and stack depth.
 void useRegularExpressionMatchingSyntax()
          When doing string matching use full regular expression processing.
 void useSimpleMatchingSyntax()
          When doing string matching use a simple matching syntax in which the wildcard characters *,?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadFilter

public ThreadFilter()
Build a thread filter where matching is done by a simple matcher which understands the wildcard characters *, ? and #.


ThreadFilter

public ThreadFilter(boolean regularExpressionMatching)
Build a thread filter and control the matching which can be done either by a simple matcher which understands the wildcard characters *, ? and # or alternatively by the full regular expression syntax.

Parameters:
regularExpressionMatching -
Method Detail

useSimpleMatchingSyntax

public void useSimpleMatchingSyntax()
When doing string matching use a simple matching syntax in which the wildcard characters *,? and # can be used to indicate matching. A ? will match any character, a # will match any numeric char (0-9) and a * will match any number of characters. Thus ?* matches "Some","No", "n", but does NOT match "" #* matches "1Some","0No", "7", but does NOT match "" or "L"


useRegularExpressionMatchingSyntax

public void useRegularExpressionMatchingSyntax()
When doing string matching use full regular expression processing. This is of course much more powerfull and allows complex matching to be specified.


threadsByName

public java.util.Iterator threadsByName(java.util.Iterator thrds,
                                        java.lang.String name,
                                        IAnalyzerBase a)
Return a subset of the threads whose name matches the given pattern.

Parameters:
thrds - list of threads to be subset
name - pattern which must match the thread name
a - the current analyzer
Returns:
an Iterator over all the threads that match the pattern

threadsByDepth

public java.util.Iterator threadsByDepth(java.util.Iterator thrds,
                                         int depth,
                                         boolean deeper,
                                         IAnalyzerBase a)
Return a subset of the threads which match the depth constraint specified by the parameters. The result can either be threads deeper than some level or shallower where deeper means more deeply nested in method calls.

Parameters:
thrds - list of threads to be subset
depth - stack depth to be tested against the actual depth
deeper - if true we return threads with stacks deeper than depth else return threads with depth less than or equal to depth
a - the current analyzer
Returns:
an Iterator over all the threads that match the pattern

threadsInMethods

public java.util.Iterator threadsInMethods(java.util.Iterator thrds,
                                           java.lang.String cls,
                                           java.lang.String met,
                                           int depth,
                                           IAnalyzerBase a)
Return a subset of the threads which are currently in methods matching a pattern of class name, method name and stack depth.

Parameters:
thrds - list of threads to be subset
cls - pattern which must match the class name - simple syntax
met - pattern which must match the method name - simple syntax
depth - depth below which the stack frame must occur
a - the current analyzer
Returns:
an Iterator over all the threads that match the pattern

threadsInNativeMethods

public java.util.Iterator threadsInNativeMethods(java.util.Iterator thrds,
                                                 int depth,
                                                 IAnalyzerBase a)
Return a subset of the threads which are currently in native methods

Parameters:
thrds - list of threads to be subset
depth - depth below which the native stack frame must occur
a - the current analyzer
Returns:
an Iterator over all the threads that match the pattern

threadsWithNativeThreadsIn

public java.util.Iterator threadsWithNativeThreadsIn(java.util.Iterator input,
                                                     java.lang.String lib,
                                                     java.lang.String proc,
                                                     int depth,
                                                     IAnalyzerBase a)
Return a subset of the threads which are associated with native threads that are currently in native methods matching a pattern of proceure name and stack depth.

Parameters:
input - list of threads to be subset
lib - library name to match using simple pattern syntax *,?,#
proc - procedure name to match using simple pattern syntax *,?,#
depth - depth below which the stack frame must occur
a - the current analyzer
Returns:
an Iterator over all the threads that match the pattern

print

public IAnalysisReport print(java.lang.String title,
                             java.util.Iterator list,
                             int depth,
                             IAnalyzerBase a)
A utility print method which will produce a titled report that shows the items in the given iterator which should in general all be of the same class. Typically this might be a list of threads etc. Formatting will be some default based on the entity type. Note that depth controls the amount of information printed and for threads it limits the stack depth, for classes it might limit the methods and fields etc.

Parameters:
title - the title for the report
list - the Iterator containing the items to be printed
depth - the depth to be printed where 0 means don't show 'depth' information and -ve means show everything
a - the current analyzer
Returns:
a report

decodeModifiers

public java.lang.String decodeModifiers(int mod)
Decode the modifiers into a string form

Parameters:
mod - the set of modifier flags
Returns:
the string form of those flags


© Copyright IBM Corp. 2007, 2008 All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.