Class ProfileStackFrame
- java.lang.Object
-
- org.opends.server.plugins.profiler.ProfileStackFrame
-
- All Implemented Interfaces:
Comparable
public class ProfileStackFrame extends Object implements 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
Constructors Constructor Description ProfileStackFrame(String className, String methodName)Creates a new profile stack frame with the provided information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Object o)Indicates the order of this profile stack frame relative to the provided object in a sorted list.booleanequals(Object o)Indicates whether the provided object is equal to this stack frame.StringgetClassName()Retrieves the class name for this stack frame.StringgetHTMLSafeMethodName()Retrieves the method name for this stack frame in a manner that will be safe for use in an HTML context.HashMap<Integer,Long>getLineNumbers()Retrieves the mapping between the line numbers associated with this method and the number of occurrences for each of those line numbers.StringgetMethodName()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.longgetTotalCount()Retrieves the total number of times that a frame with this class and method name was seen by the profiler thread.inthashCode()Retrieves the hash code for this stack frame.booleanhasSubFrames()Indicates whether this stack frame has one or more subordinate frames.voidrecurseSubFrames(ProfileStack stack, int depth, long count, HashMap<String,HashMap<ProfileStack,Long>> stacksByMethod)Recursively processes the frames of the provided stack, adding them as nested subordinate frames of this stack frame.StringtoString()Retrieves a string representation of this stack frame.voidupdateLineNumberCount(int lineNumber, long numOccurrences)Updates the count for the number of occurrences of a given stack frame for the specified line number.
-
-
-
Method Detail
-
getClassName
public String getClassName()
Retrieves the class name for this stack frame.- Returns:
- The class name for this stack frame.
-
getMethodName
public String getMethodName()
Retrieves the method name for this stack frame.- Returns:
- The method name for this stack frame.
-
getHTMLSafeMethodName
public 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 HashMap<Integer,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:
trueif this stack frame has one or more subordinate frames, orfalseif not.
-
recurseSubFrames
public void recurseSubFrames(ProfileStack stack, int depth, long count, HashMap<String,HashMap<ProfileStack,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.
-
equals
public boolean equals(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.
-
compareTo
public int compareTo(Object o) throws 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:
compareToin interfaceComparable- Parameters:
o- The object for 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:
ClassCastException- If the provided object is not a profile stack frame.
-
-