mstover1    2003/03/11 11:04:19

  Modified:    bin      jmeter.bat jmeter.properties
               src/components/org/apache/jmeter/visualizers
                        AssertionVisualizer.java
               src/core/org/apache/jmeter/gui/action Remove.java
               src/core/org/apache/jmeter/reporters ResultCollector.java
               src/core/org/apache/jmeter/samplers SampleResult.java
               src/core/org/apache/jmeter/save SaveService.java
               src/core/org/apache/jmeter/threads ListenerNotifier.java
               src/core/org/apache/jmeter/util JMeterUtils.java
               src/protocol/http/org/apache/jmeter/protocol/http/sampler
                        HTTPSampler.java
  Log:
  patches from list members, other minor changes
  
  Revision  Changes    Path
  1.23      +1 -1      jakarta-jmeter/bin/jmeter.bat
  
  Index: jmeter.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/bin/jmeter.bat,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- jmeter.bat        25 Aug 2002 19:42:20 -0000      1.22
  +++ jmeter.bat        11 Mar 2003 19:04:18 -0000      1.23
  @@ -30,4 +30,4 @@
   rem This label provides a place for the argument list loop to break out 
   rem and for NT handling to skip to.
   
  -java -Xincgc -jar ApacheJMeter.jar %JMETER_CMD_LINE_ARGS%
  \ No newline at end of file
  +java -Xincgc -Xmx256m -jar ApacheJMeter.jar %JMETER_CMD_LINE_ARGS%
  \ No newline at end of file
  
  
  
  1.58      +1 -1      jakarta-jmeter/bin/jmeter.properties
  
  Index: jmeter.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/bin/jmeter.properties,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- jmeter.properties 14 Feb 2003 04:17:15 -0000      1.57
  +++ jmeter.properties 11 Mar 2003 19:04:18 -0000      1.58
  @@ -69,7 +69,7 @@
   #Logging levels for the logging categories in JMeter.  Correct values are 
FATAL_ERROR, ERROR, WARN, INFO, and DEBUG
   log_level.jmeter=WARN
   log_level.jmeter.engine=WARN
  -log_level.jmeter.gui=DEBUG
  +log_level.jmeter.gui=WARN
   log_level.jmeter.elements=WARN
   log_level.jmeter.util=WARN
   log_level.jmeter.util.classfinder=WARN
  
  
  
  1.7       +10 -12    
