/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* ident "%Z%%M% %I% %E% SMI"
*/
/**
* Detail about one or more records dropped by DTrace (not reported to
* {@link ConsumerListener#dataReceived(DataEvent e)
* ConsumerListener.dataReceived()}) due to inadequte buffer space.
* <p>
* Immutable. Supports persistence using {@link java.beans.XMLEncoder}.
*
* @see ConsumerListener#dataDropped(DropEvent e)
*
* @author Tom Erickson
*/
static {
try {
"defaultMessage"})
{
protected Expression
{
}
};
} catch (IntrospectionException e) {
e.printStackTrace();
}
}
/**
* Indicates what kind of buffer space experienced the data drop
* (such as principal buffer or aggregation buffer) and possibly a
* reason.
*/
public enum Kind {
/** Drop to principal buffer */
/** Drop to aggregation buffer */
/** Dynamic drop */
/** Dynamic drop due to rinsing */
/** Dynamic drop due to dirtiness */
/** Speculative drop */
/** Speculative drop due to business */
/** Speculative drop due to unavailability */
/** Stack string table overflow */
/** Error in ERROR probe */
/** Unrecognized value from native DTrace library */
private String s;
private
{
s = displayString;
}
/**
* Overridden to get the default display value. To
* internationalize the display value, use {@link Enum#name()}
* instead as an I18N lookup key.
*/
public String
toString()
{
return s;
}
}
/** @serial */
private final int cpu;
/** @serial */
/** @serial */
private final long count;
/** @serial */
private final long total;
/** @serial */
/**
* Creates a {@code Drop} instance with the given CPU, drop kind,
* drop counts, and default message. Supports XML persistence.
*
* @param dropCPU cpu where drops occurred
* @param dropKindName name of enumeration value indicating the kind
* of buffer space where the drop occurred and possibly a reason
* @param dropCount number of drops
* @param totalDrops total number of drops since the source {@link
* Consumer} started running
* @param defaultDropMessage drop message provided by DTrace
* @throws IllegalArgumentException if there is no {@code Drop.Kind}
* value with the given name or if {@code dropCount} or {@code
* totalDrops} is negative
* @throws NullPointerException if the given {@code Drop.Kind} name
* or default message is {@code null}
*/
public
{
total = totalDrops;
validate();
}
private final void
validate()
{
if (count < 0) {
throw new IllegalArgumentException("count is negative");
}
if (total < 0) {
throw new IllegalArgumentException("total is negative");
}
if (defaultMessage == null) {
throw new NullPointerException("default message is null");
}
}
/**
* Gets the CPU where the drops occurred.
*
* @return non-negative CPU ID, or a negative number if the CPU is
* unknown
*/
public int
getCPU()
{
return cpu;
}
/**
* Gets the kind of drop for all drops included in {@link
* #getCount()}.
*
* @return non-null drop kind
*/
public Kind
getKind()
{
return kind;
}
/**
* Gets the number of drops reported by this {@code Drop} instance.
*
* @return non-negative drop count
*/
public long
getCount()
{
return count;
}
/**
* Gets the total number of drops since the source {@link Consumer}
* started running.
*
* @return non-negative drop total since tracing started
*/
public long
getTotal()
{
return total;
}
/**
* Gets the message provided by DTrace.
*
* @return non-null message provided by DTrace
*/
public String
{
return defaultMessage;
}
private void
throws IOException, ClassNotFoundException
{
s.defaultReadObject();
// check class invariants
try {
validate();
} catch (Exception e) {
e.getMessage());
x.initCause(e);
throw x;
}
}
/**
* Gets a string representation of this drop instance, 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:
* <pre><code>
* class-name[property1 = value1, property2 = value2]
* </code></pre>
*/
public String
toString()
{
}
}