1 18 19 package org.apache.jmeter.engine; 20 21 import java.net.InetAddress ; 22 import java.rmi.Naming ; 23 import java.rmi.RemoteException ; 24 25 import org.apache.jorphan.collections.HashTree; 26 import org.apache.jorphan.logging.LoggingManager; 27 import org.apache.log.Logger; 28 29 30 33 public class RemoteJMeterEngineImpl 34 extends java.rmi.server.UnicastRemoteObject 35 implements RemoteJMeterEngine 36 { 37 transient private static Logger log = LoggingManager.getLoggerForClass(); 38 JMeterEngine backingEngine; 39 40 public RemoteJMeterEngineImpl() throws RemoteException 41 { 42 log.info("Starting backing engine"); 43 log.debug("This = "+ this); 44 try 45 { 46 backingEngine = 47 new StandardJMeterEngine( 48 InetAddress.getLocalHost().getHostName()); 49 Naming.rebind("JMeterEngine", this); 50 } 51 catch(Exception ex){ 52 log.error( 53 "rmiregistry needs to be running to start JMeter in server " + 54 "mode\n\t" + ex.toString()); 55 throw new RemoteException ("Cannot start. See server log file."); 57 } 58 } 59 60 public void setHost(String host) 61 { 62 log.info("received host: "+host); 63 backingEngine.setHost(host); 64 } 65 66 72 public void configure(HashTree testTree) throws RemoteException 73 { 74 log.info("received test tree"); 75 backingEngine.configure(testTree); 76 } 77 78 public void runTest() throws RemoteException , JMeterEngineException 79 { 80 log.info("running test"); 81 log.debug("This = "+ this); 82 backingEngine.runTest(); 83 } 84 85 public void reset() throws RemoteException 86 { 87 log.info("Reset"); 88 backingEngine.reset(); 89 } 90 91 public void stopTest() throws RemoteException 92 { 93 log.info("Stopping test"); 94 backingEngine.stopTest(); } 96 97 public void exit() throws RemoteException 98 { 99 log.info("Exitting"); 100 backingEngine.exit(); 101 } 102 103 108 public static void main(String [] args) 109 { 110 log.info("Starting main"); 111 try 112 { 113 new RemoteJMeterEngineImpl(); 114 while (true) 115 { 116 Thread.sleep(Long.MAX_VALUE); 117 } 118 } 119 catch (Exception ex) 120 { 121 log.error("", ex); 122 } 123 124 } 125 } 126 | Popular Tags |