2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A *
2N/A * ident "%Z%%M% %I% %E% SMI"
2N/A */
2N/Apackage org.opensolaris.os.dtrace;
2N/A
2N/Aimport java.util.EventListener;
2N/A
2N/A/**
2N/A * Listener for data generated by a single DTrace {@link Consumer}.
2N/A *
2N/A * @author Tom Erickson
2N/A */
2N/Apublic interface ConsumerListener extends EventListener {
2N/A /**
2N/A * Called whenever a DTrace probe fires (that is, once for each
2N/A * instance of {@link ProbeData} generated by DTrace). Identifies
2N/A * the probe and provides data generated by the probe's actions. To
2N/A * terminate the consumer in the event of unexpected data, throw a
2N/A * {@link ConsumerException} from this method.
2N/A *
2N/A * @throws ConsumerException if the implementation should terminate
2N/A * the running consumer
2N/A */
2N/A public void dataReceived(DataEvent e) throws ConsumerException;
2N/A
2N/A /**
2N/A * Called when traced data is dropped because of inadequate buffer
2N/A * space. To terminate the consumer in the event of a drop, throw
2N/A * a {@link ConsumerException} from this method.
2N/A *
2N/A * @throws ConsumerException if the implementation should terminate
2N/A * the running consumer
2N/A */
2N/A public void dataDropped(DropEvent e) throws ConsumerException;
2N/A
2N/A /**
2N/A * Called when an error is encountered in the native DTrace library
2N/A * while tracing probe data. To terminate the consumer, throw a
2N/A * {@link ConsumerException} from this method.
2N/A *
2N/A * @throws ConsumerException if the implementation should terminate
2N/A * the running consumer
2N/A */
2N/A public void errorEncountered(ErrorEvent e) throws ConsumerException;
2N/A
2N/A /**
2N/A * Called when the state of a target process changes. To terminate
2N/A * the consumer in the event of unexpected process state, throw a
2N/A * {@link ConsumerException} from this method.
2N/A *
2N/A * @throws ConsumerException if the implementation should terminate
2N/A * the running consumer
2N/A * @see Consumer#createProcess(String command)
2N/A * @see Consumer#grabProcess(int pid)
2N/A */
2N/A public void processStateChanged(ProcessEvent e) throws ConsumerException;
2N/A
/**
* Called once when the source {@link Consumer} is successfully
* started in response to {@link Consumer#go()}.
*
* @see #consumerStopped(ConsumerEvent e)
*/
public void consumerStarted(ConsumerEvent e);
/**
* Called once when the source {@link Consumer} is stopped,
* indicating that this listener should expect no further events.
* Guaranteed to be called whether the consumer was stopped by
* request (by calling {@link Consumer#stop()} or {@link
* Consumer#abort()}), terminated normally as a result of the DTrace
* {@code exit()} action (see <a
* href=http://docs.sun.com/app/docs/doc/817-6223/6mlkidlhm?a=view>
* <tt>exit()</tt></a> in the <b>Special Actions</b> section of the
* <b>Actions and Subroutines</b> chapter of the <i>Solaris Dynamic
* Tracing Guide</i>) or after the completion of all target
* processes, or terminated abnormally because of an exception. It
* is necessary to call {@link Consumer#close()} to release any
* system resources still held by the stopped consumer.
*
* @see #consumerStarted(ConsumerEvent e)
*/
public void consumerStopped(ConsumerEvent e);
/**
* Called when the source {@link Consumer} wakes up to process its
* buffer of traced probe data.
*
* @see #intervalEnded(ConsumerEvent e)
*/
public void intervalBegan(ConsumerEvent e);
/**
* Called when the source {@link Consumer} finishes processing its
* buffer of traced probe data and is about to sleep until the next
* interval. The rate of consumption may be controlled with the
* {@link Option#switchrate switchrate} and {@link Option#aggrate
* aggrate} options (see {@link Consumer#setOption(String option,
* String value)}).
*
* @see #intervalBegan(ConsumerEvent e)
*/
public void intervalEnded(ConsumerEvent e);
}