Source Code Cross Referenced for MonitorHealthVisualizer.java in  » Testing » jakarta-jmeter » org » apache » jmeter » visualizers » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » jakarta jmeter » org.apache.jmeter.visualizers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *   http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jmeter.visualizers;
018:
019:        import java.awt.BorderLayout;
020:        import java.awt.Graphics;
021:        import java.awt.event.ItemEvent;
022:        import java.awt.event.ItemListener;
023:        import java.awt.Image;
024:
025:        import javax.swing.border.Border;
026:        import javax.swing.border.EmptyBorder;
027:
028:        import org.apache.jmeter.samplers.Clearable;
029:        import org.apache.jmeter.samplers.SampleResult;
030:        import org.apache.jmeter.util.JMeterUtils;
031:        import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
032:
033:        import org.apache.jorphan.logging.LoggingManager;
034:        import org.apache.log.Logger;
035:
036:        /**
037:         * For performance reasons, I am using tabs for the visualizers. Since a
038:         * visualizer is heavy weight, I don not want to have two separate result
039:         * collectors rather the same information. Instead, I would rather have the
040:         * visualizer be the container for the data and simply pass the data to child
041:         * JComponents. In the future, we may want to add email alerts as a third tab.
042:         */
043:        public class MonitorHealthVisualizer extends AbstractVisualizer
044:                implements  ImageVisualizer, ItemListener, GraphListener,
045:                Clearable {
046:            private MonitorTabPane TABPANE;
047:
048:            private MonitorHealthPanel HEALTHPANE;
049:
050:            private MonitorPerformancePanel PERFPANE;
051:
052:            private MonitorAccumModel MODEL;
053:
054:            private MonitorGraph GRAPH;
055:
056:            public static final String BUFFER = "monitor.buffer.size";
057:
058:            private static transient Logger log = LoggingManager
059:                    .getLoggerForClass();
060:
061:            /**
062:             * Constructor for the GraphVisualizer object.
063:             */
064:            public MonitorHealthVisualizer() {
065:                this .isStats = true;
066:                initModel();
067:                init();
068:            }
069:
070:            private void initModel() {
071:                MODEL = new MonitorAccumModel();
072:                GRAPH = new MonitorGraph(MODEL);
073:                MODEL.setBufferSize(JMeterUtils.getPropDefault(BUFFER, 800));
074:            }
075:
076:            public String getLabelResource() {
077:                return "monitor_health_title"; // $NON-NLS-1$
078:            }
079:
080:            /**
081:             * Because of the unique requirements of a monitor We have to handle the
082:             * results differently than normal GUI components. A monitor should be able
083:             * to run for a very long time without eating up all the memory.
084:             */
085:            public void add(SampleResult res) {
086:                MODEL.addSample(res);
087:                try {
088:                    collector.recordStats(this .MODEL.getLastSample()
089:                            .cloneMonitorStats());
090:                } catch (Exception e) {
091:                    // for now just swallow the exception
092:                    log.debug("StatsModel was null", e);
093:                }
094:            }
095:
096:            public Image getImage() {
097:                Image result = GRAPH.createImage(this .getWidth(), this 
098:                        .getHeight());
099:                Graphics image = result.getGraphics();
100:                GRAPH.paintComponent(image);
101:                return result;
102:            }
103:
104:            public void itemStateChanged(ItemEvent e) {
105:            }
106:
107:            public synchronized void updateGui() {
108:                this .repaint();
109:            }
110:
111:            public synchronized void updateGui(Sample s) {
112:                this .repaint();
113:            }
114:
115:            /**
116:             * Initialize the GUI.
117:             */
118:            private void init() {
119:                this .setLayout(new BorderLayout());
120:
121:                // MAIN PANEL
122:                Border margin = new EmptyBorder(10, 10, 5, 10);
123:                this .setBorder(margin);
124:
125:                // Add the main panel and the graph
126:                this .add(this .makeTitlePanel(), BorderLayout.NORTH);
127:                this .createTabs();
128:            }
129:
130:            private void createTabs() {
131:                TABPANE = new MonitorTabPane();
132:                createHealthPane(TABPANE);
133:                createPerformancePane(TABPANE);
134:                this .add(TABPANE, BorderLayout.CENTER);
135:            }
136:
137:            /**
138:             * Create the JPanel
139:             * 
140:             * @param pane
141:             */
142:            private void createHealthPane(MonitorTabPane pane) {
143:                HEALTHPANE = new MonitorHealthPanel(MODEL);
144:                pane.addTab(JMeterUtils
145:                        .getResString("monitor_health_tab_title"), HEALTHPANE); // $NON-NLS-1$
146:            }
147:
148:            /**
149:             * Create the JSplitPane for the performance history
150:             * 
151:             * @param pane
152:             */
153:            private void createPerformancePane(MonitorTabPane pane) {
154:                PERFPANE = new MonitorPerformancePanel(MODEL, GRAPH);
155:                pane.addTab(JMeterUtils
156:                        .getResString("monitor_performance_tab_title"),
157:                        PERFPANE); // $NON-NLS-1$
158:            }
159:
160:            /**
161:             * Clears the MonitorAccumModel.
162:             */
163:            public void clearData() {
164:                this.MODEL.clearData();
165:                this.HEALTHPANE.clearData();
166:                this.PERFPANE.clearData();
167:            }
168:
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.