woolfel     2004/12/22 09:32:00

  Modified:    src/monitor/components/org/apache/jmeter/monitor/util
                        Stats.java
  Log:
  updated the Stats class so that if a server doesn't return the data,

  we don't calculate the stat and just return zero.

  

  peter
  
  Revision  Changes    Path
  1.9       +16 -8     
jakarta-jmeter/src/monitor/components/org/apache/jmeter/monitor/util/Stats.java
  
  Index: Stats.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/monitor/components/org/apache/jmeter/monitor/util/Stats.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Stats.java        26 Oct 2004 14:46:20 -0000      1.8
  +++ Stats.java        22 Dec 2004 17:32:00 -0000      1.9
  @@ -68,11 +68,19 @@
                        double memdiv = (double)usedMem/(double)totMem;
                        double memWeight = DEFAULT_MEMORY_FACTOR * memdiv;
   
  -                     Connector cntr = (Connector)stat.getConnector().get(0);
  -                     int maxThread = cntr.getThreadInfo().getMaxThreads();
  -                     int curThread = 
cntr.getThreadInfo().getCurrentThreadsBusy();
  -                     double thdiv = (double)curThread/(double)maxThread;
  -                     double threadWeight = DEFAULT_THREAD_FACTOR * thdiv;
  +                     // changed the logic for BEA Weblogic in the case a
  +                     // user uses Tomcat's status servlet without any
  +                     // modifications. Weblogic will return nothing for
  +                     // the connector, therefore we need to check the size
  +                     // of the list. Peter 12.22.04
  +                     double threadWeight = 0;
  +                     if (stat.getConnector().size() > 0){
  +                             Connector cntr = 
(Connector)stat.getConnector().get(0);
  +                             int maxThread = 
cntr.getThreadInfo().getMaxThreads();
  +                             int curThread = 
cntr.getThreadInfo().getCurrentThreadsBusy();
  +                             double thdiv = 
(double)curThread/(double)maxThread;
  +                             threadWeight = DEFAULT_THREAD_FACTOR * thdiv;
  +                     }
                        return (int)(memWeight + threadWeight);
                } else {
                        return 0;
  @@ -93,7 +101,7 @@
         * @return integer representing the status
         */
        public static int calculateStatus(Status stat){
  -             if (stat != null){
  +             if (stat != null && stat.getConnector().size() > 0){
                        Connector cntr = (Connector)stat.getConnector().get(0);
                        int max = cntr.getThreadInfo().getMaxThreads();
                        int current = 
cntr.getThreadInfo().getCurrentThreadsBusy();
  @@ -141,7 +149,7 @@
         */     
        public static int calculateThreadLoad(Status stat){
                int load = 0;
  -             if (stat != null){
  +             if (stat != null && stat.getConnector().size() > 0){
                        Connector cntr = (Connector)stat.getConnector().get(0);
                        double max = 
(double)cntr.getThreadInfo().getMaxThreads();
                        double current =
  
  
  

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

Reply via email to