mstover1    2004/07/14 14:24:04

  Modified:    src/components/org/apache/jmeter/visualizers
                        ViewResultsFullVisualizer.java
               src/core/org/apache/jmeter/engine StandardJMeterEngine.java
               src/protocol/http/org/apache/jmeter/protocol/http/sampler
                        AccessLogSampler.java HTTPSampleResult.java
                        HTTPSampler.java HTTPSampler2.java
                        HTTPSamplerBase.java
               src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog
                        TCLogParser.java
  Log:
  Struggling with access log parser, fixing HttpSampleResult display
  
  Revision  Changes    Path
  1.45      +2 -4      
jakarta-jmeter/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
  
  Index: ViewResultsFullVisualizer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- ViewResultsFullVisualizer.java    20 Jun 2004 01:23:40 -0000      1.44
  +++ ViewResultsFullVisualizer.java    14 Jul 2004 21:24:04 -0000      1.45
  @@ -124,7 +124,6 @@
               log.debug("updateGui1 : sample result - " + res);
           }
           DefaultMutableTreeNode currNode = new DefaultMutableTreeNode(res);
  -
           treeModel.insertNodeInto(currNode, root, root.getChildCount());
           addSubResults(currNode, res);
           log.debug("End : updateGui1");
  @@ -160,13 +159,12 @@
       public void clear()
       {
           log.debug("Start : clear1");
  -        int totalChild = root.getChildCount();
   
           if (log.isDebugEnabled())
           {
  -            log.debug("clear1 : total child - " + totalChild);
  +            log.debug("clear1 : total child - " + root.getChildCount());
           }
  -        for (int i = 0; i < totalChild; i++)
  +        while (root.getChildCount() > 0)
           {
               // the child to be removed will always be 0 'cos as the nodes are
               // removed the nth node will become (n-1)th
  
  
  
  1.52      +23 -14    
jakarta-jmeter/src/core/org/apache/jmeter/engine/StandardJMeterEngine.java
  
  Index: StandardJMeterEngine.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/engine/StandardJMeterEngine.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- StandardJMeterEngine.java 2 Jul 2004 18:25:22 -0000       1.51
  +++ StandardJMeterEngine.java 14 Jul 2004 21:24:04 -0000      1.52
  @@ -250,8 +250,10 @@
      public synchronized void threadFinished(JMeterThread thread)
      {
         allThreads.remove(thread);
  +      log.info("Ending thread " + thread.getThreadNum());
         if (!serialized && allThreads.size() == 0 && !schcdule_run)
         {
  +         log.info("Stopping test");
            stopTest();
         }
      }
  @@ -266,22 +268,29 @@
      {
         public void run()
         {
  -         log.debug("Stopping test");
  -         if (running)
  +         try
            {
  -            running = false;
  -            tellThreadsToStop();
  -            try
  -            {
  -               Thread.sleep(10 * allThreads.size());
  -            }
  -            catch (InterruptedException e)
  -            {
  -            }
  -            verifyThreadsStopped();
  -            notifyTestListenersOfEnd();
  +              log.debug("Stopping test");
  +              if (running)
  +              {
  +                 running = false;
  +                 tellThreadsToStop();
  +                 try
  +                 {
  +                    Thread.sleep(10 * allThreads.size());
  +                 }
  +                 catch (InterruptedException e)
  +                 {
  +                 }
  +                 verifyThreadsStopped();
  +                 notifyTestListenersOfEnd();
  +              }
  +              JMeterContextService.endTest();
  +         }
  +         catch(Exception e)
  +         {
  +            log.error("Bad!",e);
            }
  -         JMeterContextService.endTest();
         }
      }
   
  
  
  
  1.17      +47 -26    
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSampler.java
  
  Index: AccessLogSampler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSampler.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- AccessLogSampler.java     14 Jul 2004 14:33:41 -0000      1.16
  +++ AccessLogSampler.java     14 Jul 2004 21:24:04 -0000      1.17
  @@ -75,6 +75,7 @@
      private String logFile, parserClassName, filterClassName;
      transient private Filter filter;
      private int count = 0;
  +   private boolean started = false;
   
      /**
       * Set the path where XML messages are stored for random selection.
  @@ -140,12 +141,13 @@
            int thisCount = PARSER.parseAndConfigure(1, this);
            if (thisCount == 0)
            {
  -            if (count == 0)
  +            if (count == 0 || filter == null)
               {
                  JMeterContextService.getContext().getThread().stop();
               }
  -            log.info("parser returned 0 paths");
  -            filter.reset();
  +            if(filter != null)
  +               filter.reset();
  +            getCookieManager().clear();
               count = 0;
               return null;
            }
  @@ -282,11 +284,11 @@
   
      protected void initFilter()
      {
  -      if (filter == null && filterClassName != null)
  +      if (filter == null && filterClassName != null && filterClassName.length() > 0)
         {
            try
            {
  -            filter = (LogFilter) Class.forName(filterClassName).newInstance();
  +            filter = (Filter) Class.forName(filterClassName).newInstance();
            }
            catch (Exception e)
            {
  @@ -306,27 +308,46 @@
      public Object clone()
      {
         AccessLogSampler s = (AccessLogSampler) super.clone();
  -      if (filterClassName != null)
  +      if(started)
         {
  -
  -         try
  -         {
  -            if (TestCloneable.class.isAssignableFrom(Class
  -                  .forName(filterClassName)))
  -            {
  -               if (filter == null)
  -               {
  -                  filter = (Filter) Class.forName(filterClassName)
  -                        .newInstance();
  -               }
  -               s.filter = (Filter) ((TestCloneable) filter).clone();
  -            }
  -         }
  -         catch (Exception e)
  -         {
  -            log.warn("Could not clone cloneable filter", e);
  -         }
  +           if (filterClassName != null && filterClassName.length() > 0)
  +           {
  +     
  +              try
  +              {
  +                 if (TestCloneable.class.isAssignableFrom(Class
  +                       .forName(filterClassName)))
  +                 {
  +                    initFilter();
  +                    s.filter = (Filter) ((TestCloneable) filter).clone();
  +                 }
  +              }
  +              catch (Exception e)
  +              {
  +                 log.warn("Could not clone cloneable filter", e);
  +              }
  +           }
         }
         return s;
  +   }
  +   /* (non-Javadoc)
  +    * @see org.apache.jmeter.testelement.TestListener#testEnded()
  +    */
  +   public void testEnded()
  +   {
  +      if(PARSER != null)
  +      {
  +         PARSER.close();
  +      }
  +      started = false;
  +      super.testEnded();
  +   }
  +   /* (non-Javadoc)
  +    * @see org.apache.jmeter.testelement.TestListener#testStarted()
  +    */
  +   public void testStarted()
  +   {
  +      started = true;
  +      super.testStarted();
      }
   }
  
  
  
  1.11      +12 -9     
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
  
  Index: HTTPSampleResult.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- HTTPSampleResult.java     12 Feb 2004 00:29:49 -0000      1.10
  +++ HTTPSampleResult.java     14 Jul 2004 21:24:04 -0000      1.11
  @@ -21,6 +21,8 @@
   import java.net.URL;
   
   import org.apache.jmeter.samplers.SampleResult;
  +import org.apache.jorphan.logging.LoggingManager;
  +import org.apache.log.Logger;
   
   /**
    * This is a specialisation of the SampleResult class for the HTTP protocol.
  @@ -30,6 +32,7 @@
    */
   public class HTTPSampleResult extends SampleResult
   {
  +   private static Logger log = LoggingManager.getLoggerForClass();
       public HTTPSampleResult()
       {
           super();
  @@ -49,7 +52,6 @@
       public HTTPSampleResult(HTTPSampleResult res)
       {
        super(res);
  -
           setHTTPMethod(res.getHTTPMethod());
           setURL(res.getURL());
           setCookies(res.getCookies());
  @@ -115,12 +117,13 @@
           {
               sb.append(' ');
               sb.append(u.toString());
  -        }
  -        String s= super.getSamplerData();
  -        if (s != null)
  -        {
  -            sb.append('\n');
  -            sb.append(s);
  +            if("POST".equals(getHTTPMethod()))
  +            {
  +               sb.append(getQueryString());
  +            }
  +            sb.append("\n");
  +            sb.append(getRequestHeaders());
  +            sb.append(getCookies());
           }
           return sb.toString();
       }
  
  
  
  1.97      +12 -13    
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.96
  retrieving revision 1.97
  diff -u -r1.96 -r1.97
  --- HTTPSampler.java  3 Jul 2004 14:03:58 -0000       1.96
  +++ HTTPSampler.java  14 Jul 2004 21:24:04 -0000      1.97
  @@ -171,17 +171,17 @@
               if (method.equals(POST))
               {
                String q = this.getQueryString();
  -                             res.setQueryString(q);
  -                sb.append("Query data:\n";);
  +                sb.append("\nQuery data:\n";);
                   sb.append(q);
  -                sb.append('\n');
  +                             res.setQueryString(sb.toString());
               }
               if (cookies != null)
               { 
  -             res.setCookies(cookies);
  -                sb.append("\nCookie Data:\n";);
  -                sb.append(cookies);
  -                sb.append('\n');
  +               StringBuffer temp = new StringBuffer("\nCookie Data:\n";);
  +               temp.append(cookies);
  +               temp.append('\n');
  +             res.setCookies(temp.toString());
  +             sb.append(temp);
               }
               res.setSamplerData(sb.toString());
               //TODO rather than stuff all the information in here,
  @@ -567,8 +567,7 @@
                           res.addSubResult(
                               errorResult(
                                   new Exception("Maximum frame/iframe nesting depth 
exceeded."),
  -                                null,
  -                                0));
  +                                res));
                       }
                       else
                       {
  @@ -590,7 +589,7 @@
           catch (IOException e)
           {
                res.sampleEnd();
  -            return errorResult(e, url.toString(), res.getTime());
  +            return errorResult(e, res);
           }
           finally
           {
  @@ -639,7 +638,7 @@
               }
               catch (MalformedURLException e)
               {
  -                lastRes= errorResult(e, location, 0);
  +                lastRes= errorResult(e, lastRes);
               }
               totalRes.addSubResult(lastRes);
   
  @@ -653,8 +652,7 @@
               lastRes=
                   errorResult(
                       new IOException("Exceeeded maximum number of redirects: 
"+MAX_REDIRECTS),
  -                    null,
  -                    0);
  +                    lastRes);
               totalRes.addSubResult(lastRes);
           }
   
  @@ -668,6 +666,7 @@
           // redirect chain in the location field. 
           totalRes.setURL(lastRes.getURL());
           totalRes.setHTTPMethod(lastRes.getHTTPMethod());
  +        totalRes.setQueryString(lastRes.getQueryString());
           totalRes.setRequestHeaders(lastRes.getRequestHeaders());
   
           totalRes.setResponseData(lastRes.getResponseData());
  
  
  
  1.14      +7 -7      
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
  
  Index: HTTPSampler2.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- HTTPSampler2.java 5 Jul 2004 23:29:39 -0000       1.13
  +++ HTTPSampler2.java 14 Jul 2004 21:24:04 -0000      1.14
  @@ -280,6 +280,7 @@
               res.setURL(u);
               res.setHTTPMethod(method);
               res.setRequestHeaders(hdrs);
  +            res.setQueryString(getQueryString());
           }
   
           setConnectionAuthorization(httpMethod, u, getAuthManager());
  @@ -553,8 +554,7 @@
                           res.addSubResult(
                               errorResult(
                                   new Exception("Maximum frame/iframe nesting depth 
exceeded."),
  -                                null,
  -                                0));
  +                                res));
                       }
                       else
                       {
  @@ -577,14 +577,14 @@
           catch (IllegalArgumentException e)// e.g. some kinds of invalid URL
           {
                res.sampleEnd();
  -            HTTPSampleResult err = errorResult(e, url.toString(), res.getTime());
  +            HTTPSampleResult err = errorResult(e, res);
               err.setSampleLabel("Error: "+url.toString());
               return err;
           }
           catch (IOException e)
           {
                res.sampleEnd();
  -            HTTPSampleResult err = errorResult(e, url.toString(), res.getTime());
  +            HTTPSampleResult err = errorResult(e, res);
               err.setSampleLabel("Error: "+url.toString());
               return err;
           }
  @@ -632,7 +632,7 @@
               }
               catch (MalformedURLException e)
               {
  -                lastRes= errorResult(e, location, 0);
  +                lastRes= errorResult(e, lastRes);
               }
               totalRes.addSubResult(lastRes);
   
  @@ -646,8 +646,7 @@
               lastRes=
                   errorResult(
                       new IOException("Exceeeded maximum number of redirects: 
"+MAX_REDIRECTS),
  -                    null,
  -                    0);
  +                    lastRes);
               totalRes.addSubResult(lastRes);
           }
   
  @@ -661,6 +660,7 @@
           // redirect chain in the location field. 
           totalRes.setURL(lastRes.getURL());
           totalRes.setHTTPMethod(lastRes.getHTTPMethod());
  +        totalRes.setQueryString(lastRes.getQueryString());
           totalRes.setRequestHeaders(lastRes.getRequestHeaders());
   
           totalRes.setResponseData(lastRes.getResponseData());
  
  
  
  1.7       +7 -14     
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
  
  Index: HTTPSamplerBase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HTTPSamplerBase.java      3 Jul 2004 02:28:27 -0000       1.6
  +++ HTTPSamplerBase.java      14 Jul 2004 21:24:04 -0000      1.7
  @@ -378,15 +378,12 @@
        * during sampling, and how long it took to detect the error.
        * 
        * @param e Exception representing the error.
  -     * @param data a piece of data associated to the error (e.g. URL)
  -     * @param time time spent detecting the error (0 for client-only issues)
  +     * @param current SampleResult
        * @return a sampling result useful to inform the user about the exception.
        */
  -    protected HTTPSampleResult errorResult(Throwable e, String data, long time)
  +    protected HTTPSampleResult errorResult(Throwable e, HTTPSampleResult res)
       {
  -        HTTPSampleResult res= new HTTPSampleResult(time);
           res.setSampleLabel("Error");
  -        res.setSamplerData(data);
           res.setDataType(HTTPSampleResult.TEXT);
           ByteArrayOutputStream text= new ByteArrayOutputStream(200);
           e.printStackTrace(new PrintStream(text));
  @@ -394,10 +391,6 @@
           res.setResponseCode(NON_HTTP_RESPONSE_CODE);
           res.setResponseMessage(NON_HTTP_RESPONSE_MESSAGE);
           res.setSuccessful(false);
  -        try {
  -                     res.setURL(getUrl());
  -        } catch (MalformedURLException ex){
  -        }
           res.setMonitor(this.isMonitor());
           return res;
       }
  @@ -583,15 +576,16 @@
        */
       public SampleResult sample()
       {
  +       HTTPSampleResult res = new HTTPSampleResult();
           try
           {
  -            SampleResult res= sample(getUrl(), getMethod(), false, 0);
  +            res= sample(getUrl(), getMethod(), false, 0);
               res.setSampleLabel(getName());
               return res;
           }
           catch (MalformedURLException e)
           {
  -            return errorResult(e, getName(), 0);
  +            return errorResult(e, res);
           }
       }
   
  @@ -644,7 +638,7 @@
           catch (HTMLParseException e)
           {
               // Don't break the world just because this failed:
  -            res.addSubResult(errorResult(e, null, 0));
  +            res.addSubResult(errorResult(e, res));
               res.setSuccessful(false);
           }
   
  @@ -676,8 +670,7 @@
                       res.addSubResult(
                           errorResult(
                               new Exception(binURL + " is not a correct URI"),
  -                            null,
  -                            0));
  +                            res));
                       res.setSuccessful(false);
                       continue;
                   }
  
  
  
  1.17      +16 -29    
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java
  
  Index: TCLogParser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/TCLogParser.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TCLogParser.java  14 Jul 2004 14:33:42 -0000      1.16
  +++ TCLogParser.java  14 Jul 2004 21:24:04 -0000      1.17
  @@ -92,17 +92,6 @@
        * The path to the access log file
        */
       protected String URL_PATH = null;
  -    /**
  -     * A counter used by the parser.
  -     * it is the real count of lines
  -     * parsed
  -     */
  -    protected int COUNT = 0;
  -    /**
  -     * the number of lines the user
  -     * wishes to parse
  -     */
  -    protected int PARSECOUNT = -1;
       protected boolean useFILE = true;
   
       protected File SOURCE = null;
  @@ -179,7 +168,7 @@
        * parse the entire file.
        * @return boolean success/failure
        */
  -    public boolean parse(TestElement el)
  +    public int parse(TestElement el,int parseCount)
       {
           if (this.SOURCE == null)
           {
  @@ -191,13 +180,13 @@
               {
                   this.READER = new BufferedReader(new FileReader(this.SOURCE));
               }
  -            parse(this.READER,el);
  +            return parse(this.READER,el,parseCount);
           }
           catch (Exception exception)
           {
               log.error("Problem creating samples",exception);
           }
  -        return true;
  +        return 0;
       }
   
       /**
  @@ -212,13 +201,7 @@
        */
       public int parseAndConfigure(int count,TestElement el)
       {
  -       COUNT = 0;
  -        if (count > 0)
  -        {
  -            this.PARSECOUNT = count;
  -        }
  -        this.parse(el);
  -        return COUNT;
  +       return this.parse(el,count);
       }
   
       /**
  @@ -227,8 +210,9 @@
        * if a set number of lines is given.
        * @param breader
        */
  -    protected void parse(BufferedReader breader,TestElement el)
  +    protected int parse(BufferedReader breader,TestElement el,int parseCount)
       {
  +       int actualCount = 0;
           String line = null;
           try
           {
  @@ -239,14 +223,14 @@
               {
                                if (line.length() > 0)
                                {
  -                                     this.parseLine(line,el);
  +                                     actualCount += this.parseLine(line,el);
                                }
                   // we check the count to see if we have exceeded
                   // the number of lines to parse. There's no way
                   // to know where to stop in the file. Therefore
                   // we use break to escape the while loop when
                   // we've reached the count.
  -                if (this.PARSECOUNT != -1 && COUNT >= this.PARSECOUNT)
  +                if (parseCount != -1 && actualCount >= parseCount)
                   {
                       break;
                   }
  @@ -265,6 +249,7 @@
           {
              log.error("Error reading log file",ioe);
           }
  +        return actualCount;
       }
   
       /**
  @@ -272,8 +257,9 @@
        * to parse the given text.
        * @param line
        */
  -    protected void parseLine(String line,TestElement el)
  +    protected int parseLine(String line,TestElement el)
       {
  +       int count = 0;
           // we clean the line to get
           // rid of extra stuff
           String cleanedLine = this.cleanURL(line);
  @@ -287,7 +273,7 @@
               {
                  log.debug("line was not filtered");
                   // increment the current count
  -                COUNT++;
  +                count++;
                   // we filter the line first, before we try
                   // to separate the URL into file and 
                   // parameters.
  @@ -306,11 +292,12 @@
           {
              log.debug("filter was null");
               // increment the current count
  -            COUNT++;
  +            count++;
               // in the case when the filter is not set, we
               // parse all the lines
               createUrl(cleanedLine,el);
           }
  +        return count;
       }
   
       /**
  
  
  

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

Reply via email to