KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > common > jmx > mbeans > DatabaseBackendMBean


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.common.jmx.mbeans;
26
27 import java.util.ArrayList JavaDoc;
28
29 import org.objectweb.cjdbc.common.sql.schema.DatabaseSchema;
30
31 /**
32  * MBeanInterface to the DatabaseBackend
33  *
34  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
35  * @version 1.0
36  */

37 public interface DatabaseBackendMBean
38 {
39   /**
40    * Returns <code>true</code> if this backend has the given list of tables in
41    * its schema. The caller must ensure that the database schema has been
42    * defined
43    *
44    * @param tables the list of table names (<code>ArrayList</code> of
45    * <code>String</code>) to look for
46    * @return <code>true</code> if all the tables are found
47    */

48   boolean hasTables(ArrayList JavaDoc tables);
49
50   /**
51    * Returns <code>true</code> if this backend has the given table in its
52    * schema. The caller must ensure that the database schema has been defined,
53    *
54    * @param table The table name to look for
55    * @return <code>true</code> if tables is found in the schema
56    */

57   boolean hasTable(String JavaDoc table);
58
59   /**
60    * Returns <code>true</code> if this backend has the given stored procedure
61    * in its schema. The caller must ensure that the database schema has been
62    * defined
63    *
64    * @param procedureName The stored procedure name to look for
65    * @return <code>true</code> if procedure name is found in the schema
66    */

67   boolean hasStoredProcedure(String JavaDoc procedureName);
68
69   /**
70    * Tests if this backend is enabled (active and synchronized).
71    *
72    * @return <code>true</code> if this backend is enabled
73    * @throws Exception if an error occurs
74    */

75   boolean isInitialized() throws Exception JavaDoc;
76
77   /**
78    * Tests if this backend is read enabled (active and synchronized).
79    *
80    * @return <code>true</code> if this backend is enabled.
81    */

82   boolean isReadEnabled();
83
84   /**
85    * Tests if this backend is write enabled (active and synchronized).
86    *
87    * @return <code>true</code> if this backend is enabled.
88    */

89   boolean isWriteEnabled();
90
91   /**
92    * Is the backend completely disabled ? This usually means it has a known
93    * state with a checkpoint associated to it.
94    *
95    * @return <code>true</code> if the backend is disabled
96    */

97   boolean isDisabled();
98
99   /**
100    * Enables the database backend for reads. This method should only be called
101    * when the backend is synchronized with the others.
102    */

103   void enableRead();
104
105   /**
106    * Enables the database backend for writes. This method should only be called
107    * when the backend is synchronized with the others.
108    */

109   void enableWrite();
110
111   /**
112    * Disables the database backend for reads. This does not affect write ability
113    */

114   void disableRead();
115
116   /**
117    * Disables the database backend for writes. This does not affect read ability
118    * although the backend will not be coherent anymore as soon as a write as
119    * occured. This should be used in conjunction with a checkpoint to recover
120    * missing writes.
121    */

122   void disableWrite();
123
124   /**
125    * Sets the database backend state to disable. This state is just an
126    * indication and it has no semantic effect. It is up to the request manager
127    * (especially the load balancer) to ensure that no more requests are sent to
128    * this backend.
129    */

130   void disable();
131
132   /**
133    * Returns the SQL statement to use to check the connection validity.
134    *
135    * @return a <code>String</code> containing a SQL statement
136    */

137   String JavaDoc getConnectionTestStatement();
138
139   /**
140    * Returns the database native JDBC driver class name.
141    *
142    * @return the driver class name
143    */

144   String JavaDoc getDriverClassName();
145
146   /**
147    * Returns the backend logical name.
148    *
149    * @return the backend logical name
150    */

151   String JavaDoc getName();
152
153   /**
154    * Returns a description of the state of the backend
155    *
156    * @see org.objectweb.cjdbc.common.jmx.notifications.CjdbcNotificationList
157    * @return a string description of the state. Can be enabled, disabled,
158    * recovering, backuping ...
159    */

160   String JavaDoc getState();
161
162   /**
163    * Returns the list of pending requests for this backend.
164    *
165    * @param count number of requests to retrieve, if 0, return all.
166    * @param fromFirst count the request from first if true, or from last if false
167    * @param clone should clone the pending request if true, block it if false
168    * @return <code>ArrayList</code> of <code>String</code> description of
169    * each request.
170    */

171   ArrayList JavaDoc getPendingRequestsDescription(int count,boolean fromFirst,boolean clone);
172
173   /**
174    * Returns the list of active transactions for this backend.
175    *
176    * @return <code>ArrayList</code> of <code>Long</code>, corresponding to
177    * active transaction identifier.
178    */

179   ArrayList JavaDoc getActiveTransactions();
180
181   /**
182    * Checks that the current database schema is compatible with all schema
183    * gathered from each connection manager.
184    * <p>
185    * If no schema has been defined, the first gathered schema is used as the
186    * current database schema.
187    * <p>
188    * For each schema that is not compatible with the current schema, a warning
189    * is issued on the logger for that backend
190    *
191    * @return true if comptaible, false otherwise
192    */

193   boolean checkDatabaseSchema();
194
195   /**
196    * Returns the schema of this database.
197    *
198    * @return the schema of this database. Returns <code>null</code> if the
199    * schema has not been set.
200    */

201   DatabaseSchema getDatabaseSchema();
202
203   /**
204    * Check if the driver used by this backend is compliant with C-JDBC needs.
205    *
206    * @throws Exception if the driver is not compliant
207    */

208   void checkDriverCompliance() throws Exception JavaDoc;
209
210   /**
211    * Returns the JDBC URL used to access the database.
212    *
213    * @return a JDBC URL
214    */

215   String JavaDoc getURL();
216
217   /**
218    * @return Returns the schemaIsStatic.
219    */

220   boolean isSchemaStatic();
221
222   /**
223    * Returns the driver path.
224    *
225    * @return the driver path
226    */

227   String JavaDoc getDriverPath();
228
229   /**
230    * setLastKnownCheckpoint for this backend
231    *
232    * @param checkpoint the checkpoint
233    */

234   void setLastKnownCheckpoint(String JavaDoc checkpoint);
235
236   /**
237    * Returns the lastKnownCheckpoint value.
238    *
239    * @return Returns the lastKnownCheckpoint.
240    */

241   String JavaDoc getLastKnownCheckpoint();
242
243   /**
244    * Is the backend accessible ?
245    *
246    * @return <tt>true</tt> if a jdbc connection is still possible from the
247    * controller, <tt>false</tt> if connectionTestStatement failed
248    */

249   boolean isJDBCConnected();
250
251   /**
252    * The getXml() method does not return the schema if it is not static anymore,
253    * to avoid confusion between static and dynamic schema. This method returns a
254    * static view of the schema, whatever the dynamic precision is.
255    *
256    * @param expandSchema if we should force the schema to be expanded. This is
257    * needed as the default getXml should call this method.
258    * @return an xml formatted string
259    */

260   String JavaDoc getSchemaXml(boolean expandSchema);
261
262   /**
263    * Return a string description of the backend in xml format. This does not
264    * include the schema description if the dynamic precision is not set to
265    * static.
266    *
267    * @return an xml formatted string
268    */

269   String JavaDoc getXml();
270 }
Popular Tags