mstover1    2002/08/02 18:27:41

  Modified:    src_1/org/apache/jmeter/protocol/http/sampler
                        HTTPSamplerFull.java
               src_1/org/apache/jmeter/protocol/java/sampler
                        JavaSampler.java
  Log:
  Updating KeepAlive in HTTP Sampler (Martin Ramshaw)
  
  Revision  Changes    Path
  1.12      +81 -15    
jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFull.java
  
  Index: HTTPSamplerFull.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFull.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- HTTPSamplerFull.java      23 Jul 2002 18:06:30 -0000      1.11
  +++ HTTPSamplerFull.java      3 Aug 2002 01:27:41 -0000       1.12
  @@ -134,7 +134,7 @@
         long totalTime = (long)0;
         SampleResult res = super.sample(e);
         String displayName = res.getSampleLabel();
  -      List loadBinaryList = new ArrayList();
  +      Set uniqueBinaries = new HashSet();
         if(catClass.isDebugEnabled())
         {
                catClass.debug("sample2 : main page loading time - " + res.getTime());
  @@ -175,6 +175,7 @@
         for(int i = 0; i < nodeList.getLength(); i++)
         {
                imgRes = new SampleResult();
  +             boolean uniqueImage = true;
                try
                {
                  Node tempNode = nodeList.item(i);
  @@ -198,8 +199,21 @@
                         catClass.debug("sample2 : Image url with baseUrl - " + 
imgUrl);
                  }
                  imgRes.setSampleLabel(imgUrl.toString());
  -               loadBinary(imgUrl, imgRes);
  -               totalTime += imgRes.getTime();
  +               uniqueImage = uniqueBinaries.add(imgUrl.toString());
  +               if (uniqueImage)
  +               {
  +                      // a browser should be smart enough to *not* download
  +                      //   a binary file that it already has in its cache.
  +                      loadBinary(imgUrl, imgRes);
  +                      totalTime += imgRes.getTime();
  +               }
  +               else
  +               {
  +                       if(catClass.isDebugEnabled())
  +                       {
  +                              catClass.debug("sample2 : skipping duplicate Image - 
" + imgUrl);
  +                       }
  +               }
                }
                catch(IOException exception)
                {
  @@ -210,7 +224,10 @@
                  imgRes.setResponseMessage(NON_HTTP_RESPONSE_MESSAGE);
                  imgRes.setSuccessful(false);
                }
  -             res.addSubResult(imgRes);
  +             if (uniqueImage)
  +             {
  +                      res.addSubResult(imgRes);
  +             }
         }
         SampleResult appRes = null;
         // use parser to look for applet tags
  @@ -218,6 +235,7 @@
         for(int i = 0; i < nodeList.getLength(); i++)
         {
                appRes = new SampleResult();
  +             boolean uniqueApplet = true;
                try
                {
                  Node tempNode = nodeList.item(i);
  @@ -228,7 +246,10 @@
                  // get the url of those applets
                  NamedNodeMap nnm = tempNode.getAttributes();
                  Node namedItem = nnm.getNamedItem("code");
  -               String appletUrlStr = namedItem.getNodeValue() + ".class";
  +               // This will only work with an Applet .class file.
  +               // Ideally, this should be upgraded to work with Objects (IE)
  +               // as well as archive (.jar and .zip) files as well.
  +               String appletUrlStr = namedItem.getNodeValue();
                  // set the baseUrl and imgUrl so that if error occurs
                  // due to MalformedException then at least the values will be
                  // visible to the user to aid correction
  @@ -241,8 +262,21 @@
                         catClass.debug("sample2 : Applet url with baseUrl - " + 
appletUrl);
                  }
                  appRes.setSampleLabel(appletUrl.toString());
  -               loadBinary(appletUrl, appRes);
  -               totalTime += appRes.getTime();
  +               uniqueApplet = uniqueBinaries.add(appletUrl.toString());
  +               if (uniqueApplet)
  +               {
  +                      // a browser should be smart enough to *not* download
  +                      //   a binary file that it already has in its cache.
  +                      loadBinary(appletUrl, appRes);
  +                      totalTime += appRes.getTime();
  +               }
  +               else
  +               {
  +                       if(catClass.isDebugEnabled())
  +                       {
  +                              catClass.debug("sample2 : skipping duplicate Applet - 
" + appletUrl);
  +                       }
  +               }
                }
                catch(IOException exception)
                {
  @@ -253,12 +287,16 @@
                  appRes.setResponseMessage(NON_HTTP_RESPONSE_MESSAGE);
                  appRes.setSuccessful(false);
                }
  -             res.addSubResult(appRes);
  +             if (uniqueApplet)
  +             {
  +                      res.addSubResult(appRes);
  +             }
         }
         // use parser to look for input tags with image types as well
         nodeList = html.getElementsByTagName("input");
         for(int i = 0; i < nodeList.getLength(); i++)
         {
  +             boolean uniqueImage = true;
                try
                {
                  Node tempNode = nodeList.item(i);
  @@ -295,9 +333,22 @@
                                        catClass.debug("sample2 : Image url with 
baseUrl - " +
                                                imgUrl);
                                }
  -                             loadBinary(imgUrl, imgRes);
                                imgRes.setSampleLabel(imgUrl.toString());
  -                             totalTime += imgRes.getTime();
  +                             uniqueImage = uniqueBinaries.add(imgUrl.toString());
  +                             if (uniqueImage)
  +                             {
  +                                     // a browser should be smart enough to *not* 
download
  +                                     //   a binary file that it already has in its 
cache.
  +                                     loadBinary(imgUrl, imgRes);
  +                                     totalTime += imgRes.getTime();
  +                             }
  +                             else
  +                             {
  +                               if(catClass.isDebugEnabled())
  +                               {
  +                                      catClass.debug("sample2 : skipping duplicate 
Image - " + imgUrl);
  +                               }
  +                             }
                        }
                }
                }
  @@ -310,7 +361,10 @@
                  imgRes.setResponseMessage(NON_HTTP_RESPONSE_MESSAGE);
                  imgRes.setSuccessful(false);
                }
  -             res.addSubResult(imgRes);
  +             if (uniqueImage)
  +             {
  +                      res.addSubResult(imgRes);
  +             }
         }
         if(catClass.isDebugEnabled())
         {
  @@ -325,7 +379,6 @@
        * Download the binaries from given <code>URL</code>
        *
        * @param url            <code>URL</code> from where binary is to be downloaded
  -     * @param e      <code>Entry</code> being sampled
        * @param res            <code>SampleResult</code> to store sampling results
        * @return       binary downloaded
        */
  @@ -399,7 +452,14 @@
         {
                try
                {
  -                     conn.disconnect();
  +                     // the server can request that the connection be closed,
  +                     // but if we requested that the server close the connection
  +                     // the server should echo back our 'close' request.
  +                     // Otherwise, let the server disconnect the connection
  +                     // when its timeout period is reached.
  +                     String connection  = conn.getHeaderField("Connection");
  +                     if (connection == null || connection.equalsIgnoreCase("close"))
  +                             conn.disconnect();
                }
                catch(Exception e){}
         }
  @@ -609,10 +669,16 @@
                  "<td width = 20>\n" +
                  "<td width = 500 align = left>\n" +
                  "<img src=\"/tomcat.gif\">\n" +
  +               "<img src=\"/tomcat.gif\">\n" +
                  "<a href=\"Time.java\"> Read my code <a>\n" +
  -               "<p><applet code=Time width = 400 height = 200>\n" +
  +               "<p><applet code=Time.class width = 400 height = 200>\n" +
  +               "</applet>\n" +
  +               "<p><applet code=Time.class width = 400 height = 200>\n" +
                  "</applet>\n" +
                  "</table>\n" +
  +               "<form>\n" +
  +               "  <input type=\"image\" src=\"/tomcat-power.gif\">\n" +
  +               "</form>\n" +
                  "<form>\n" +
                  "  <input type=\"image\" src=\"/tomcat-power.gif\">\n" +
                  "</form>\n" +
  
  
  
  1.3       +0 -1      
jakarta-jmeter/src_1/org/apache/jmeter/protocol/java/sampler/JavaSampler.java
  
  Index: JavaSampler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/java/sampler/JavaSampler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JavaSampler.java  23 Jul 2002 19:20:53 -0000      1.2
  +++ JavaSampler.java  3 Aug 2002 01:27:41 -0000       1.3
  @@ -183,7 +183,6 @@
        public JavaSamplerClient createJavaClient() {
                if (javaClient == null) {
                        try {
  -
                                Class javaClass = Class.forName(getClassname().trim(),
                                                
false,Thread.currentThread().getContextClassLoader());
                                java.lang.reflect.Constructor[] constructors = 
javaClass.getConstructors();
  
  
  

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

Reply via email to