Source Code Cross Referenced for RemoteStart.java in  » Testing » jakarta-jmeter » org » apache » jmeter » gui » action » 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.gui.action 
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:         */
018:
019:        package org.apache.jmeter.gui.action;
020:
021:        import java.awt.Component;
022:        import java.awt.event.ActionEvent;
023:        import java.util.HashMap;
024:        import java.util.HashSet;
025:        import java.util.Map;
026:        import java.util.Set;
027:
028:        import org.apache.jmeter.JMeter;
029:        import org.apache.jmeter.engine.ClientJMeterEngine;
030:        import org.apache.jmeter.engine.JMeterEngine;
031:        import org.apache.jmeter.engine.JMeterEngineException;
032:        import org.apache.jmeter.gui.GuiPackage;
033:        import org.apache.jmeter.util.JMeterUtils;
034:        import org.apache.jorphan.collections.HashTree;
035:        import org.apache.jorphan.logging.LoggingManager;
036:        import org.apache.log.Logger;
037:
038:        public class RemoteStart extends AbstractAction {
039:
040:            private static final Logger log = LoggingManager
041:                    .getLoggerForClass();
042:
043:            private static final String LOCAL_HOST = "127.0.0.1"; // $NON-NLS-1$
044:
045:            private static final String REMOTE_HOSTS = "remote_hosts"; // $NON-NLS-1$ jmeter.properties
046:
047:            private static final String REMOTE_HOSTS_SEPARATOR = ","; // $NON-NLS-1$
048:
049:            private static Set commands = new HashSet();
050:            static {
051:                commands.add(ActionNames.REMOTE_START);
052:                commands.add(ActionNames.REMOTE_STOP);
053:                commands.add(ActionNames.REMOTE_START_ALL);
054:                commands.add(ActionNames.REMOTE_STOP_ALL);
055:                commands.add(ActionNames.REMOTE_EXIT);
056:                commands.add(ActionNames.REMOTE_EXIT_ALL);
057:            }
058:
059:            private Map remoteEngines = new HashMap();
060:
061:            public RemoteStart() {
062:            }
063:
064:            public void doAction(ActionEvent e) {
065:                String name = ((Component) e.getSource()).getName();
066:                if (name != null) {
067:                    name = name.trim();
068:                }
069:                String action = e.getActionCommand();
070:                if (action.equals(ActionNames.REMOTE_STOP)) {
071:                    doRemoteStop(name);
072:                } else if (action.equals(ActionNames.REMOTE_START)) {
073:                    popupShouldSave(e);
074:                    doRemoteInit(name);
075:                    doRemoteStart(name);
076:                } else if (action.equals(ActionNames.REMOTE_START_ALL)) {
077:                    popupShouldSave(e);
078:                    String remote_hosts_string = JMeterUtils.getPropDefault(
079:                            REMOTE_HOSTS, LOCAL_HOST);
080:                    java.util.StringTokenizer st = new java.util.StringTokenizer(
081:                            remote_hosts_string, REMOTE_HOSTS_SEPARATOR);
082:                    while (st.hasMoreElements()) {
083:                        String el = (String) st.nextElement();
084:                        doRemoteInit(el.trim());
085:                    }
086:                    st = new java.util.StringTokenizer(remote_hosts_string,
087:                            REMOTE_HOSTS_SEPARATOR);
088:                    while (st.hasMoreElements()) {
089:                        String el = (String) st.nextElement();
090:                        doRemoteStart(el.trim());
091:                    }
092:                } else if (action.equals(ActionNames.REMOTE_STOP_ALL)) {
093:                    String remote_hosts_string = JMeterUtils.getPropDefault(
094:                            REMOTE_HOSTS, LOCAL_HOST);
095:                    java.util.StringTokenizer st = new java.util.StringTokenizer(
096:                            remote_hosts_string, REMOTE_HOSTS_SEPARATOR);
097:                    while (st.hasMoreElements()) {
098:                        String el = (String) st.nextElement();
099:                        doRemoteStop(el.trim());
100:                    }
101:                } else if (action.equals(ActionNames.REMOTE_EXIT)) {
102:                    doRemoteExit(name);
103:                } else if (action.equals(ActionNames.REMOTE_EXIT_ALL)) {
104:                    String remote_hosts_string = JMeterUtils.getPropDefault(
105:                            REMOTE_HOSTS, LOCAL_HOST);
106:                    java.util.StringTokenizer st = new java.util.StringTokenizer(
107:                            remote_hosts_string, REMOTE_HOSTS_SEPARATOR);
108:                    while (st.hasMoreElements()) {
109:                        String el = (String) st.nextElement();
110:                        doRemoteExit(el.trim());
111:                    }
112:                }
113:            }
114:
115:            /**
116:             * Stops a remote testing engine
117:             * 
118:             * @param name
119:             *            the DNS name or IP address of the remote testing engine
120:             * 
121:             */
122:            private void doRemoteStop(String name) {
123:                GuiPackage.getInstance().getMainFrame().showStoppingMessage(
124:                        name);
125:                JMeterEngine engine = (JMeterEngine) remoteEngines.get(name);
126:                engine.stopTest();
127:            }
128:
129:            /**
130:             * Exits a remote testing engine
131:             * 
132:             * @param name
133:             *            the DNS name or IP address of the remote testing engine
134:             * 
135:             */
136:            private void doRemoteExit(String name) {
137:                JMeterEngine engine = (JMeterEngine) remoteEngines.get(name);
138:                if (engine == null)
139:                    return;
140:                // GuiPackage.getInstance().getMainFrame().showStoppingMessage(name);
141:                engine.exit();
142:            }
143:
144:            /**
145:             * Starts a remote testing engine
146:             * 
147:             * @param name
148:             *            the DNS name or IP address of the remote testing engine
149:             * 
150:             */
151:            private void doRemoteStart(String name) {
152:                JMeterEngine engine = (JMeterEngine) remoteEngines.get(name);
153:                if (engine != null) {
154:                    try {
155:                        engine.runTest();
156:                    } catch (JMeterEngineException e) {
157:                        JMeterUtils.reportErrorToUser(e.getMessage(),
158:                                JMeterUtils
159:                                        .getResString("remote_error_starting")); // $NON-NLS-1$
160:                    }
161:                }
162:            }
163:
164:            /**
165:             * Initializes remote engines
166:             */
167:            private void doRemoteInit(String name) {
168:                JMeterEngine engine = (JMeterEngine) remoteEngines.get(name);
169:                if (engine == null) {
170:                    try {
171:                        engine = new ClientJMeterEngine(name);
172:                        remoteEngines.put(name, engine);
173:                    } catch (Exception ex) {
174:                        log.error("Failed to initialise remote engine", ex);
175:                        JMeterUtils.reportErrorToUser(ex.getMessage(),
176:                                JMeterUtils.getResString("remote_error_init")); // $NON-NLS-1$
177:                        return;
178:                    }
179:                } else {
180:                    engine.reset();
181:                }
182:                initEngine(engine, name);
183:            }
184:
185:            public Set getActionNames() {
186:                return commands;
187:            }
188:
189:            /**
190:             * Initializes test on engine.
191:             * 
192:             * @param engine
193:             *            remote engine object
194:             * @param host
195:             *            host the engine will run on
196:             */
197:            private void initEngine(JMeterEngine engine, String host) {
198:                GuiPackage gui = GuiPackage.getInstance();
199:                HashTree testTree = gui.getTreeModel().getTestPlan();
200:                JMeter.convertSubTree(testTree);
201:                testTree.add(testTree.getArray()[0], gui.getMainFrame());
202:                engine.configure(testTree);
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.