Version 1.2.0 of the EasySMF:JE Java API is now available.
Major Changes
- SMF Type 89 Support
- SMF type 42 Support
- DB2 SMF type 100 and 101 support
Java API for DB2 SMF Records
This support is currently experimental while we learn more about the specifics of DB2 SMF data. Breaking changes to the API are more likely while it is in experimental status.
Using the API
Typical steps to use the package are:
- Read SMF records using the SmfRecordReader class
- Check the record type and other relevant attributes of each SmfRecord to see whether it is one you are interested in
- Create the specific record type from the SmfRecord e.g.
new Smf100Record(record)
- Process information from the specific record as required
DB2 Record Compression
Records compressed with CSRCESRV will be automatically expanded when the SmfDb2Record is constructed.
IFCID
The IFCID of the record can be determined using the SmfDb2Record.ifcid()
method.
Accessing Record Data
DB2 records are typically made up of a varying number of sections of different types. Sections of a specific type are returned in a List<E> of that type. If there are no sections of the type in the record an empty List is returned. This allows you to iterate over the sections without explicitly checking whether the sections exist in the record – an empty list will iterate 0 times. However, you may need to check the IFCID if the section is present in multiple IFCIDs but you want data from a specific IFCID.
Example
The following code reads all Qwos sections from type 100 SMF records from the DD INPUT.
try (SmfRecordReader reader =
SmfRecordReader.fromDD("INPUT").include(100)) // include only type 100 records
{
for (SmfRecord record : reader) // read each record
{
Smf100Record r100 = new Smf100Record(record); // construct a Smf100record
for (Qwos qwos : r100.qwos()) // process 0 or more Qwos sections
{
//... // process Qwos sections here
}
}
} // reader automatically closed at end
// of try with resources block.
Of course the inner loop can be replaced with whatever processing you need to do with the record.
Data Conversion
The API aims to provide a consistent interface across different types and sections, and converts values to standard Java types for simple programming. Conversions are the same as for other SMF record types.
Dates and Times
Dates and times are converted to java.time classes. Java.time can represent dates and times with a precision of 1 nanosecond.
- Times representing a duration e.g. CPU or elapsed time are converted to Duration.
- Dates and times of day are converted to LocalDate, LocalTime, LocalDateTime or ZonedDateTime depending on exactly what information is in the field. Typically, times based on UTC(GMT) are converted to ZonedDateTime with ZoneOffset.UTC. Other dates and times are converted to LocalDate/Times.
Java has time zone rules so it is possible to apply a ZoneId to a LocalDateTime and perform date aware conversions between time zones.
The raw numeric value of date and time fields is also provided.
Numeric Values
- 1, 2 and 3 byte integer values and 4 byte signed integer values are converted to int (32 bit signed) values.
- 4-7 byte integer values and 8 byte signed values are converted to long (64 bit signed).
- 8 byte unsigned values are available as both long (64 bit signed) and as a BigInteger. The long value may provide better performance if the value will not exceed the maximum value for a long. If a value does exceed the maximum value (i.e. the high order bit is set) an exception will be thrown.
If the field value might exceed the maximum value for a long, use the BigInteger version. - Integer values greater than 8 bytes are converted to BigInteger.
- Floating point values are converted to Java double.