You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by wo...@apache.org on 2004/03/16 14:56:35 UTC

cvs commit: jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers MonitorAccumModel.java MonitorModel.java MonitorHealthPanel.java MonitorPerformancePanel.java MonitorHealthVisualizer.java MonitorGraph.java

woolfel     2004/03/16 05:56:35

  Modified:    src/monitor/components/org/apache/jmeter/visualizers
                        MonitorAccumModel.java MonitorModel.java
                        MonitorHealthPanel.java
                        MonitorPerformancePanel.java
                        MonitorHealthVisualizer.java MonitorGraph.java
  Log:
  fixed two minor bugs related to clear. the first one was the
  accumModel was clearing the listener when it shouldn't. the
  second is after the listener is cleared, lastSelectedPath
  returns null. 
  peter lin
  
  Revision  Changes    Path
  1.5       +18 -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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MonitorAccumModel.java	16 Mar 2004 03:49:53 -0000	1.4
  +++ MonitorAccumModel.java	16 Mar 2004 13:56:34 -0000	1.5
  @@ -21,6 +21,7 @@
   import java.util.ArrayList;
   import java.util.Collections;
   import java.util.HashMap;
  +import java.util.Iterator;
   import java.util.List;
   import java.util.LinkedList;
   
  @@ -170,6 +171,13 @@
   		notifyListeners(createNewMonitorModel(url));
   	}
   	
  +	/**
  +	 * Method will return a new MonitorModel object
  +	 * with the given URL. This is used when the server
  +	 * fails to respond fully, or is dead.
  +	 * @param url
  +	 * @return
  +	 */
   	public MonitorModel createNewMonitorModel(URL url){
   		MonitorStats stat = new MonitorStats(Stats.DEAD,
   			0,
  @@ -185,10 +193,17 @@
   	}
   	
   	/**
  -	 * Clears everything.
  +	 * Clears everything except the listener. Do not
  +	 * clear the listeners. If we clear listeners,
  +	 * subsequent "run" will not notify the gui of
  +	 * data changes.
   	 */
   	public void clear(){
  -		listeners.clear();
  +		Iterator itr = this.MAP.keySet().iterator();
  +		while (itr.hasNext()){
  +			List lt = (List)this.MAP.get(itr.next());
  +			lt.clear();
  +		}
   		this.MAP.clear();
   	}
   	
  
  
  
  1.3       +14 -5     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MonitorModel.java	13 Mar 2004 22:45:15 -0000	1.2
  +++ MonitorModel.java	16 Mar 2004 13:56:34 -0000	1.3
  @@ -93,6 +93,11 @@
   		return this.current.getURL();
   	}
   	
  +	/**
  +	 * Method will return a formatted date using
  +	 * SimpleDateFormat.
  +	 * @return String 
  +	 */
   	public String getTimestampString(){
   		Date date = new Date(this.current.timestamp);
   		SimpleDateFormat ft = new SimpleDateFormat();
  @@ -106,10 +111,10 @@
   	public String toString(){
   		return getURL();
   	}
  -	
  -    /* (non-Javadoc)
  -     * @see org.apache.jmeter.samplers.Clearable#clear()
  -     */
  +
  +	/**
  +	 * clear will create a new MonitorStats object.
  +	 */	
       public void clear()
       {
   		current = 
  @@ -132,6 +137,10 @@
   		listeners.add(listener);
   	}
   	
  +	/**
  +	 * a clone method is provided for convienance. In some
  +	 * cases, it may be desirable to clone the object.
  +	 */
   	public Object clone(){
   		MonitorStats newstats =
   			new MonitorStats(current.health,
  
  
  
  1.4       +12 -23    jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorHealthPanel.java
  
  Index: MonitorHealthPanel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorHealthPanel.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MonitorHealthPanel.java	13 Mar 2004 23:16:07 -0000	1.3
  +++ MonitorHealthPanel.java	16 Mar 2004 13:56:34 -0000	1.4
  @@ -26,7 +26,6 @@
   import javax.swing.JPanel;
   
   import java.util.HashMap;
  -import java.util.Random;
   
   import javax.swing.JScrollPane;
   
  @@ -76,7 +75,11 @@
           init();
       }
   
  -	private void init(){
  +	/**
  +	 * init is responsible for creating the necessary legends
  +	 * and information for the health panel.
  +	 */
  +	protected void init(){
   		this.setLayout(new BorderLayout());
   		ImageIcon legend = JMeterUtils.getImage("monitor-legend.gif");
   		JLabel label = new JLabel(legend);
  @@ -104,24 +107,6 @@
   		this.add(eqs,BorderLayout.SOUTH);
   	}
   
  -	public void createTestData(){	
  -		Random ran = new Random(System.currentTimeMillis());
  -		for (int idx = 0; idx < 21; idx++){
  -			MonitorStats stat = new MonitorStats();
  -			stat.host = "localhost" + idx;
  -			stat.port = "8080";
  -			stat.protocol = "http";
  -			stat.health = ran.nextInt(3);
  -			stat.load = ran.nextInt(100);
  -			stat.timestamp = (System.currentTimeMillis() - ran.nextLong());
  -			
  -			MonitorModel mm = new MonitorModel(stat);
  -			ServerPanel sp = new ServerPanel(mm);
  -			this.SERVERMAP.put(stat.getURL(),sp);
  -			this.SERVERS.add(sp);
  -		}
  -	}
  -	
   	/**
   	 * 
   	 * @param model
  @@ -136,17 +121,21 @@
   				SERVERMAP.put(model.getURL(),pane);
   			}
   			pane.updateGui(model);
  -			this.SERVERS.updateUI();
   		} else {
   			ServerPanel newpane = new ServerPanel(model);
   			SERVERMAP.put(model.getURL(),newpane);
   			this.SERVERS.add(newpane);
   			newpane.updateGui(model);
  -			this.SERVERS.updateUI();
   		}
  +		this.SERVERS.updateUI();
   	}
   
  +	/**
  +	 * clear will clear the hashmap, remove all ServerPanels
  +	 * from the servers pane, and update the ui.
  +	 */
   	public void clear(){
  +		this.SERVERMAP.clear();
   		this.SERVERS.removeAll();
   		this.SERVERS.updateUI();
   	}
  
  
  
  1.4       +45 -12    jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorPerformancePanel.java
  
  Index: MonitorPerformancePanel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorPerformancePanel.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MonitorPerformancePanel.java	13 Mar 2004 23:16:07 -0000	1.3
  +++ MonitorPerformancePanel.java	16 Mar 2004 13:56:34 -0000	1.4
  @@ -114,7 +114,11 @@
           init();
       }
   
  -	public void init(){
  +	/**
  +	 * init() will create all the necessary swing panels,
  +	 * labels and icons for the performance panel.
  +	 */
  +	protected void init(){
   		ROOTSAMPLE = new SampleResult();
   		ROOTSAMPLE.setSampleLabel(SERVER_TITLE);
   		ROOTSAMPLE.setSuccessful(true);
  @@ -149,6 +153,12 @@
   		this.add(right,JSplitPane.RIGHT);		
   	}
   	
  +	/**
  +	 * Method will create the legends at the bottom of
  +	 * the performance tab explaining the meaning of
  +	 * each line.
  +	 * @return JPanel
  +	 */
   	public JPanel createLegend(){
   		Dimension lsize = new Dimension(130,18);
   		
  @@ -179,7 +189,12 @@
   		legend.add(thd);
   		return legend;
   	}
  -	
  +
  +	/**
  +	 * Method is responsible for creating the left
  +	 * grid labels.
  +	 * @return JPanel
  +	 */	
   	public JPanel createLeftGridLabels(){
   		Dimension lsize = new Dimension(33,20);
   		JPanel labels = new JPanel();
  @@ -202,6 +217,11 @@
   		return labels;
   	}
   	
  +	/**
  +	 * Method is responsible for creating the grid labels
  +	 * on the right for "healthy" and "dead"
  +	 * @return JPanel
  +	 */
   	public JPanel createRightGridLabels(){
   		JPanel labels = new JPanel();
   		labels.setLayout(new BorderLayout());
  @@ -219,6 +239,10 @@
   		return labels;
   	}
   	
  +	/**
  +	 * MonitorAccumModel will call this method to notify
  +	 * the component data has changed.
  +	 */
   	public void addSample(MonitorModel model){
   		if (!SERVERMAP.containsKey(model.getURL())){
   			DefaultMutableTreeNode newnode =
  @@ -226,7 +250,7 @@
   			newnode.setAllowsChildren(false);
   			SERVERMAP.put(model.getURL(),newnode);
   			ROOTNODE.add(newnode);
  -			TREEPANE.updateUI();
  +			this.TREEPANE.updateUI();
   		}
   		DefaultMutableTreeNode node =
   			(DefaultMutableTreeNode) SERVERTREE.getLastSelectedPathComponent();
  @@ -244,17 +268,26 @@
   	 */
   	public void valueChanged(TreeSelectionEvent e)
   	{
  -		DefaultMutableTreeNode node =
  -			(DefaultMutableTreeNode) SERVERTREE.getLastSelectedPathComponent();
  -		Object usrobj = node.getUserObject();
  -		if (usrobj instanceof MonitorModel && usrobj != null){
  -			MonitorModel mo = (MonitorModel)usrobj;
  -			GRAPH.updateGui(mo);
  -			this.updateUI();
  +		// we check to see if the lastSelectedPath is null
  +		// after we clear, it would return null
  +		if (SERVERTREE.getLastSelectedPathComponent() != null){
  +			DefaultMutableTreeNode node =
  +				(DefaultMutableTreeNode) SERVERTREE.getLastSelectedPathComponent();
  +			Object usrobj = node.getUserObject();
  +			if ( usrobj != null && usrobj instanceof MonitorModel){
  +				MonitorModel mo = (MonitorModel)usrobj;
  +				GRAPH.updateGui(mo);
  +				this.updateUI();
  +			}
  +			TREEPANE.updateUI();
   		}
  -		TREEPANE.updateUI();
   	}
   	
  +	/**
  +	 * clear will remove all child nodes from the ROOTNODE,
  +	 * clear the HashMap, update the graph and jpanel for
  +	 * the server tree.
  +	 */
   	public void clear(){
   		this.SERVERMAP.clear();
   		ROOTNODE.removeAllChildren();
  
  
  
  1.5       +4 -1      jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorHealthVisualizer.java
  
  Index: MonitorHealthVisualizer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorHealthVisualizer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MonitorHealthVisualizer.java	16 Mar 2004 03:49:53 -0000	1.4
  +++ MonitorHealthVisualizer.java	16 Mar 2004 13:56:34 -0000	1.5
  @@ -53,6 +53,8 @@
   	private MonitorAccumModel MODEL;
   	private MonitorGraph GRAPH;
   	
  +	public static final String BUFFER = "monitor.buffer.size";
  +	
       /**
        * Constructor for the GraphVisualizer object.
        */
  @@ -61,6 +63,7 @@
       	MODEL = new MonitorAccumModel();
       	GRAPH = new MonitorGraph(MODEL);
       	init();
  +		MODEL.setBufferSize(JMeterUtils.getPropDefault(BUFFER,800));
       }
   
       public String getLabelResource()
  
  
  
  1.4       +20 -13    jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorGraph.java
  
  Index: MonitorGraph.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/monitor/components/org/apache/jmeter/visualizers/MonitorGraph.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MonitorGraph.java	13 Mar 2004 23:16:07 -0000	1.3
  +++ MonitorGraph.java	16 Mar 2004 13:56:34 -0000	1.4
  @@ -126,9 +126,10 @@
   
       }
   
  -    /* (non-Javadoc)
  -     * @see org.apache.jmeter.visualizers.MonitorGuiListener#updateGui(org.apache.jmeter.visualizers.MonitorModel)
  -     */
  +	/**
  +	 * The method will fist check to see if the graph is
  +	 * visible. If it is, it will repaint the graph.
  +	 */
       public void updateGui(final MonitorModel model)
       {
       	if (this.isShowing()){
  @@ -137,6 +138,12 @@
       	}
       }
   
  +	/**
  +	 * painComponent is responsible for drawing the actual
  +	 * graph. This is because of how screen works. Tried
  +	 * to use clipping, but I don't understand it well
  +	 * enough to get the desired effect.
  +	 */
   	public void paintComponent(Graphics g)
   	{
   		super.paintComponent(g);
  @@ -167,17 +174,17 @@
   		}
   	}
   
  -    /* (non-Javadoc)
  -     * @see org.apache.jmeter.visualizers.MonitorGuiListener#updateGui()
  -     */
  +	/**
  +	 * updateGui() will call repaint
  +	 */
       public void updateGui()
       {
       	repaint();
       }
   
  -    /* (non-Javadoc)
  -     * @see org.apache.jmeter.samplers.Clearable#clear()
  -     */
  +	/**
  +	 * clear will repaint the graph
  +	 */
       public void clear()
       {
       	paintComponent(getGraphics());
  @@ -189,12 +196,12 @@
   	{
   		double width = (double)getWidth();
   		double height = (double)getHeight() - 10.0;
  -		// int xaxis = (int)(x % width);
  -		// int lastx = (int)((x - 1) % width);
   		int xaxis = (int)(width * (x /width));
   		int lastx = (int)(width * ((x - 1)/width));
   		
  -		// draw grid
  +		// draw grid only when x is 1. If we didn't
  +		// the grid line would draw over the data
  +		// lines making it look bad.
   		if (YGRID && x == 1){
   			int q1 = (int)(height * 0.25);
   			int q2 = (int)(height * 0.50);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org