PrintaRecord.java revision 91cfa10a8e55050a5103c4b2e83b0bf8d783a7cb
03831d35f7499c87d51205817c93e9a8d42c4baestevel * CDDL HEADER START
03831d35f7499c87d51205817c93e9a8d42c4baestevel * The contents of this file are subject to the terms of the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Common Development and Distribution License (the "License").
03831d35f7499c87d51205817c93e9a8d42c4baestevel * You may not use this file except in compliance with the License.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
03831d35f7499c87d51205817c93e9a8d42c4baestevel * See the License for the specific language governing permissions
03831d35f7499c87d51205817c93e9a8d42c4baestevel * and limitations under the License.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * When distributing Covered Code, include this CDDL HEADER in each
03831d35f7499c87d51205817c93e9a8d42c4baestevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * If applicable, add the following below this CDDL HEADER, with the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * fields enclosed by brackets "[]" replaced with your own identifying
03831d35f7499c87d51205817c93e9a8d42c4baestevel * information: Portions Copyright [yyyy] [name of copyright owner]
03831d35f7499c87d51205817c93e9a8d42c4baestevel * CDDL HEADER END
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Use is subject to license terms.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * ident "%Z%%M% %I% %E% SMI"
03831d35f7499c87d51205817c93e9a8d42c4baestevel * A record generated by the DTrace {@code printa()} action. Lists the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * aggregations passed to {@code printa()} and records the formatted
03831d35f7499c87d51205817c93e9a8d42c4baestevel * output associated with each {@link Tuple}. If multiple aggregations
03831d35f7499c87d51205817c93e9a8d42c4baestevel * were passed to the {@code printa()} action that generated this
03831d35f7499c87d51205817c93e9a8d42c4baestevel * record, then the DTrace library tabulates the output, using a default
03831d35f7499c87d51205817c93e9a8d42c4baestevel * format if no format string was specified. By default, the output
03831d35f7499c87d51205817c93e9a8d42c4baestevel * string associated with a given {@code Tuple} includes a value from
03831d35f7499c87d51205817c93e9a8d42c4baestevel * each aggregation, or zero wherever an aggregation has no value
03831d35f7499c87d51205817c93e9a8d42c4baestevel * associated with that {@code Tuple}. For example, the D statements
03831d35f7499c87d51205817c93e9a8d42c4baestevel * <pre><code>
03831d35f7499c87d51205817c93e9a8d42c4baestevel * @a[123] = sum(1);
03831d35f7499c87d51205817c93e9a8d42c4baestevel * @b[456] = sum(2);
03831d35f7499c87d51205817c93e9a8d42c4baestevel * printa(@a, @b, @c);
03831d35f7499c87d51205817c93e9a8d42c4baestevel * </code></pre>
03831d35f7499c87d51205817c93e9a8d42c4baestevel * produce output for the tuples "123" and "456" similar to the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * following:
03831d35f7499c87d51205817c93e9a8d42c4baestevel * <pre><code>
03831d35f7499c87d51205817c93e9a8d42c4baestevel * 123 1 0 0
03831d35f7499c87d51205817c93e9a8d42c4baestevel * 456 0 2 0
03831d35f7499c87d51205817c93e9a8d42c4baestevel * </code></pre>
03831d35f7499c87d51205817c93e9a8d42c4baestevel * The first column after the tuple contains values from {@code @a},
03831d35f7499c87d51205817c93e9a8d42c4baestevel * the next column contains values from {@code @b}, and the last
03831d35f7499c87d51205817c93e9a8d42c4baestevel * column contains zeros because {@code @c} has neither a value
03831d35f7499c87d51205817c93e9a8d42c4baestevel * associated with "123" nor a value associated with "456".
03831d35f7499c87d51205817c93e9a8d42c4baestevel * If a format string is passed to {@code printa()}, it may limit the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * aggregation data available in this record. For example, if the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * format string specifies a value placeholder for only one of two
03831d35f7499c87d51205817c93e9a8d42c4baestevel * aggregations passed to {@code printa()}, then the resulting {@code
03831d35f7499c87d51205817c93e9a8d42c4baestevel * PrintaRecord} will contain only one {@code Aggregation}. If no value
03831d35f7499c87d51205817c93e9a8d42c4baestevel * placeholder is specified, or if the aggregation tuple is not
03831d35f7499c87d51205817c93e9a8d42c4baestevel * completely specified, the resulting {@code PrintaRecord} will contain
03831d35f7499c87d51205817c93e9a8d42c4baestevel * no aggregation data. However, the formatted output generated by the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * DTrace library is available in all cases. For details about
03831d35f7499c87d51205817c93e9a8d42c4baestevel * {@code printa()} format strings, see the <a
03831d35f7499c87d51205817c93e9a8d42c4baestevel * href=http://docs.sun.com/app/docs/doc/817-6223/6mlkidli3?a=view>
03831d35f7499c87d51205817c93e9a8d42c4baestevel * <b>{@code printa()}</b></a> section of the <b>Output
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Formatting</b> chapter of the <i>Solaris Dynamic Tracing Guide</i>.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Immutable. Supports persistence using {@link java.beans.XMLEncoder}.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * @author Tom Erickson
03831d35f7499c87d51205817c93e9a8d42c4baestevelpublic final class PrintaRecord implements Record, Serializable {
03831d35f7499c87d51205817c93e9a8d42c4baestevel static final long serialVersionUID = -4174277639915895694L;
03831d35f7499c87d51205817c93e9a8d42c4baestevel BeanInfo info = Introspector.getBeanInfo(PrintaRecord.class);
03831d35f7499c87d51205817c93e9a8d42c4baestevel d.setValue("persistenceDelegate", persistenceDelegate);
03831d35f7499c87d51205817c93e9a8d42c4baestevel /** @serial */
03831d35f7499c87d51205817c93e9a8d42c4baestevel private final long snaptime;
03831d35f7499c87d51205817c93e9a8d42c4baestevel /** @serial */
03831d35f7499c87d51205817c93e9a8d42c4baestevel /** @serial */
03831d35f7499c87d51205817c93e9a8d42c4baestevel /** @serial */
03831d35f7499c87d51205817c93e9a8d42c4baestevel private transient boolean formatted;
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Package level access, called by ProbeData.
03831d35f7499c87d51205817c93e9a8d42c4baestevel PrintaRecord(long snaptimeNanos, boolean isFormatString)
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Creates a record with the given snaptime, aggregations, and
03831d35f7499c87d51205817c93e9a8d42c4baestevel * formatted output.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * @param snaptimeNanos nanosecond timestamp of the snapshot used
03831d35f7499c87d51205817c93e9a8d42c4baestevel * to create this {@code printa()} record
03831d35f7499c87d51205817c93e9a8d42c4baestevel * @param aggs aggregations passed to the {@code printa()} action
03831d35f7499c87d51205817c93e9a8d42c4baestevel * that generated this record
03831d35f7499c87d51205817c93e9a8d42c4baestevel * @param formattedOutput the formatted output, if any, associated
03831d35f7499c87d51205817c93e9a8d42c4baestevel * with each {@code Tuple} occurring in the aggregations belonging
03831d35f7499c87d51205817c93e9a8d42c4baestevel * to this record, one formatted string per {@code Tuple}, or an
03831d35f7499c87d51205817c93e9a8d42c4baestevel * empty or {@code null} map if an incomplete {@code printa()}
03831d35f7499c87d51205817c93e9a8d42c4baestevel * format string caused aggregation tuples to be omitted from this
03831d35f7499c87d51205817c93e9a8d42c4baestevel * @param orderedTuples list of aggregation tuples in the same order
03831d35f7499c87d51205817c93e9a8d42c4baestevel * generated by the native DTrace library (determined by the various
03831d35f7499c87d51205817c93e9a8d42c4baestevel * "aggsort" options such as {@link Option#aggsortkey})
03831d35f7499c87d51205817c93e9a8d42c4baestevel * @param formattedOutputString {@code printa()} formatted string
03831d35f7499c87d51205817c93e9a8d42c4baestevel * output in the same order generated by the native DTrace library
03831d35f7499c87d51205817c93e9a8d42c4baestevel * (determined by the various "aggsort" options such as
03831d35f7499c87d51205817c93e9a8d42c4baestevel * {@link Option#aggsortkey})
03831d35f7499c87d51205817c93e9a8d42c4baestevel * @throws NullPointerException if the given collection of
03831d35f7499c87d51205817c93e9a8d42c4baestevel * aggregations is {@code null}, or if the given ordered lists of
03831d35f7499c87d51205817c93e9a8d42c4baestevel * tuples or formatted strings are {@code null}
03831d35f7499c87d51205817c93e9a8d42c4baestevel * @throws IllegalArgumentException if the given snaptime is
03831d35f7499c87d51205817c93e9a8d42c4baestevel PrintaRecord(long snaptimeNanos, Collection <Aggregation> aggs,
03831d35f7499c87d51205817c93e9a8d42c4baestevel aggregations = new ArrayList <Aggregation> (aggs.size());
03831d35f7499c87d51205817c93e9a8d42c4baestevel tuples = new ArrayList <Tuple> (orderedTuples.size());
03831d35f7499c87d51205817c93e9a8d42c4baestevel private final void
03831d35f7499c87d51205817c93e9a8d42c4baestevel throw new IllegalArgumentException("snaptime is negative");
03831d35f7499c87d51205817c93e9a8d42c4baestevel throw new NullPointerException("aggregations list is null");
03831d35f7499c87d51205817c93e9a8d42c4baestevel for (int i = 0, len = aggregations.size(); i < len; ++i) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel if (a == null) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel "null aggregation at index " + i);
03831d35f7499c87d51205817c93e9a8d42c4baestevel throw new NullPointerException("ordered tuple list is null");
03831d35f7499c87d51205817c93e9a8d42c4baestevel throw new NullPointerException("formatted output is null");
return snaptime;
private Aggregation
return null;
return null;
public Aggregation
public String
return null;
public String
return output;
} catch (IllegalArgumentException e) {
s.defaultWriteObject();
s.defaultReadObject();
validate();
} catch (Exception e) {
public String
toString()