Class ResultCollector

  • All Implemented Interfaces:
    java.io.Serializable , java.lang.Cloneable , org.apache.jmeter.engine.util.NoThreadClone , org.apache.jmeter.gui.Searchable , org.apache.jmeter.samplers.Clearable , org.apache.jmeter.samplers.Remoteable , org.apache.jmeter.samplers.SampleListener , org.apache.jmeter.testelement.TestElement , org.apache.jmeter.testelement.TestStateListener

    
    public class ResultCollector
    extends AbstractListenerElement implements SampleListener, Clearable, Serializable, TestStateListener, Remoteable, NoThreadClone
                        

    This class handles all saving of samples. The class must be thread-safe because it is shared between threads (NoThreadClone).

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Object clone()
      String getFilename() Get the filename of the file this collector uses
      boolean isErrorLogging() Get the state of error logging
      final void setErrorLogging(boolean errorLogging) Sets error logging flag
      final void setSuccessOnlyLogging(boolean value) Sets the flag whether only successful samples should be logged
      boolean isSuccessOnlyLogging() Get the state of successful only logging
      boolean isSampleWanted(boolean success) Decides whether or not to a sample is wanted based on:
      • errorOnly
      • successOnly
      • sample success
      Should only be called for single samples.
      static boolean isSampleWanted(boolean success, boolean errorOnly, boolean successOnly) Decides whether or not to a sample is wanted based on:
      • errorOnly
      • successOnly
      • sample success
      This version is intended to be called by code that loops over many samples; it is cheaper than fetching the settings each time.
      void setFilename(String f) Sets the filename attribute of the ResultCollector object.
      void testEnded(String host) Called once for all threads after the end of a test.
      void testStarted(String host) Called just before the start of the test from the main engine thread.
      void testEnded() Called once for all threads after the end of a test.
      void testStarted() Called just before the start of the test from the main engine thread.
      void loadExistingFile() Loads an existing sample data (JTL) file.
      void sampleStarted(SampleEvent e) A sample has started.
      void sampleStopped(SampleEvent e) A sample has stopped.
      void sampleOccurred(SampleEvent event) When a test result is received, display it and save it.
      void flushFile() Flush PrintWriter to synchronize file contents
      SampleSaveConfiguration getSaveConfig()
      void setSaveConfig(SampleSaveConfiguration saveConfig)
      void clearData() Clears the current data of the object.
      • Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

        addTestElement, canRemove, clear, clearTestElementChildren, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getPropertyOrNull, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse
      • Methods inherited from class org.apache.jmeter.reporters.AbstractListenerElement

        setListener
      • Methods inherited from class org.apache.jmeter.testelement.TestElement

        addTestElement, canRemove, clear, clearTestElementChildren, clone, get, get, get, get, get, get, get, get, get, getComment, getName, getOrCreate, getOrCreate, getOrNull, getOrNull, getOrNull, getProperty, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyOrNull, getProps, getSchema, getString, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, removed, set, setComment, setEnabled, setName, setProperty, setTemporary, traverse
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResultCollector

        ResultCollector()
        No-arg constructor.
    • Method Detail

      • getFilename

         String getFilename()

        Get the filename of the file this collector uses

        Returns:

        The name of the file

      • isErrorLogging

         boolean isErrorLogging()

        Get the state of error logging

        Returns:

        Flag whether errors should be logged

      • setErrorLogging

         final void setErrorLogging(boolean errorLogging)

        Sets error logging flag

        Parameters:
        errorLogging - The flag whether errors should be logged
      • setSuccessOnlyLogging

         final void setSuccessOnlyLogging(boolean value)

        Sets the flag whether only successful samples should be logged

        Parameters:
        value - The flag whether only successful samples should be logged
      • isSuccessOnlyLogging

         boolean isSuccessOnlyLogging()

        Get the state of successful only logging

        Returns:

        Flag whether only successful samples should be logged

      • isSampleWanted

         boolean isSampleWanted(boolean success)

        Decides whether or not to a sample is wanted based on:

        • errorOnly
        • successOnly
        • sample success
        Should only be called for single samples.
        Parameters:
        success - is sample successful
        Returns:

        whether to log/display the sample

      • isSampleWanted

         static boolean isSampleWanted(boolean success, boolean errorOnly, boolean successOnly)

        Decides whether or not to a sample is wanted based on:

        • errorOnly
        • successOnly
        • sample success
        This version is intended to be called by code that loops over many samples; it is cheaper than fetching the settings each time.
        Parameters:
        success - status of sample
        errorOnly - if errors only wanted
        successOnly - if success only wanted
        Returns:

        whether to log/display the sample

      • setFilename

         void setFilename(String f)

        Sets the filename attribute of the ResultCollector object.

        Parameters:
        f - the new filename value
      • testEnded

         void testEnded(String host)

        Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

        N.B. testStarted() and testEnded() are called from different threads.

        Parameters:
        host - name of host
      • testStarted

         void testStarted(String host)

        Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

        N.B. testStarted() and testEnded() are called from different threads.

        Parameters:
        host - name of host
      • testEnded

         void testEnded()

        Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

        N.B. testStarted() and testEnded() are called from different threads.

      • testStarted

         void testStarted()

        Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

        N.B. testStarted() and testEnded() are called from different threads.

      • loadExistingFile

         void loadExistingFile()

        Loads an existing sample data (JTL) file. This can be one of:

        • XStream format
        • CSV format
      • sampleOccurred

         void sampleOccurred(SampleEvent event)

        When a test result is received, display it and save it.

        Parameters:
        event - the sample event that was received
      • flushFile

         void flushFile()

        Flush PrintWriter to synchronize file contents

      • clearData

         void clearData()

        Clears the current data of the object.