org.opends.server.plugins.profiler
Class ProfileStackFrame

java.lang.Object
  extended by org.opends.server.plugins.profiler.ProfileStackFrame
All Implemented Interfaces:
java.lang.Comparable

public class ProfileStackFrame
extends java.lang.Object
implements java.lang.Comparable

This class defines a data structure for holding information about a stack frame captured by the Directory Server profiler. It will contain the class and method name for this frame, the set of line numbers within that method that were captured along with the number of times they were seen, as well as references to subordinate frames that were encountered.


Constructor Summary
ProfileStackFrame(java.lang.String className, java.lang.String methodName)
          Creates a new profile stack frame with the provided information.
 
Method Summary
 int compareTo(java.lang.Object o)
          Indicates the order of this profile stack frame relative to the provided object in a sorted list.
 boolean equals(java.lang.Object o)
          Indicates whether the provided object is equal to this stack frame.
 java.lang.String getClassName()
          Retrieves the class name for this stack frame.
 java.lang.String getHTMLSafeMethodName()
          Retrieves the method name for this stack frame in a manner that will be safe for use in an HTML context.
 java.util.HashMap<java.lang.Integer,java.lang.Long> getLineNumbers()
          Retrieves the mapping between the line numbers associated with this method and the number of occurrences for each of those line numbers.
 java.lang.String getMethodName()
          Retrieves the method name for this stack frame.
 ProfileStackFrame[] getSubordinateFrames()
          Retrieves an array containing the subordinate frames that were seen below this frame in stack traces.
 long getTotalCount()
          Retrieves the total number of times that a frame with this class and method name was seen by the profiler thread.
 int hashCode()
          Retrieves the hash code for this stack frame.
 boolean hasSubFrames()
          Indicates whether this stack frame has one or more subordinate frames.
 void recurseSubFrames(ProfileStack stack, int depth, long count, java.util.HashMap<java.lang.String,java.util.HashMap<ProfileStack,java.lang.Long>> stacksByMethod)
          Recursively processes the frames of the provided stack, adding them as nested subordinate frames of this stack frame.
 java.lang.String toString()
          Retrieves a string representation of this stack frame.
 void updateLineNumberCount(int lineNumber, long numOccurrences)
          Updates the count for the number of occurrences of a given stack frame for the specified line number.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProfileStackFrame

public ProfileStackFrame(java.lang.String className,
                         java.lang.String methodName)
Creates a new profile stack frame with the provided information.

Parameters:
className - The class name for use in this stack frame.
methodName - The method name for use in this stack frame.
Method Detail

getClassName

public java.lang.String getClassName()
Retrieves the class name for this stack frame.

Returns:
The class name for this stack frame.

getMethodName

public java.lang.String getMethodName()
Retrieves the method name for this stack frame.

Returns:
The method name for this stack frame.

getHTMLSafeMethodName

public java.lang.String getHTMLSafeMethodName()
Retrieves the method name for this stack frame in a manner that will be safe for use in an HTML context. Currently, this simply replaces angle brackets with the appropriate HTML equivalent.

Returns:
The generated safe name.

getLineNumbers

public java.util.HashMap<java.lang.Integer,java.lang.Long> getLineNumbers()
Retrieves the mapping between the line numbers associated with this method and the number of occurrences for each of those line numbers.

Returns:
The mapping between the line numbers associated with this method and the number of occurrences for each of those line numbers.

updateLineNumberCount

public void updateLineNumberCount(int lineNumber,
                                  long numOccurrences)
Updates the count for the number of occurrences of a given stack frame for the specified line number.

Parameters:
lineNumber - The line number for which to update the count.
numOccurrences - The number of times the specified line was encountered for this stack frame.

getTotalCount

public long getTotalCount()
Retrieves the total number of times that a frame with this class and method name was seen by the profiler thread.

Returns:
The total number of times that a frame with this class and method name was seen by the profiler thread.

getSubordinateFrames

public ProfileStackFrame[] getSubordinateFrames()
Retrieves an array containing the subordinate frames that were seen below this frame in stack traces. The elements of the array will be sorted in descending order of the number of occurrences.

Returns:
An array containing the subordinate frames that were seen below this frame in stack traces.

hasSubFrames

public boolean hasSubFrames()
Indicates whether this stack frame has one or more subordinate frames.

Returns:
true if this stack frame has one or more subordinate frames, or false if not.

recurseSubFrames

public void recurseSubFrames(ProfileStack stack,
                             int depth,
                             long count,
                             java.util.HashMap<java.lang.String,java.util.HashMap<ProfileStack,java.lang.Long>> stacksByMethod)
Recursively processes the frames of the provided stack, adding them as nested subordinate frames of this stack frame.

Parameters:
stack - The stack trace to use to obtain the frames.
depth - The slot of the next frame to process in the provided array.
count - The number of occurrences for the provided stack.
stacksByMethod - The set of stack traces mapped from method name to their corresponding stack traces.

hashCode

public int hashCode()
Retrieves the hash code for this stack frame. It will be the sum of the hash codes for the class and method name.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code for this stack frame.

equals

public boolean equals(java.lang.Object o)
Indicates whether the provided object is equal to this stack frame. It will be considered equal if it is a profile stack frame with the same class and method name.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object for which to make the determination.
Returns:
true if the provided object may be considered equal to this stack frame, or false if not.

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Indicates the order of this profile stack frame relative to the provided object in a sorted list. The order will be primarily based on number of occurrences, with an equivalent number of occurrences falling back on alphabetical by class and method names.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The objectfor which to make the comparison.
Returns:
A negative integer if this stack frame should come before the provided object in a sorted list, a positive integer if it should come after the provided object, or zero if they should have equivalent order.
Throws:
java.lang.ClassCastException - If the provided object is not a profile stack frame.

toString

public java.lang.String toString()
Retrieves a string representation of this stack frame. It will contain the total number of matching frames, the class name, and the method name.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this stack frame.