jakarta-jmeter/src/components/org/apache/jmeter/visualizers/AssertionVisualizer.java
  
  Index: AssertionVisualizer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/visualizers/AssertionVisualizer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AssertionVisualizer.java  3 Feb 2003 14:29:01 -0000       1.6
  +++ AssertionVisualizer.java  11 Mar 2003 19:04:18 -0000      1.7
  @@ -2,7 +2,7 @@
    * ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001,2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -116,7 +116,10 @@
        ***************************************/
       public void add(SampleResult sample)
       {
  -        textArea.append(sample.getSamplerData().toString());
  +        if(null != sample.getSamplerData())
  +            textArea.append(sample.getSamplerData().toString());
  +        else
  +            textArea.append(sample.getSampleLabel());
           textArea.append(getAssertionResult(sample));
           textArea.append("\n");
       }
  @@ -134,15 +137,10 @@
           if (res != null)
           {
               StringBuffer display = new StringBuffer();
  -            List assertionResults = Arrays.asList(res.getAssertionResults());
  -
  -            if (assertionResults != null)
  -            {
  -                Iterator iter = assertionResults.iterator();
  -
  -                while (iter.hasNext())
  -                {
  -                    AssertionResult item = (AssertionResult) iter.next();
  +            AssertionResult assertionResults[] = res.getAssertionResults();
  +            if (assertionResults != null) {
  +                for (int i = 0; i < assertionResults.length; i++) {
  +                    AssertionResult item = assertionResults[i];
   
                       if (item.isFailure() || item.isError())
                       {
  
  
  
  1.5       +7 -2      jakarta-jmeter/src/core/org/apache/jmeter/gui/action/Remove.java
  
  Index: Remove.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/action/Remove.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Remove.java       5 Feb 2003 05:12:07 -0000       1.4
  +++ Remove.java       11 Mar 2003 19:04:18 -0000      1.5
  @@ -105,12 +105,17 @@
                guiPackage.getTreeListener().removedSelectedNode();
                for (int i = nodes.length - 1; i >= 0; i--)
                {
  -                             
guiPackage.getTreeModel().removeNodeFromParent(nodes[i]);
  -                             guiPackage.removeNode(nodes[i].createTestElement());
  +                             removeNode(nodes[i]);
                }
                guiPackage.getTreeListener().getJTree().setSelectionRow(1);
   
        }
  +
  +    public static void removeNode(JMeterTreeNode node)
  +    {
  +        GuiPackage.getInstance().getTreeModel().removeNodeFromParent(node);
  +        GuiPackage.getInstance().removeNode(node.createTestElement());
  +    }
        static
        {
                commands.add("remove");
  
  
  
  1.14      +6 -3      
jakarta-jmeter/src/core/org/apache/jmeter/reporters/ResultCollector.java
  
  Index: ResultCollector.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/reporters/ResultCollector.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ResultCollector.java      5 Feb 2003 19:45:56 -0000       1.13
  +++ ResultCollector.java      11 Mar 2003 19:04:18 -0000      1.14
  @@ -395,8 +395,11 @@
               {
                   if (SaveService.getOutputFormat() == SaveService.SAVE_AS_CSV)
                   {
  -                    String savee = SaveService.resultToDelimitedString(result);
  -                    out.println(savee);
  +                    if (out != null) {
  +                        String savee =
  +                                SaveService.resultToDelimitedString(result);
  +                        out.println(savee);
  +                    }
                   }
                   // Save results as XML
                   else
  
  
  
  1.5       +49 -70    
jakarta-jmeter/src/core/org/apache/jmeter/samplers/SampleResult.java
  
  Index: SampleResult.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/samplers/SampleResult.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SampleResult.java 20 Feb 2003 02:59:15 -0000      1.4
  +++ SampleResult.java 11 Mar 2003 19:04:18 -0000      1.5
  @@ -2,7 +2,7 @@
    *  ====================================================================
    *  The Apache Software License, Version 1.1
    *
  - *  Copyright (c) 2001 The Apache Software Foundation.  All rights
  + *  Copyright (c) 2001,2003 The Apache Software Foundation.  All rights
    *  reserved.
    *
    *  Redistribution and use in source and binary forms, with or without
  @@ -77,11 +77,22 @@
    */
   public class SampleResult implements Serializable
   {
  -     //public final static String URL = "sampler.url";
  -
  -     public final static String TAG_NAME = "sampleResult";
  +    /**
  +     * Data type value indicating that the response data is text.
  +     *
  +     * @see #getDataType
  +     * @see #setDataType(java.lang.String)
  +     */
        public final static String TEXT = "text";
  +
  +    /**
  +     * Data type value indicating that the response data is binary.
  +     *
  +     * @see #getDataType
  +     * @see #setDataType(java.lang.String)
  +     */
        public final static String BINARY = "bin";
  +
        private byte[] responseData;
        private String responseCode;
        private String label;
  @@ -89,65 +100,30 @@
        private String threadName;
        private String responseMessage;
        private long timeStamp = 0;
  -     private List assertionResults = new ArrayList();
  -     private List subResults = new ArrayList();
  +     private List assertionResults;
  +     private List subResults;
        private String dataType;
        private boolean success;
  -     private boolean mark = false;
  -     private Set files = new HashSet();
  +     private Set files;
       private String dataEncoding;
  -     
  -
  -     Map map;
  -     long time;
  -     /**
  -      *  Description of the Field
  -      */
  -     private final static String SAMPLE_LABEL = "displayName";
  -     private final static String SAMPLER_CONFIG = "samplerConfig";
  -     private final static String DATA_TYPE = "dataType";
  -     private final static String RESPONSE_CODE = "responseCode";
  -     private final static String RESPONSE_MESSAGE = "responseMessage";
  -     private final static String THREAD_NAME = "threadName";
  -     private final static String TIME_STAMP = "timeStamp";
  -     /**
  -      *  Description of the Field
  -      */
  -     private final static String ASSERTION_RESULTS = "assertionResults";
  -     /**
  -      *  Description of the Field
  -      */
  -     private final static String RESPONSE_DATA = "responseData";
  -     /**
  -      *  Description of the Field
  -      */
  -     private final static String SUCCESS = "success";
  +    private long time;
   
  -     /**
  -      *  Description of the Field
  -      */
        private final static String TOTAL_TIME = "totalTime";
   
        transient private static Logger log = 
Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.engine");
   
   
  -     /**
  -      *  !ToDo (Constructor description)
  -      */
  -     public SampleResult()
  -     {
  -             map = new HashMap();
  -             time = 0;
  -     }
  -     
        public void setMarked(String filename)
        {
  +        if (files == null) {
  +            files = new HashSet();
  +        }
                files.add(filename);
        }
        
        public boolean isMarked(String filename)
        {
  -             return files.contains(filename);
  +        return files != null && files.contains(filename);
        }       
        
        public String getResponseCode()
  @@ -202,29 +178,48 @@
   
        public void addAssertionResult(AssertionResult assertResult)
        {
  +        if (assertionResults == null) {
  +            assertionResults = new ArrayList();
  +        }
                assertionResults.add(assertResult);
        }
   
  +    /**
  +     * Gets the assertion results associated with this sample.
  +     *
  +     * @return an array containing the assertion results for this sample.
  +     *         Returns null if there are no assertion results.
  +     */
        public AssertionResult[] getAssertionResults()
        {
  +        if (assertionResults == null) {
  +            return null;
  +        }
                return (AssertionResult[])assertionResults.toArray(new 
AssertionResult[0]);
        }
   
        public void addSubResult(SampleResult subResult)
        {
  +        if (subResults == null) {
  +            subResults = new ArrayList();
  +        }
                subResults.add(subResult);
        }
   
  +    /**
  +     * Gets the subresults associated with this sample.
  +     *
  +     * @return an array containing the subresults for this sample. Returns
  +     *         null if there are no subresults.
  +     */
        public SampleResult[] getSubResults()
        {
  +        if (subResults == null) {
  +            return null;
  +        }
                return (SampleResult[])subResults.toArray(new SampleResult[0]);
        }
   
  -     /**
  -      *  Description of the Method
  -      *
  -      [EMAIL PROTECTED]  info  Description of the Parameter
  -      */
        public void configure(Configuration info)
        {
                setTime(info.getAttributeAsLong(TOTAL_TIME,0L));
  @@ -248,9 +243,6 @@
        public void setResponseData(byte[] response)
        {
                responseData = response;
  -             /*DefaultConfiguration responseChild = new 
DefaultConfiguration(RESPONSE_DATA, "");
  -             responseChild.setValue(getHexString(response));
  -             addChild(responseChild);*/
        }
   
        
  @@ -264,14 +256,6 @@
        public byte[] getResponseData()
        {
                return responseData;
  -             /*Configuration responseChild = getChild(RESPONSE_DATA);
  -             ByteArrayOutputStream bytes = new ByteArrayOutputStream();
  -             String res = responseChild.getValue("");
  -             for (int i = 0; i < res.length(); i+=2)
  -             {
  -                     bytes.write(Integer.parseInt(res.substring(i,i+2),16));
  -             }
  -             return bytes.toByteArray();*/
        }
   
        public void setSamplerData(TestElement s)
  @@ -294,11 +278,6 @@
                return time;
        }
   
  -     /**
  -      *  !ToDoo (Method description)
  -      *
  -      [EMAIL PROTECTED]    !ToDo (Return description)
  -      */
        public boolean isSuccessful()
        {
                return success;
  
  
  
  1.17      +18 -11    jakarta-jmeter/src/core/org/apache/jmeter/save/SaveService.java
  
  Index: SaveService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/save/SaveService.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- SaveService.java  21 Feb 2003 16:33:39 -0000      1.16
  +++ SaveService.java  11 Mar 2003 19:04:18 -0000      1.17
  @@ -561,9 +561,11 @@
   
           SampleResult[] subResults = result.getSubResults();
   
  -        for (int i = 0; i < subResults.length; i++)
  -        {
  -            config.addChild(getConfiguration(subResults[i], funcTest));
  +        if (subResults != null) {
  +            for (int i = 0; i < subResults.length; i++)
  +            {
  +                config.addChild(getConfiguration(subResults[i], funcTest));
  +            }
           }
   
           AssertionResult[] assResults = result.getAssertionResults();
  @@ -571,9 +573,11 @@
           if (funcTest)
           {
               config.addChild(getConfigForTestElement(null, result.getSamplerData()));
  -            for (int i = 0; i < assResults.length; i++)
  -            {
  -                config.addChild(getConfiguration(assResults[i]));
  +            if (assResults != null) {
  +                for (int i = 0; i < assResults.length; i++)
  +                {
  +                    config.addChild(getConfiguration(assResults[i]));
  +                }
               }
               config.addChild(getConfiguration(result.getResponseData()));
           }
  @@ -584,12 +588,15 @@
               if (assertionsResultsToSave == SAVE_ALL_ASSERTIONS)
               {
                   config.addChild(getConfigForTestElement(null, 
result.getSamplerData()));
  -                for (int i = 0; i < assResults.length; i++)
  -                {
  -                    config.addChild(getConfiguration(assResults[i]));
  +                if (assResults != null) {
  +                    for (int i = 0; i < assResults.length; i++)
  +                    {
  +                        config.addChild(getConfiguration(assResults[i]));
  +                    }
                   }
               }
               else if ((assertionsResultsToSave == SAVE_FIRST_ASSERTION)
  +                    && assResults != null
                       && assResults.length > 0)
               {
                   config.addChild(getConfiguration(assResults[0]));
  
  
  
  1.11      +227 -98   
jakarta-jmeter/src/core/org/apache/jmeter/threads/ListenerNotifier.java
  
  Index: ListenerNotifier.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/threads/ListenerNotifier.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ListenerNotifier.java     5 Feb 2003 05:12:09 -0000       1.10
  +++ ListenerNotifier.java     11 Mar 2003 19:04:19 -0000      1.11
  @@ -8,105 +8,234 @@
   import org.apache.jmeter.util.JMeterUtils;
   import org.apache.jorphan.logging.LoggingManager;
   import org.apache.log.Logger;
  +import org.apache.commons.collections.Buffer;
  +import org.apache.commons.collections.BufferUtils;
  +import org.apache.commons.collections.UnboundedFifoBuffer;
  +
   /**
  - * @author Administrator
  + * The <code>ListenerNotifier</code> thread is responsible for performing
  + * asynchronous notifications that a sample has occurred.  Each time a
  + * sample occurs, the <code>addLast</code> 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.
  + * <p>
  + * 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.
    *
  - * To change this generated comment edit the template variable "typecomment":
  - * Window>Preferences>Java>Templates.
  + * @see org.apache.jmeter.samplers.SampleListener
    */
  -public class ListenerNotifier extends LinkedList implements Runnable
  -{
  -     private static Logger log =
  -             LoggingManager.getLoggerFor(JMeterUtils.ENGINE);
  -     /**
  -      * @see java.lang.Runnable#run()
  -      */
  -     boolean running;
  -     boolean isStopped;
  -     static private int ABS_MAX = 500;
  -     static private int MAX = 200;
  -     int sleepTime = 2000;
  -     public ListenerNotifier()
  -     {
  -             super();
  -             running = true;
  -             isStopped = true;
  -     }
  -     public void run()
  -     {
  -             Iterator iter;
  -             while (running || this.size() > 1)
  -             {
  -                     SampleEvent res = (SampleEvent) this.removeFirst();
  -                     if (res != null)
  -                     {
  -                             List listeners = (List) this.removeFirst();
  -                             notifyListeners(res, listeners);
  -                     }
  -                     try
  -                     {
  -                             Thread.sleep(sleepTime);
  -                     }
  -                     catch (InterruptedException e)
  -                     {
  -                     }
  -                     if (size() > MAX && Thread.currentThread().getPriority() == 
Thread.NORM_PRIORITY)
  -                     {
  -                             log.debug("Notifier thread priority going from normal 
to max, size = "+size());
  -                             
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
  -                     }
  -             }
  -             log.debug("Listener Notifier stopped");
  -             isStopped = true;
  -     }
  -     private void notifyListeners(SampleEvent res, List listeners)
  -     {
  -             Iterator iter;
  -             iter = listeners.iterator();
  -             while (iter.hasNext())
  -             {
  -                     ((SampleListener) iter.next()).sampleOccurred(res);
  -             }
  -     }
  -     public boolean isStopped()
  -     {
  -             return isStopped;
  -     }
  -     public synchronized void addLast(SampleEvent item, List listeners)
  -     {
  -             if(size() > ABS_MAX)
  -             {
  -                     notifyListeners(item,listeners);                
  -             }
  -             else
  -             {
  -                     super.addLast(item);
  -                     super.addLast(listeners);
  -                     sleepTime = 0;
  -             }
  -     }
  -     public synchronized Object removeFirst()
  -     {
  -             try
  -             {
  -                     return super.removeFirst();
  -             }
  -             catch (RuntimeException e)
  -             {
  -                     sleepTime = 2000;
  -                     log.debug("Setting notifier thread priority to normal");
  -                     Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
  -                     return null;
  -             }
  -     }
  -     public void stop()
  -     {
  -             running = false;
  -     }
  -     public void start()
  -     {
  -             Thread noteThread = new Thread(this);
  -             noteThread.start();
  -             isStopped = false;
  -     }
  +public class ListenerNotifier implements Runnable {
  +    private static Logger log =
  +        LoggingManager.getLoggerFor(JMeterUtils.ENGINE);
  +
  +    /**
  +     * The number of milliseconds between batches of notifications.
  +     */
  +    private static final int SLEEP_TIME = 2000;
  +
  +    /**
  +     * Indicates whether or not this thread should remain running.  The
  +     * thread will continue running after this field is set to false until
  +     * the next batch of notifications has been completed and the
  +     * notification queue is empty.
  +     */
  +    private boolean running = true;
  +
  +    /**
  +     * Indicates whether or not this thread has stopped.  No further
  +     * notifications will be performed.
  +     */
  +    private boolean isStopped = true;
  +
  +    /**
  +     * The queue containing the notifications to be performed.  Each
  +     * notification consists of a pair of entries in this queue.  The
  +     * first is the [EMAIL PROTECTED] org.apache.jmeter.samplers.SampleEvent
  +     * SampleEvent} representing the sample.  The second is a List of
  +     * [EMAIL PROTECTED] org.apache.jmeter.samplers.SampleListener SampleListener}s
  +     * which should be notified.
  +     */
  +    private Buffer listenerEvents =
  +        BufferUtils.synchronizedBuffer(new UnboundedFifoBuffer());
  +
  +
  +    /**
  +     * Starts running the ListenerNotifier thread.
  +     */
  +    public void start() {
  +        isStopped = false;
  +        new Thread(this).start();
  +    }
  +
  +    /**
  +     * 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.
  +     */
  +    public void stop() {
  +        running = false;
  +    }
  +
  +    /**
  +     * Indicates whether or not the thread has stopped.  This will not
  +     * return true until the <code>stop</code> method has been called and
  +     * any remaining notifications in the queue have been completed.
  +     *
  +     * @return  true if the ListenerNotifier has completely stopped, false
  +     *          otherwise
  +     */
  +    public boolean isStopped() {
  +        return isStopped;
  +    }
  +
  +    /**
  +     * Process the events in the notification queue until the thread has
  +     * been told to stop and the notification queue is empty.
  +     * <p>
  +     * 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.
  +     */
  +    public void run() {
  +        boolean isMaximumPriority = false;
  +        int normalCount = 0;
  +
  +        while (running) {
  +            long startTime = System.currentTimeMillis();
  +            processNotifications();
  +            long sleep = SLEEP_TIME - (System.currentTimeMillis() - startTime);
  +
  +            // If the thread has been told to stop then we shouldn't sleep
  +            if (!running) {
  +                break;
  +            }
  +
  +            if (sleep < 0) {
  +                isMaximumPriority = true;
  +                normalCount = 0;
  +                if (log.isInfoEnabled()) {
  +                    log.info("ListenerNotifier exceeded maximum " +
  +                            "notification time by " + (-sleep) + "ms");
  +                }
  +                boostPriority();
  +            } else {
  +                normalCount++;
  +
  +                // If there have been three consecutive iterations since the
  +                // last iteration which took too long to execute, return the
  +                // thread to normal priority.
  +                if (isMaximumPriority && normalCount >= 3) {
  +                    isMaximumPriority = false;
  +                    unboostPriority();
  +                }
  +
  +                if (log.isDebugEnabled()) {
  +                    log.debug("ListenerNotifier sleeping for " + sleep + "ms");
  +                }
  +
  +                try {
  +                    Thread.sleep (sleep);
  +                } catch (InterruptedException e) {
  +                }
  +            }
  +        }
  +
  +        // Make sure that all pending notifications are processed before
  +        // actually ending the thread.
  +        processNotifications();
  +        isStopped = true;
  +    }
  +
  +    /**
  +     * Process all of the pending notifications.  Only the samples which are
  +     * in the queue when this method is called will be processed.  Any samples
  +     * added between the time when this method is called and when it exits are
  +     * saved for the next batch.
  +     */
  +    private void processNotifications() {
  +        int listenerEventsSize = listenerEvents.size();
  +        if (log.isDebugEnabled()) {
  +            log.debug ("ListenerNotifier: processing " + listenerEventsSize +
  +                    " events");
  +        }
  +
  +        while (listenerEventsSize > 0) {
  +            // Since this is a FIFO and this is the only place we remove
  +            // from it (only from a single thread) we don't have to remove
  +            // these two items in one atomic operation.  Each individual
  +            // remove is atomic (because we use a synchronized buffer),
  +            // which is necessary since the buffer can be accessed from
  +            // other threads (to add things to the buffer).
  +            SampleEvent res = (SampleEvent)listenerEvents.remove();
  +            List listeners = (List)listenerEvents.remove();
  +
  +            notifyListeners (res, listeners);
  +
  +            listenerEventsSize -= 2;
  +        }
  +    }
  +
  +    /**
  +     * Boost the priority of the current thread to maximum priority.  If
  +     * the thread is already at maximum priority then this will have no
  +     * effect.
  +     */
  +    private void boostPriority() {
  +        if (Thread.currentThread().getPriority() != Thread.MAX_PRIORITY) {
  +            log.info("ListenerNotifier: Boosting thread priority to maximum.");
  +            Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
  +        }
  +    }
  +
  +    /**
  +     * Return the priority of the current thread to normal.  If the thread
  +     * is already at normal priority then this will have no effect.
  +     */
  +    private void unboostPriority() {
  +        if (Thread.currentThread().getPriority() != Thread.NORM_PRIORITY) {
  +            log.info("ListenerNotifier: Returning thread priority to normal.");
  +            Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
  +        }
  +    }
  +
  +    /**
  +     * Notify a list of listeners that a sample has occurred.
  +     *
  +     * @param res       the sample event that has occurred.  Must be non-null.
  +     * @param listeners a list of the listeners which should be notified.
  +     *                  This list must not be null and must contain only
  +     *                  SampleListener elements.
  +     */
  +    private void notifyListeners(SampleEvent res, List listeners) {
  +        Iterator iter = listeners.iterator();
  +        while (iter.hasNext()) {
  +            ((SampleListener) iter.next()).sampleOccurred(res);
  +        }
  +    }
  +
  +    /**
  +     * Add a new sample event to the notification queue.  The notification
  +     * will be performed asynchronously and this method will return
  +     * immediately.
  +     *
  +     * @param item      the sample event that has occurred.  Must be non-null.
  +     * @param listeners a list of the listeners which should be notified.
  +     *                  This list must not be null and must contain only
  +     *                  SampleListener elements.
  +     */
  +    public void addLast(SampleEvent item, List listeners) {
  +        // Must use explicit synchronization here so that the item and
  +        // listeners are added together atomically
  +        synchronized (listenerEvents) {
  +            listenerEvents.add(item);
  +            listenerEvents.add(listeners);
  +        }
  +    }
   }
  
  
  
  1.18      +18 -1     jakarta-jmeter/src/core/org/apache/jmeter/util/JMeterUtils.java
  
  Index: JMeterUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/util/JMeterUtils.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- JMeterUtils.java  28 Feb 2003 14:21:47 -0000      1.17
  +++ JMeterUtils.java  11 Mar 2003 19:04:19 -0000      1.18
  @@ -86,6 +86,7 @@
   import org.apache.log.Logger;
   import org.apache.oro.text.PatternCacheLRU;
   import org.apache.oro.text.regex.Perl5Compiler;
  +import org.apache.oro.text.regex.Perl5Matcher;
   import org.xml.sax.XMLReader;
   /**
    *  This class contains the static utility methods used by JMeter.
  @@ -122,9 +123,25 @@
        private static Collection localeChangeListeners = new HashSet();
        private static Locale locale;
        private static ResourceBundle resources;
  +    
  +    private static ThreadLocal localMatcher = new ThreadLocal()
  +        {
  +            protected Object initialValue()
  +            {
  +                return new Perl5Matcher();
  +            }
  +        };
      
      //Provide Random numbers to whomever wants one
      private static Random rand = new Random();
  +   
  +   /**
  +    * Gets Perl5Matcher for this thread.
  +    */
  +   public static Perl5Matcher getMatcher()
  +   {
  +       return (Perl5Matcher)localMatcher.get();
  +   }
   
        /**
         *  This method is used by the init method to load the property file that may
  
  
  
  1.25      +3 -2      
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
  
  Index: HTTPSampler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- HTTPSampler.java  4 Mar 2003 19:28:17 -0000       1.24
  +++ HTTPSampler.java  11 Mar 2003 19:04:19 -0000      1.25
  @@ -963,6 +963,7 @@
                       SampleResult redirectResult = redirect.sample(redirects + 1);
                       res.addSubResult(redirectResult);
                       res.setResponseData(redirectResult.getResponseData());
  +                    res.setSuccessful(redirectResult.isSuccessful());
                       time += redirectResult.getTime();
                   }
               }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to