KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > engine > RemoteJMeterEngineImpl


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/engine/RemoteJMeterEngineImpl.java,v 1.16 2004/02/12 23:59:01 sebb Exp $
2
/*
3  * Copyright 2001-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */

18
19 package org.apache.jmeter.engine;
20
21 import java.net.InetAddress JavaDoc;
22 import java.rmi.Naming JavaDoc;
23 import java.rmi.RemoteException JavaDoc;
24
25 import org.apache.jorphan.collections.HashTree;
26 import org.apache.jorphan.logging.LoggingManager;
27 import org.apache.log.Logger;
28
29
30 /**
31  * @version $Revision: 1.16 $ Updated on: $Date: 2004/02/12 23:59:01 $
32  */

33 public class RemoteJMeterEngineImpl
34     extends java.rmi.server.UnicastRemoteObject JavaDoc
35     implements RemoteJMeterEngine
36 {
37     transient private static Logger log = LoggingManager.getLoggerForClass();
38     JMeterEngine backingEngine;
39
40     public RemoteJMeterEngineImpl() throws RemoteException JavaDoc
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 JavaDoc ex){
52             log.error(
53                 "rmiregistry needs to be running to start JMeter in server " +
54                 "mode\n\t" + ex.toString());
55             // Throw an Exception to ensure caller knows ...
56
throw new RemoteException JavaDoc("Cannot start. See server log file.");
57         }
58     }
59
60     public void setHost(String JavaDoc host)
61     {
62         log.info("received host: "+host);
63         backingEngine.setHost(host);
64     }
65
66     /**
67      * Adds a feature to the ThreadGroup attribute of the RemoteJMeterEngineImpl
68      * object.
69      *
70      * @param testTree the feature to be added to the ThreadGroup attribute
71      */

72     public void configure(HashTree testTree) throws RemoteException JavaDoc
73     {
74         log.info("received test tree");
75         backingEngine.configure(testTree);
76     }
77
78     public void runTest() throws RemoteException JavaDoc, JMeterEngineException
79     {
80         log.info("running test");
81         log.debug("This = "+ this);
82         backingEngine.runTest();
83     }
84
85     public void reset() throws RemoteException JavaDoc
86     {
87         log.info("Reset");
88         backingEngine.reset();
89     }
90
91     public void stopTest() throws RemoteException JavaDoc
92     {
93         log.info("Stopping test");
94         backingEngine.stopTest();//TODO: askThreadsToStop() instead?
95
}
96
97     public void exit() throws RemoteException JavaDoc
98     {
99         log.info("Exitting");
100         backingEngine.exit();
101     }
102     
103     /**
104      * The main program for the RemoteJMeterEngineImpl class.
105      *
106      * @param args the command line arguments
107      */

108     public static void main(String JavaDoc[] 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 JavaDoc ex)
120         {
121             log.error("", ex);
122         }
123
124     }
125 }
126
Popular Tags