org.opensolaris.os.dtrace
Class Aggregate

java.lang.Object
  extended by org.opensolaris.os.dtrace.Aggregate
All Implemented Interfaces:
java.io.Serializable

public final class Aggregate
extends java.lang.Object
implements java.io.Serializable

A consistent snapshot of all aggregations requested by a single Consumer.

Immutable. Supports persistence using XMLEncoder.

See Also:
Consumer.getAggregate(), Serialized Form

Constructor Summary
Aggregate(long snaptimeNanos, java.util.Collection<Aggregation> aggregations)
          Creates an aggregate with the given snaptime and aggregations.
 
Method Summary
 java.util.Map<java.lang.String,Aggregation> asMap()
          Gets a read-only Map view of this aggregate.
 Aggregation getAggregation(java.lang.String name)
          Gets the aggregation with the given name if it exists in this aggregate snapshot.
 java.util.List<Aggregation> getAggregations()
          Gets an unordered list of all aggregations in this aggregate snapshot.
 java.util.List<AggregationRecord> getOrderedRecords()
          Gets an ordered list of this aggregate's records sequenced by their ordinal property.
 java.util.List<AggregationRecord> getRecords()
          Gets an unordered list of this aggregate's records.
 long getSnaptime()
          Gets the nanosecond timestamp of this aggregate snapshot.
 java.lang.String toString()
          Gets a string representation of this aggregate snapshot useful for logging and not intended for display.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Aggregate

public Aggregate(long snaptimeNanos,
                 java.util.Collection<Aggregation> aggregations)
Creates an aggregate with the given snaptime and aggregations. Supports XML persistence.

Parameters:
snaptimeNanos - nanosecond timestamp when this aggregate was snapped
aggregations - unordered collection of aggregations belonging to this aggregate
Throws:
java.lang.NullPointerException - if the given collection of aggregations is null
java.lang.IllegalArgumentException - if the record ordinals of the given aggregations are invalid
Method Detail

getSnaptime

public long getSnaptime()
Gets the nanosecond timestamp of this aggregate snapshot.

Returns:
nanosecond timestamp of this aggregate snapshot

getAggregations

public java.util.List<Aggregation> getAggregations()
Gets an unordered list of all aggregations in this aggregate snapshot. The list is easily sortable using Collections.sort(List list, Comparator c) provided any user-defined ordering. Modifying the returned list has no effect on this aggregate. Supports XML persistence.

Returns:
modifiable unordered list of all aggregations in this aggregate snapshot; list is non-null and possibly empty

getAggregation

public Aggregation getAggregation(java.lang.String name)
Gets the aggregation with the given name if it exists in this aggregate snapshot.

Parameters:
name - the name of the desired aggregation, or empty string to request the unnamed aggregation. In D, the unnamed aggregation is used anytime a name does not follow the aggregation symbol '@', for example:
          @ = count();
as opposed to
          @counts = count()
resulting in an Aggregation with the name "counts".
Returns:
null if no aggregation by the given name exists in this aggregate
See Also:
Aggregation.getName()

getRecords

public java.util.List<AggregationRecord> getRecords()
Gets an unordered list of this aggregate's records. The list is sortable using Collections.sort(List list, Comparator c) with any user-defined ordering. Modifying the returned list has no effect on this aggregate.

Returns:
a newly created list that copies this aggregate's records by reference in no particular order

getOrderedRecords

public java.util.List<AggregationRecord> getOrderedRecords()
Gets an ordered list of this aggregate's records sequenced by their ordinal property. Note that the unordered list returned by getRecords() can easily be sorted by any arbitrary criteria, for example by key ascending:

 List  records = aggregate.getRecords();
 Collections.sort(records, new Comparator <AggregationRecord> () {
        public int compare(AggregationRecord r1, AggregationRecord r2) {
                return r1.getTuple().compareTo(r2.getTuple());
        }
 });
 
Use getOrderedRecords() instead of getRecords() when you want to list records as they would be ordered by dtrace(1M).

Returns:
a newly created list of this aggregate's records in the order used by the native DTrace library

asMap

public java.util.Map<java.lang.String,Aggregation> asMap()
Gets a read-only Map view of this aggregate.

Returns:
a read-only Map view of this aggregate keyed by aggregation name

toString

public java.lang.String toString()
Gets a string representation of this aggregate snapshot useful for logging and not intended for display. The exact details of the representation are unspecified and subject to change, but the following format may be regarded as typical:

 class-name[property1 = value1, property2 = value2]
 

Overrides:
toString in class java.lang.Object