Class TraceContext
java.lang.Object
com.ibm.jvm.trace.format.api.TraceContext
-
Field Summary
Modifier and TypeFieldDescriptionprotected Vector
static final int
static final int
protected static final BigInteger
static final int
static final int
static final int
protected MessageFile
protected static final BigInteger
protected static final BigInteger
protected static final BigInteger
protected static final BigInteger
static final int
protected static final int
protected static final int
-
Method Summary
Modifier and TypeMethodDescriptionaddData
(byte[] data) addData
(RandomAccessFile file, long offset) void
addMessageData
(File file) void
addMessageData
(InputStream stream) Adds additional formatting strings to the set provided when the context was created.void
addThreadToFilter
(Long threadID) This method adds a thread id to the thread filter.void
Reports a debug messagevoid
This method tells the formatter that there was data discarded at this point in the stream of records.void
Reports an error messageformatPointer
(long value) static TraceContext
getContext
(byte[] data, int length, File messageFile) static TraceContext
getContext
(byte[] data, int length, File messageFile, PrintStream message, PrintStream error, PrintStream warning, PrintStream debug) static TraceContext
getContext
(byte[] data, int length, InputStream messageFile) Message and warning destinations default to stdout, the error destination defaults to stderr.static TraceContext
getContext
(byte[] data, int length, InputStream messageFile, PrintStream message, PrintStream error, PrintStream warning, PrintStream debug) This method constructs a context that can be used to format trace records produced by the VM instance that created the meta-data provided.static TraceContext
getContext
(ByteBuffer data, File messageFile) static TraceContext
getContext
(ByteBuffer data, File messageFile, PrintStream message, PrintStream error, PrintStream warning, PrintStream debug) This method constructs a context that can be used to format trace records produced by the VM instance that created the meta-data provided.static TraceContext
getContext
(ByteBuffer data, InputStream messageFile) Message and warning destinations default to stdout, the error destination defaults to stderr.static TraceContext
getContext
(ByteBuffer data, InputStream messageFile, PrintStream message, PrintStream error, PrintStream warning, PrintStream debug) This method constructs a context that can be used to format trace records produced by the VM instance that created the meta-data provided.long
The number of errors encountered to dateint
Returns the size of the meta-data.int
getHeaderSize
(ByteBuffer data) Constructs a temporary TraceFileHeader from the supplied data and returns it's size offset of the first record.This returns the number of high precision ticks per millisecond as calculated based on trace data processed to date.int
Accessor for the pointer size associated with the trace dataint
The size of the trace records expected by the contextboolean
Answer whether thread names are being captured for inclusion in the information returned bysummary()
.The time of trace initialization in the traced JVM in high precision format This should be used in conjunction with the system start timeThe system time of trace initialization in the traced JVMThis method provides an iterator to walk the set of known threads; those that have not returned trace points that indicate the thread is exiting.long
The total number of records processed to datelong
The total number of trace points returned to dateThis method returns trace points in chronological order on the current data set across threads.int
Accessor for the trace type, internal (wraps within a single buffer) or external (no wrapping)float
A description of the VM that generated the meta-data with which the context was constructedlong
The number of warnings encountered to datevoid
Reports an informational messageorder()
The byte order of the trace datavoid
setDebugLevel
(int level) void
setDebugStream
(PrintStream stream) Sets the destination for debug messagesvoid
setErrorStream
(PrintStream stream) Sets the destination for error messagesvoid
setMessageStream
(PrintStream stream) Sets the destination for informational messagesvoid
setRecordThreadNames
(boolean value) Controls whether thread names are captured for inclusion in the information returned bysummary()
.void
setTimeZoneOffset
(int minutes) Sets the timezone offset from GMT in +/- minutes to be applied to the time stamp when formatted.void
setTraceType
(int type) Deprecated.this method is deprecated as it's use implies a problem elsewherevoid
setWarningStream
(PrintStream stream) Sets the destination for warning messagessummary()
void
Reports a warning message
-
Field Details
-
traceFormatMajorVersion
protected static final int traceFormatMajorVersion- See Also:
-
traceFormatMinorVersion
protected static final int traceFormatMinorVersion- See Also:
-
INTERNAL
public static final int INTERNAL- See Also:
-
EXTERNAL
public static final int EXTERNAL- See Also:
-
BYTE
public static final int BYTE- See Also:
-
INT
public static final int INT- See Also:
-
LONG
public static final int LONG- See Also:
-
SIZE_T
public static final int SIZE_T- See Also:
-
MILLIS2SECONDS
-
SECONDS2MINUTES
-
MINUTES2HOURS
-
HOURS2DAYS
-
MILLION
-
messageFile
-
auxiliaryMessageFiles
-
-
Method Details
-
setRecordThreadNames
public void setRecordThreadNames(boolean value) Controls whether thread names are captured for inclusion in the information returned bysummary()
. By default, thread names are not captured unless enabled via this method. Any previously captured names are discarded when subsequently disabled.- Parameters:
value
- whether thread names should be captured
-
getRecordThreadNames
public boolean getRecordThreadNames()Answer whether thread names are being captured for inclusion in the information returned bysummary()
.- Returns:
- true if thread names are being captured, false otherwise
-
warning
-
error
-
message
-
debug
-
setErrorStream
Sets the destination for error messages- Parameters:
stream
- - destination
-
setWarningStream
Sets the destination for warning messages- Parameters:
stream
- - destination
-
setDebugStream
Sets the destination for debug messages- Parameters:
stream
- - destination
-
setMessageStream
Sets the destination for informational messages- Parameters:
stream
- - destination
-
getVersion
public float getVersion()- Returns:
-
getVmVersionString
A description of the VM that generated the meta-data with which the context was constructed- Returns:
- - VM description
-
getHighPrecisionResolution
This returns the number of high precision ticks per millisecond as calculated based on trace data processed to date. This value will stabilize over time.- Returns:
- - ticks per millisecond
-
getRecordSize
public int getRecordSize()The size of the trace records expected by the context- Returns:
- - size in bytes
-
getHeaderSize
public int getHeaderSize()Returns the size of the meta-data. This allows a file processor to skip to the offset of the first record.- Returns:
- the length of the meta-data
-
getHeaderSize
Constructs a temporary TraceFileHeader from the supplied data and returns it's size offset of the first record.- Returns:
- the length of the meta-data
-
order
-
getTraceType
public int getTraceType()Accessor for the trace type, internal (wraps within a single buffer) or external (no wrapping)- Returns:
- - trace type
-
setTraceType
Deprecated.this method is deprecated as it's use implies a problem elsewhereThis forces the trace to a given type. This should only be necessary if you have metadata from a VM when no subscribers were attached and data from a subscriber that was registered afterwards. The inverted case could be true as well, but is much less likely to occur. If you're calling this then you should think about altering the sequence of calls used to get the metadata and trace data.- Parameters:
type
- - the type of the trace data to process, either TraceContext.INTERNAL or TraceContext.EXTERNAL
-
getTotalTracePoints
public long getTotalTracePoints()The total number of trace points returned to date- Returns:
- - number of trace points
-
getTotalRecords
public long getTotalRecords()The total number of records processed to date- Returns:
- - number of records
-
getErrorCount
public long getErrorCount()The number of errors encountered to date- Returns:
- - number of errors
-
getWarningCount
public long getWarningCount()The number of warnings encountered to date- Returns:
- - number of warnings
-
addMessageData
- Throws:
IOException
- See Also:
-
addMessageData
Adds additional formatting strings to the set provided when the context was created.- Parameters:
stream
- - input stream for accessing formatting data- Throws:
IOException
-
getPointerSize
public int getPointerSize()Accessor for the pointer size associated with the trace data- Returns:
- - pointer size in bytes (4 or 8)
-
getContext
- Returns:
- Throws:
IOException
- See Also:
-
getContext
- Throws:
IOException
- See Also:
-
getContext
public static TraceContext getContext(byte[] data, int length, File messageFile, PrintStream message, PrintStream error, PrintStream warning, PrintStream debug) throws IOException - Throws:
IOException
- See Also:
-
getContext
Message and warning destinations default to stdout, the error destination defaults to stderr.- Throws:
IOException
- See Also:
-
getContext
public static TraceContext getContext(byte[] data, int length, InputStream messageFile) throws IOException Message and warning destinations default to stdout, the error destination defaults to stderr.- Throws:
IOException
- See Also:
-
getContext
public static TraceContext getContext(byte[] data, int length, InputStream messageFile, PrintStream message, PrintStream error, PrintStream warning, PrintStream debug) throws IOException This method constructs a context that can be used to format trace records produced by the VM instance that created the meta-data provided. The message file is used to format trace points into a human readable form and the print streams provided are where messages of that type are written to- Parameters:
data
- - trace meta-datalength
- - the length of the meta-data in the arraymessageFile
- - a file containing format stringsmessage
- - informational message destinationerror
- - error message destinationwarning
- - warning message destinationdebug
- - debug message destination- Returns:
- - a context to use for formatting trace records
- Throws:
IOException
- - if the message data can't be accessed
-
getContext
public static TraceContext getContext(ByteBuffer data, File messageFile, PrintStream message, PrintStream error, PrintStream warning, PrintStream debug) throws IOException This method constructs a context that can be used to format trace records produced by the VM instance that created the meta-data provided. The message file is used to format trace points into a human readable form and the print streams provided are where messages of that type are written to- Parameters:
data
- - trace meta-datamessageFile
- - a file containing format stringsmessage
- - informational message destinationerror
- - error message destinationwarning
- - warning message destinationdebug
- - debug message destination- Returns:
- - a context to use for formatting trace records
- Throws:
IOException
-
getContext
public static TraceContext getContext(ByteBuffer data, InputStream messageFile, PrintStream message, PrintStream error, PrintStream warning, PrintStream debug) throws IOException This method constructs a context that can be used to format trace records produced by the VM instance that created the meta-data provided. The message file is used to format trace points into a human readable form and the print streams provided are where messages of that type are written to- Parameters:
data
- - trace meta-datamessageFile
- - an input stream providing access to format stringsmessage
- - informational message destinationerror
- - error message destinationwarning
- - warning message destinationdebug
- - debug message destination- Returns:
- - a context to use for formatting trace records
- Throws:
IOException
-
addData
- Parameters:
file
- - file containing trace dataoffset
- - the offset in the file of the buffer- Returns:
- - the thread that generated the buffer
- Throws:
IOException
- See Also:
-
addData
- Parameters:
data
- - a trace buffer generated by the JVM corresponding the context- Returns:
- - the thread that generated the buffer
- See Also:
-
discardedData
public void discardedData()This method tells the formatter that there was data discarded at this point in the stream of records. This has the affect of discarding any trace point fragments that are awaiting data for completion across all threads. When a trace point iterator encounters one of the locations where data was discarded it will throw a MissingDataException as for records discarded by the trace engine. This makes the assumption that the records are being supplied chronologically. -
getStartPlatform
The time of trace initialization in the traced JVM in high precision format This should be used in conjunction with the system start time- Returns:
- - high precision start time
-
getStartSystem
The system time of trace initialization in the traced JVM- Returns:
- - start time
-
getThreads
This method provides an iterator to walk the set of known threads; those that have not returned trace points that indicate the thread is exiting. This iterator may be invalidated by adding new trace data to the context.- Returns:
- - iterator over non-dead threads
-
getTracepoints
This method returns trace points in chronological order on the current data set across threads. This operates on the data available at the time the method is called. If new data is added the oldest trace point from the expanded data set will be returned, irrespective if newer trace points have already been returned.- Returns:
-
addThreadToFilter
This method adds a thread id to the thread filter. Only those threads in the filter will have data returned via any of the iterators.- Parameters:
threadID
- - the id of the thread to include in the filter
-
setTimeZoneOffset
public void setTimeZoneOffset(int minutes) Sets the timezone offset from GMT in +/- minutes to be applied to the time stamp when formatted.- Parameters:
minutes
- - timezone offset in minutes
-
formatPointer
-
summary
-
setDebugLevel
public void setDebugLevel(int level) -
statistics
-