Apache JMeter
2.0.1.20050615

org.apache.jmeter.threads
Class ListenerNotifier

java.lang.Object
  extended byorg.apache.jmeter.threads.ListenerNotifier

public class ListenerNotifier
extends Object

The ListenerNotifier thread is responsible for performing asynchronous notifications that a sample has occurred. Each time a sample occurs, the addLast method should be called to add the sample and its list of listeners to the notification queue. This thread will then notify those listeners asynchronously at some future time.

In the current implementation, the notifications will be made in batches, with 2 seconds between the beginning of successive batches. If the notifier thread starts to get behind, the priority of the thread will be increased in an attempt to help it to keep up.

Version:
$Revision: 1.16 $
See Also:
SampleListener

Constructor Summary
ListenerNotifier()
           
 
Method Summary
 void addLast(SampleEvent item, List listeners)
          Add a new sample event to the notification queue.
 boolean isStopped()
          Indicates whether or not the thread has stopped.
 void notifyListeners(SampleEvent res, List listeners)
          Notify a list of listeners that a sample has occurred.
 void run()
          Process the events in the notification queue until the thread has been told to stop and the notification queue is empty.
 void stop()
          Stops the ListenerNotifier thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListenerNotifier

public ListenerNotifier()
Method Detail

stop

public void stop()
Stops the ListenerNotifier thread. The thread will continue processing any events remaining in the notification queue before it actually stops, but this method will return immediately.


isStopped

public boolean isStopped()
Indicates whether or not the thread has stopped. This will not return true until the stop method has been called and any remaining notifications in the queue have been completed.

Returns:
true if the ListenerNotifier has completely stopped, false otherwise

run

public void run()
Process the events in the notification queue until the thread has been told to stop and the notification queue is empty.

In the current implementation, this method will iterate continually until the thread is told to stop. In each iteration it will process any notifications that are in the queue at the beginning of the iteration, and then will sleep until it is time to start the next batch. As long as the thread is keeping up, each batch should start 2 seconds after the beginning of the last batch. This exact behavior is subject to change.


notifyListeners

public void notifyListeners(SampleEvent res,
                            List listeners)
Notify a list of listeners that a sample has occurred.

Parameters:
res - the sample event that has occurred. Must be non-null.
listeners - a list of the listeners which should be notified. This list must not be null and must contain only SampleListener elements.

addLast

public void addLast(SampleEvent item,
                    List listeners)
Add a new sample event to the notification queue. The notification will be performed asynchronously and this method will return immediately.

Parameters:
item - the sample event that has occurred. Must be non-null.
listeners - a list of the listeners which should be notified. This list must not be null and must contain only SampleListener elements.

Apache JMeter
2.0.1.20050615

Copyright © 1998-2005 Apache Software Foundation. All Rights Reserved.