woolfel     2005/01/06 20:20:10

  Modified:    src/monitor/components/org/apache/jmeter/visualizers
                        MonitorAccumModel.java MonitorStats.java
                        MonitorModel.java
  Log:
  made changes to the monitor stats can be saved to a file.

  

  peter
  
  Revision  Changes    Path
  1.7       +16 -3     
jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorAccumModel.java
  
  Index: MonitorAccumModel.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorAccumModel.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MonitorAccumModel.java    20 Mar 2004 20:36:37 -0000      1.6
  +++ MonitorAccumModel.java    7 Jan 2005 04:20:10 -0000       1.7
  @@ -36,7 +36,11 @@
   {
   
        private HashMap MAP;
  -     //private MonitorModel CURRENT;
  +     /**
  +      * we use this to set the current monitorModel so that
  +      * we can save the stats to the resultcolllector.
  +      */
  +     private MonitorModel CURRENT;
        private List listeners;
        /**
         * By default, we set the default to 800
  @@ -61,13 +65,22 @@
       }
       
       /**
  +     * Added this method we that we can save the calculated
  +     * stats.
  +     * @return
  +     */
  +    public MonitorModel getLastSample(){
  +     return this.CURRENT;
  +    }
  +    
  +    /**
        * Method will look up the server in the map. The
        * MonitorModel will be added to an existing list,
        * or a new one will be created.
        * @param model
        */
       public void addSample(MonitorModel model){
  -             //this.CURRENT = model;
  +             this.CURRENT = model;
        if (MAP.containsKey(model.getURL())){
                List newlist = updateArray(model,(List)MAP.get(model.getURL()));
                MAP.put(model.getURL(),newlist);
  
  
  
  1.4       +96 -21    
jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorStats.java
  
  Index: MonitorStats.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorStats.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MonitorStats.java 13 Mar 2004 23:16:07 -0000      1.3
  +++ MonitorStats.java 7 Jan 2005 04:20:10 -0000       1.4
  @@ -18,18 +18,20 @@
   
   import java.io.Serializable;
   
  -public class MonitorStats implements Serializable
  +import org.apache.jmeter.testelement.AbstractTestElement;
  +
  +public class MonitorStats extends AbstractTestElement implements Serializable
   {
   
  -     public int health;
  -     public int load;
  -     public int cpuload;
  -     public int memload;
  -     public int threadload;
  -     public String host;
  -     public String port;
  -     public String protocol;
  -     public long timestamp;
  +     public static String HEALTH = "stats.health";
  +     public static String LOAD = "stats.load";
  +     public static String CPULOAD = "stats.cpuload";
  +     public static String MEMLOAD = "stats.memload";
  +     public static String THREADLOAD = "stats.threadload";
  +     public static String HOST = "stats.host";
  +     public static String PORT = "stats.port";
  +     public static String PROTOCOL = "stats.protocol";
  +     public static String TIMESTAMP = "stats.timestamp";
        
       /**
        * 
  @@ -60,15 +62,15 @@
        String port,
        String protocol,
        long time){
  -             this.health = health;
  -             this.load = load;
  -             this.cpuload = cpuload;
  -             this.memload = memload;
  -             this.threadload = threadload;
  -             this.host = host;
  -             this.port = port;
  -             this.protocol = protocol;
  -             this.timestamp = time;
  +             this.setHealth(health);
  +             this.setLoad(load);
  +             this.setCpuLoad(cpuload);
  +             this.setMemLoad(memload);
  +             this.setThreadLoad(threadload);
  +             this.setHost(host);
  +             this.setPort(port);
  +             this.setProtocol(protocol);
  +             this.setTimeStamp(time);
        }
   
        /**
  @@ -77,6 +79,79 @@
         * @return protocol://host:port
         */
        public String getURL(){
  -             return protocol + "://" + host + ":" + port;
  +             return this.getProtocol() + "://" + 
  +             this.getHost() + ":" + this.getPort();
  +     }
  +     
  +     public void setHealth(int health){
  +             this.setProperty(HEALTH,String.valueOf(health));
  +     }
  +     
  +     public void setLoad(int load){
  +             this.setProperty(LOAD,String.valueOf(load));
  +     }
  +     
  +     public void setCpuLoad(int load){
  +             this.setProperty(CPULOAD,String.valueOf(load));
  +     }
  +     
  +     public void setMemLoad(int load){
  +             this.setProperty(MEMLOAD,String.valueOf(load));
  +     }
  +     
  +     public void setThreadLoad(int load){
  +             this.setProperty(THREADLOAD,String.valueOf(load));
  +     }
  +     
  +     public void setHost(String host){
  +             this.setProperty(HOST,host);
  +     }
  +     
  +     public void setPort(String port){
  +             this.setProperty(PORT,port);
  +     }
  +     
  +     public void setProtocol(String protocol){
  +             this.setProperty(PROTOCOL,protocol);
  +     }
  +     
  +     public void setTimeStamp(long time){
  +             this.setProperty(TIMESTAMP,String.valueOf(time));
  +     }
  +     
  +     public int getHealth(){
  +             return this.getPropertyAsInt(HEALTH);
  +     }
  +     
  +     public int getLoad(){
  +             return this.getPropertyAsInt(LOAD);
  +     }
  +     
  +     public int getCpuLoad(){
  +             return this.getPropertyAsInt(CPULOAD);
  +     }
  +     
  +     public int getMemLoad(){
  +             return this.getPropertyAsInt(MEMLOAD);
  +     }
  +     
  +     public int getThreadLoad(){
  +             return this.getPropertyAsInt(THREADLOAD);
  +     }
  +     
  +     public String getHost(){
  +             return this.getPropertyAsString(HOST);
  +     }
  +     
  +     public String getPort(){
  +             return this.getPropertyAsString(PORT);
  +     }
  +     
  +     public String getProtocol(){
  +             return this.getPropertyAsString(PROTOCOL);
  +     }
  +     
  +     public long getTimeStamp(){
  +             return this.getPropertyAsLong(TIMESTAMP);
        }
   }
  
  
  
  1.5       +28 -22    
jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorModel.java
  
  Index: MonitorModel.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorModel.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MonitorModel.java 20 Mar 2004 22:10:02 -0000      1.4
  +++ MonitorModel.java 7 Jan 2005 04:20:10 -0000       1.5
  @@ -54,39 +54,39 @@
        }
        
        public int getHealth(){
  -             return this.current.health;
  +             return this.current.getHealth();
        }
        
        public int getLoad(){
  -             return this.current.load;
  +             return this.current.getLoad();
        }
   
        public int getCpuload(){
  -             return this.current.cpuload;    
  +             return this.current.getCpuLoad();       
        }
        
        public int getMemload(){
  -             return this.current.memload;
  +             return this.current.getMemLoad();
        }
        
        public int getThreadload(){
  -             return this.current.threadload;
  +             return this.current.getThreadLoad();
        }
        
        public String getHost(){
  -             return this.current.host;
  +             return this.current.getHost();
        }
        
        public String getPort(){
  -             return this.current.port;
  +             return this.current.getPort();
        }
        
        public String getProtocol(){
  -             return this.current.protocol;
  +             return this.current.getProtocol();
        }
        
        public long getTimestamp(){
  -             return this.current.timestamp;
  +             return this.current.getTimeStamp();
        }
        
        public String getURL(){
  @@ -99,7 +99,7 @@
         * @return String 
         */
        public String getTimestampString(){
  -             Date date = new Date(this.current.timestamp);
  +             Date date = new Date(this.current.getTimeStamp());
                SimpleDateFormat ft = new SimpleDateFormat();
                return ft.format(date);
        }
  @@ -142,16 +142,22 @@
         * cases, it may be desirable to clone the object.
         */
        public Object clone(){
  -             MonitorStats newstats =
  -                     new MonitorStats(current.health,
  -                             current.load,
  -                             current.cpuload,
  -                             current.memload,
  -                             current.threadload,
  -                             current.host,
  -                             current.port,
  -                             current.protocol,
  -                             current.timestamp);
  -             return new MonitorModel(newstats);
  +             return new MonitorModel(cloneMonitorStats());
  +     }
  +     
  +     /**
  +      * a clone method to clone the stats
  +      * @return
  +      */
  +     public MonitorStats cloneMonitorStats(){
  +             return new MonitorStats(current.getHealth(),
  +                     current.getLoad(),
  +                     current.getCpuLoad(),
  +                     current.getMemLoad(),
  +                     current.getThreadLoad(),
  +                     current.getHost(),
  +                     current.getPort(),
  +                     current.getProtocol(),
  +                     current.getTimeStamp());
        }
   }
  
  
  

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

Reply via email to