00001 /** 00002 * C-JDBC: Clustered JDBC. 00003 * Copyright (C) 2002-2004 French National Institute For Research In Computer 00004 * Science And Control (INRIA). 00005 * Contact: c-jdbc@objectweb.org 00006 * 00007 * This library is free software; you can redistribute it and/or modify it 00008 * under the terms of the GNU Lesser General Public License as published by the 00009 * Free Software Foundation; either version 2.1 of the License, or any later 00010 * version. 00011 * 00012 * This library is distributed in the hope that it will be useful, but WITHOUT 00013 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 00015 * for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public License 00018 * along with this library; if not, write to the Free Software Foundation, 00019 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00020 * 00021 * Initial developer(s): Nicolas Modrzyk 00022 * Contributor(s): 00023 */ 00024 00025 package org.objectweb.cjdbc.common.jmx.mbeans; 00026 00027 import java.util.ArrayList; 00028 00029 import org.objectweb.cjdbc.common.sql.schema.DatabaseSchema; 00030 00031 /** 00032 * MBeanInterface to the DatabaseBackend 00033 * 00034 * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a> 00035 * @version 1.0 00036 */ 00037 public interface DatabaseBackendMBean 00038 { 00039 /** 00040 * Returns <code>true</code> if this backend has the given list of tables in 00041 * its schema. The caller must ensure that the database schema has been 00042 * defined 00043 * 00044 * @param tables the list of table names (<code>ArrayList</code> of 00045 * <code>String</code>) to look for 00046 * @return <code>true</code> if all the tables are found 00047 */ 00048 boolean hasTables(ArrayList tables); 00049 00050 /** 00051 * Returns <code>true</code> if this backend has the given table in its 00052 * schema. The caller must ensure that the database schema has been defined, 00053 * 00054 * @param table The table name to look for 00055 * @return <code>true</code> if tables is found in the schema 00056 */ 00057 boolean hasTable(String table); 00058 00059 /** 00060 * Returns <code>true</code> if this backend has the given stored procedure 00061 * in its schema. The caller must ensure that the database schema has been 00062 * defined 00063 * 00064 * @param procedureName The stored procedure name to look for 00065 * @return <code>true</code> if procedure name is found in the schema 00066 */ 00067 boolean hasStoredProcedure(String procedureName); 00068 00069 /** 00070 * Tests if this backend is enabled (active and synchronized). 00071 * 00072 * @return <code>true</code> if this backend is enabled 00073 * @throws Exception if an error occurs 00074 */ 00075 boolean isInitialized() throws Exception; 00076 00077 /** 00078 * Tests if this backend is read enabled (active and synchronized). 00079 * 00080 * @return <code>true</code> if this backend is enabled. 00081 */ 00082 boolean isReadEnabled(); 00083 00084 /** 00085 * Tests if this backend is write enabled (active and synchronized). 00086 * 00087 * @return <code>true</code> if this backend is enabled. 00088 */ 00089 boolean isWriteEnabled(); 00090 00091 /** 00092 * Is the backend completely disabled ? This usually means it has a known 00093 * state with a checkpoint associated to it. 00094 * 00095 * @return <code>true</code> if the backend is disabled 00096 */ 00097 boolean isDisabled(); 00098 00099 /** 00100 * Enables the database backend for reads. This method should only be called 00101 * when the backend is synchronized with the others. 00102 */ 00103 void enableRead(); 00104 00105 /** 00106 * Enables the database backend for writes. This method should only be called 00107 * when the backend is synchronized with the others. 00108 */ 00109 void enableWrite(); 00110 00111 /** 00112 * Disables the database backend for reads. This does not affect write ability 00113 */ 00114 void disableRead(); 00115 00116 /** 00117 * Disables the database backend for writes. This does not affect read ability 00118 * although the backend will not be coherent anymore as soon as a write as 00119 * occured. This should be used in conjunction with a checkpoint to recover 00120 * missing writes. 00121 */ 00122 void disableWrite(); 00123 00124 /** 00125 * Sets the database backend state to disable. This state is just an 00126 * indication and it has no semantic effect. It is up to the request manager 00127 * (especially the load balancer) to ensure that no more requests are sent to 00128 * this backend. 00129 */ 00130 void disable(); 00131 00132 /** 00133 * Returns the SQL statement to use to check the connection validity. 00134 * 00135 * @return a <code>String</code> containing a SQL statement 00136 */ 00137 String getConnectionTestStatement(); 00138 00139 /** 00140 * Returns the database native JDBC driver class name. 00141 * 00142 * @return the driver class name 00143 */ 00144 String getDriverClassName(); 00145 00146 /** 00147 * Returns the backend logical name. 00148 * 00149 * @return the backend logical name 00150 */ 00151 String getName(); 00152 00153 /** 00154 * Returns a description of the state of the backend 00155 * 00156 * @see org.objectweb.cjdbc.common.jmx.notifications.CjdbcNotificationList 00157 * @return a string description of the state. Can be enabled, disabled, 00158 * recovering, backuping ... 00159 */ 00160 String getState(); 00161 00162 /** 00163 * Returns the list of pending requests for this backend. 00164 * 00165 * @param count number of requests to retrieve, if 0, return all. 00166 * @param fromFirst count the request from first if true, or from last if false 00167 * @param clone should clone the pending request if true, block it if false 00168 * @return <code>ArrayList</code> of <code>String</code> description of 00169 * each request. 00170 */ 00171 ArrayList getPendingRequestsDescription(int count,boolean fromFirst,boolean clone); 00172 00173 /** 00174 * Returns the list of active transactions for this backend. 00175 * 00176 * @return <code>ArrayList</code> of <code>Long</code>, corresponding to 00177 * active transaction identifier. 00178 */ 00179 ArrayList getActiveTransactions(); 00180 00181 /** 00182 * Checks that the current database schema is compatible with all schema 00183 * gathered from each connection manager. 00184 * <p> 00185 * If no schema has been defined, the first gathered schema is used as the 00186 * current database schema. 00187 * <p> 00188 * For each schema that is not compatible with the current schema, a warning 00189 * is issued on the logger for that backend 00190 * 00191 * @return true if comptaible, false otherwise 00192 */ 00193 boolean checkDatabaseSchema(); 00194 00195 /** 00196 * Returns the schema of this database. 00197 * 00198 * @return the schema of this database. Returns <code>null</code> if the 00199 * schema has not been set. 00200 */ 00201 DatabaseSchema getDatabaseSchema(); 00202 00203 /** 00204 * Check if the driver used by this backend is compliant with C-JDBC needs. 00205 * 00206 * @throws Exception if the driver is not compliant 00207 */ 00208 void checkDriverCompliance() throws Exception; 00209 00210 /** 00211 * Returns the JDBC URL used to access the database. 00212 * 00213 * @return a JDBC URL 00214 */ 00215 String getURL(); 00216 00217 /** 00218 * @return Returns the schemaIsStatic. 00219 */ 00220 boolean isSchemaStatic(); 00221 00222 /** 00223 * Returns the driver path. 00224 * 00225 * @return the driver path 00226 */ 00227 String getDriverPath(); 00228 00229 /** 00230 * setLastKnownCheckpoint for this backend 00231 * 00232 * @param checkpoint the checkpoint 00233 */ 00234 void setLastKnownCheckpoint(String checkpoint); 00235 00236 /** 00237 * Returns the lastKnownCheckpoint value. 00238 * 00239 * @return Returns the lastKnownCheckpoint. 00240 */ 00241 String getLastKnownCheckpoint(); 00242 00243 /** 00244 * Is the backend accessible ? 00245 * 00246 * @return <tt>true</tt> if a jdbc connection is still possible from the 00247 * controller, <tt>false</tt> if connectionTestStatement failed 00248 */ 00249 boolean isJDBCConnected(); 00250 00251 /** 00252 * The getXml() method does not return the schema if it is not static anymore, 00253 * to avoid confusion between static and dynamic schema. This method returns a 00254 * static view of the schema, whatever the dynamic precision is. 00255 * 00256 * @param expandSchema if we should force the schema to be expanded. This is 00257 * needed as the default getXml should call this method. 00258 * @return an xml formatted string 00259 */ 00260 String getSchemaXml(boolean expandSchema); 00261 00262 /** 00263 * Return a string description of the backend in xml format. This does not 00264 * include the schema description if the dynamic precision is not set to 00265 * static. 00266 * 00267 * @return an xml formatted string 00268 */ 00269 String getXml(); 00270 }