You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Mike Measel <mm...@wilytech.com> on 2005/08/26 14:59:12 UTC

No listener in batch (non-gui) mode

I'm using a custom listener to send results to another application.  
When I start a test plan in non-gui mode, the listener doesn't seem to 
be getting called.  Is this expected behavior?  Is it possible to create 
a listener that does get called in non-gui mode or am I missing 
something simple?

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: No listener in batch (non-gui) mode

Posted by Michael Stover <ms...@apache.org>.
I think I understand.  What you have here is a Gui element - this
element is never involved in a non-gui run.  You've put your recording
logic here, and it's never reached.

What you want to do instead is subclass ResultCollector with the
recordXXX() logic.  Keep this GUI class strictly GUI.

-Mike

On Fri, 2005-08-26 at 13:57 -0500, Mike Measel wrote:
> Here's the listener code.  I've tested it several times today and the 
> only difference seems to be
> that if I use the -n switch, the listener doesn't fire.  I can run same 
> remote test in gui mode and
> it works.
> 
> 
> package com.wily.jmeter;
> 
> import java.awt.BorderLayout;
> 
> import org.apache.jmeter.samplers.Clearable;
> import org.apache.jmeter.samplers.SampleResult;
> import org.apache.jmeter.util.JMeterUtils;
> import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
> import com.wily.introscope.agent.api.*;
> 
> public class WilyListener
>     extends AbstractVisualizer
>     implements Clearable
> {
>     /****************************************
>      * Create the WilyListener.
>      ***************************************/
>     public WilyListener()
>     {
>         init();
>         setName(getStaticLabel());
>     }
> 
> 
>     /****************************************
>      * Reurns the name of this component to be used by the GUI.
>      *@return the name of this component
>      ***************************************/
>     public String getStaticLabel()
>     {
>         return "Wily Data Listener";
>     }
> 
> 
>     /**
>         Initialize the component in the UI
>     **/
>     private void init()
>     {
>         setLayout(new BorderLayout());
>         setBorder(makeBorder());
>         add(makeTitlePanel(), BorderLayout.NORTH);
>     }
> 
> 
>     /**
>         Does nothing, but required by interface.
>     **/
>     public void clear()
>     {
>     }
> 
> 
>     /**
>         Called for each sample to record test results.
>         @param sample ignored
>     **/
>     public void add(SampleResult sample)
>     {
>     StringBuffer metricName=new StringBuffer(sample.getThreadName());
>     metricName.append("|");
>     metricName.append(sample.getSampleLabel());
> 
>     recordResponseTime
>         (metricName+":Average Response Time (ms)",sample.getTime());
>     recordRate(metricName+":Responses Per Second");
> 
>     metricName.append(":Reponse Count (");
>     metricName.append(sample.getResponseCode());
>     metricName.append(")");
> 
>     recordCount(metricName.toString());
>     }
> 
> 
>     // Following are the record methods for hooking into introscope...
> 
>     java.util.Hashtable avgRespRecorders = new java.util.Hashtable();
>     public void recordResponseTime(String name, long i)
>     {
>     try {
>         LongAverageDataRecorder recorder =
>         (LongAverageDataRecorder)avgRespRecorders.get(name);
>         if (recorder==null) {
>         recorder =
>             DataRecorderFactory.createLongAverageDataRecorder(name);
>         avgRespRecorders.put(name,recorder);
>         }
>         recorder.recordDataPoint(i);
>     }
>     catch(Exception ive) {
>         ive.printStackTrace();
>     }
>     }
> 
> 
>     java.util.Hashtable rateRecorders = new java.util.Hashtable();
>     public void recordRate(String name)
>     {
>     try {
>         IntRateDataRecorder recorder =
>         (IntRateDataRecorder)rateRecorders.get(name);
>         if (recorder==null) {
>         recorder =
>             DataRecorderFactory.createIntRateDataRecorder(name);
>         rateRecorders.put(name,recorder);
>         }
>         recorder.recordIncident();
>     }
>     catch(Exception ive) {
>         ive.printStackTrace();
>     }
>     }
> 
>     java.util.Hashtable countRecorders = new java.util.Hashtable();
>     public void recordCount(String name)
>     {
>     try {
>         IntCounterDataRecorder recorder =
>         (IntCounterDataRecorder)countRecorders.get(name);
>         if (recorder==null) {
>         recorder =
>             DataRecorderFactory.createIntCounterDataRecorder(name);
>         recorder.recordCurrentValue(0);
>         countRecorders.put(name,recorder);
>         }
>         recorder.add(1);
>     }
>     catch(Exception ive) {
>         ive.printStackTrace();
>     }
>     }
> }
> 
> Michael Stover wrote:
> 
> >Listeners that are part of the test plan do get called in non-gui mode.
> >Are you getting errors in the jmeter.log when you run this way?  Also,
> >if you don't follow the rules closely, your listener may not be getting
> >loaded correctly in non-gui mode.  Debugging might require letting us
> >see your code.
> >
> >-Mike
> >
> >On Fri, 2005-08-26 at 07:59 -0500, Mike Measel wrote:
> >  
> >
> >>I'm using a custom listener to send results to another application.  
> >>When I start a test plan in non-gui mode, the listener doesn't seem to 
> >>be getting called.  Is this expected behavior?  Is it possible to create 
> >>a listener that does get called in non-gui mode or am I missing 
> >>something simple?
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >>    
> >>
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >  
> >


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: No listener in batch (non-gui) mode

