KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > scenario > tools > components > ComponentManagerInterface


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk.
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.scenario.tools.components;
26
27 /**
28  * This class defines a ComponentManagerInterface. This class is used to start,
29  * stop, management configuration of classes that implements the
30  * <code>ComponentInterface</code> interface. <br>
31  * Typically, this will be used to start database backends and controller,
32  * load database configuration (virtual or not) and simulate failure by
33  * stopping the component straight away or after a given time.<br>
34  *
35  *
36  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
37  * @version 1.0
38  */

39 public interface ComponentManagerInterface
40 {
41   /**
42    * Instaciate a process managed by this component manager on the given port
43    * This used the default configuration file returned by the
44    * <code>getDefaultConfigurationFile</code> method
45    *
46    * @param port port to start the process on
47    * @return a reference to the newly started component
48    * @throws Exception if fails
49    */

50   ComponentInterface instanciateProcess(String JavaDoc port) throws Exception JavaDoc;
51
52   /**
53    * Instaciate a process managed by this component manager on the given port
54    *
55    * @param port port to start the process on
56    * @param configurationFile used to instanciate the process
57    * @return a reference to the newly started component
58    * @throws Exception if fails
59    */

60   ComponentInterface instanciateProcess(String JavaDoc port, String JavaDoc configurationFile)
61       throws Exception JavaDoc;
62
63   /**
64    * The default configuration file to use with this component manager. This
65    * should be specific to each component manager
66    *
67    * @return the default filename
68    */

69   String JavaDoc getDefaultConfigurationFile();
70
71   /**
72    * Starts component on the given port with the given database
73    *
74    * @param port to run hsql on
75    * @param database to load component with
76    * @return created process
77    * @throws Exception if fails to create process
78    */

79   ComponentInterface startComponent(String JavaDoc port, String JavaDoc database)
80       throws Exception JavaDoc;
81
82   /**
83    * Starts component on the given port
84    *
85    * @param port to run component on
86    * @return created process
87    * @throws Exception if fails to create process
88    */

89   ComponentInterface startComponent(String JavaDoc port) throws Exception JavaDoc;
90
91   /**
92    * Check if can open a connection on localhost on the given port
93    *
94    * @param port to open a socket for check
95    * @throws Exception if fails
96    */

97   void waitForStarted(String JavaDoc port) throws Exception JavaDoc;
98
99   /**
100    * Wait for the component to stop
101    *
102    * @param port to check the connection on
103    * @throws Exception if fails
104    */

105   void waitForStopped(String JavaDoc port) throws Exception JavaDoc;
106
107   /**
108    * Check if can open a connection on localhost on the given port
109    *
110    * @param port to open a socket for check
111    * @return true if can connect, false if exception or can't connect
112    */

113   boolean isStarted(String JavaDoc port);
114
115   /**
116    * fill the database with raidb1 default configuration
117    *
118    * @param port of the database
119    * @throws Exception if fails
120    */

121   void loaddatabase(String JavaDoc port) throws Exception JavaDoc;
122
123   /**
124    * Load the database with a given input file
125    *
126    * @param port of the database to load
127    * @param templateName name of the file to load(NO PATH!)
128    * @throws Exception if fails
129    */

130   void loaddatabase(String JavaDoc port, String JavaDoc templateName) throws Exception JavaDoc;
131
132   /**
133    * Stop Hsql. Destroy the process so it looks like a failure.
134    *
135    * @param process to stop
136    */

137   void stop(ComponentInterface process);
138
139   /**
140    * Stop a component from its unique port number
141    *
142    * @param componentOnPort port number of the component to stop
143    */

144   void stop(String JavaDoc componentOnPort);
145
146   /**
147    * Same as stop(String)
148    *
149    * @param port port number
150    */

151   void stop(int port);
152
153   /**
154    * Simulate a failure of the component by stopping it after the given time.
155    *
156    * @param port the port of the component to stop
157    * @param wait the wait time before stopping it
158    * @param rand should we use a random time, if so, the previous argument is
159    * used as a range
160    */

161   void simulateFailure(String JavaDoc port, long wait, boolean rand);
162
163   /**
164    * Simulate a failure of the component by stopping it after the given time.
165    *
166    * @param port the port of the component to stop
167    * @param wait the wait time before stopping it
168    * @param rand should we use a random time, if so, the previous argument is
169    * used as a range
170    */

171   void simulateFailure(int port, long wait, boolean rand);
172
173   /**
174    * Stops all process contained in this manager
175    */

176   void stopAll();
177
178   /**
179    * Starts database component on the given port with the given database
180    *
181    * @param port to run component on
182    * @param database to load component with
183    * @return created process
184    * @throws Exception if fails to create process
185    */

186   ComponentInterface start(String JavaDoc port, String JavaDoc database) throws Exception JavaDoc;
187
188   /**
189    * Starts database component on the given port with the default configuration
190    *
191    * @param port to run component on
192    * @return created process
193    * @throws Exception if fails to create process
194    */

195   ComponentInterface start(String JavaDoc port) throws Exception JavaDoc;
196
197   /**
198    * release files and processes owned by manager
199    */

200   void release();
201 }
Popular Tags