Posted by Mike Measel <mm...@wilytech.com>.
Here's the listener code.  I've tested it several times today and the 
only difference seems to be
that if I use the -n switch, the listener doesn't fire.  I can run same 
remote test in gui mode and
it works.


package com.wily.jmeter;

import java.awt.BorderLayout;

import org.apache.jmeter.samplers.Clearable;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
import com.wily.introscope.agent.api.*;

public class WilyListener
    extends AbstractVisualizer
    implements Clearable
{
    /****************************************
     * Create the WilyListener.
     ***************************************/
    public WilyListener()
    {
        init();
        setName(getStaticLabel());
    }


    /****************************************
     * Reurns the name of this component to be used by the GUI.
     *@return the name of this component
     ***************************************/
    public String getStaticLabel()
    {
        return "Wily Data Listener";
    }


    /**
        Initialize the component in the UI
    **/
    private void init()
    {
        setLayout(new BorderLayout());
        setBorder(makeBorder());
        add(makeTitlePanel(), BorderLayout.NORTH);
    }


    /**
        Does nothing, but required by interface.
    **/
    public void clear()
    {
    }


    /**
        Called for each sample to record test results.
        @param sample ignored
    **/
    public void add(SampleResult sample)
    {
    StringBuffer metricName=new StringBuffer(sample.getThreadName());
    metricName.append("|");
    metricName.append(sample.getSampleLabel());

    recordResponseTime
        (metricName+":Average Response Time (ms)",sample.getTime());
    recordRate(metricName+":Responses Per Second");

    metricName.append(":Reponse Count (");
    metricName.append(sample.getResponseCode());
    metricName.append(")");

    recordCount(metricName.toString());
    }


    // Following are the record methods for hooking into introscope...

    java.util.Hashtable avgRespRecorders = new java.util.Hashtable();
    public void recordResponseTime(String name, long i)
    {
    try {
        LongAverageDataRecorder recorder =
        (LongAverageDataRecorder)avgRespRecorders.get(name);
        if (recorder==null) {
        recorder =
            DataRecorderFactory.createLongAverageDataRecorder(name);
        avgRespRecorders.put(name,recorder);
        }
        recorder.recordDataPoint(i);
    }
    catch(Exception ive) {
        ive.printStackTrace();
    }
    }


    java.util.Hashtable rateRecorders = new java.util.Hashtable();
    public void recordRate(String name)
    {
    try {
        IntRateDataRecorder recorder =
        (IntRateDataRecorder)rateRecorders.get(name);
        if (recorder==null) {
        recorder =
            DataRecorderFactory.createIntRateDataRecorder(name);
        rateRecorders.put(name,recorder);
        }
        recorder.recordIncident();
    }
    catch(Exception ive) {
        ive.printStackTrace();
    }
    }

    java.util.Hashtable countRecorders = new java.util.Hashtable();
    public void recordCount(String name)
    {
    try {
        IntCounterDataRecorder recorder =
        (IntCounterDataRecorder)countRecorders.get(name);
        if (recorder==null) {
        recorder =
            DataRecorderFactory.createIntCounterDataRecorder(name);
        recorder.recordCurrentValue(0);
        countRecorders.put(name,recorder);
        }
        recorder.add(1);
    }
    catch(Exception ive) {
        ive.printStackTrace();
    }
    }
}

Michael Stover wrote:

>Listeners that are part of the test plan do get called in non-gui mode.
>Are you getting errors in the jmeter.log when you run this way?  Also,
>if you don't follow the rules closely, your listener may not be getting
>loaded correctly in non-gui mode.  Debugging might require letting us
>see your code.
>
>-Mike
>
>On Fri, 2005-08-26 at 07:59 -0500, Mike Measel wrote:
>  
>
>>I'm using a custom listener to send results to another application.  
>>When I start a test plan in non-gui mode, the listener doesn't seem to 
>>be getting called.  Is this expected behavior?  Is it possible to create 
>>a listener that does get called in non-gui mode or am I missing 
>>something simple?
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>  
>

Re: No listener in batch (non-gui) mode

Posted by Michael Stover <ms...@apache.org>.
Listeners that are part of the test plan do get called in non-gui mode.
Are you getting errors in the jmeter.log when you run this way?  Also,
if you don't follow the rules closely, your listener may not be getting
loaded correctly in non-gui mode.  Debugging might require letting us
see your code.

-Mike

On Fri, 2005-08-26 at 07:59 -0500, Mike Measel wrote:
> I'm using a custom listener to send results to another application.  
> When I start a test plan in non-gui mode, the listener doesn't seem to 
> be getting called.  Is this expected behavior?  Is it possible to create 
> a listener that does get called in non-gui mode or am I missing 
> something simple?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org