001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
004: * Science And Control (INRIA).
005: * Contact: sequoia@continuent.org
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: *
019: * Initial developer(s): Nicolas Modrzyk
020: * Contributor(s):
021: */package org.continuent.sequoia.common.jmx.mbeans;
022:
023: import java.util.List;
024:
025: /**
026: * MBeanInterface to the DatabaseBackend
027: *
028: * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
029: * @version 1.0
030: */
031: public interface DatabaseBackendMBean {
032: /**
033: * Tests if this backend is enabled (active and synchronized).
034: *
035: * @return <code>true</code> if this backend is enabled
036: * @throws Exception if an error occurs
037: */
038: boolean isInitialized() throws Exception;
039:
040: /**
041: * Tests if this backend is read enabled (active and synchronized).
042: *
043: * @return <code>true</code> if this backend is enabled.
044: */
045: boolean isReadEnabled();
046:
047: /**
048: * Tests if this backend is write enabled (active and synchronized).
049: *
050: * @return <code>true</code> if this backend is enabled.
051: */
052: boolean isWriteEnabled();
053:
054: /**
055: * Is the backend completely disabled ? This usually means it has a known
056: * state with a checkpoint associated to it.
057: *
058: * @return <code>true</code> if the backend is disabled
059: */
060: boolean isDisabled();
061:
062: /**
063: * Enables the database backend for reads. This method should only be called
064: * when the backend is synchronized with the others.
065: */
066: void enableRead();
067:
068: /**
069: * Enables the database backend for writes. This method should only be called
070: * when the backend is synchronized with the others.
071: */
072: void enableWrite();
073:
074: /**
075: * Disables the database backend for reads. This does not affect write ability
076: */
077: void disableRead();
078:
079: /**
080: * Disables the database backend for writes. This does not affect read ability
081: * although the backend will not be coherent anymore as soon as a write as
082: * occured. This should be used in conjunction with a checkpoint to recover
083: * missing writes.
084: */
085: void disableWrite();
086:
087: /**
088: * Sets the database backend state to disable. This state is just an
089: * indication and it has no semantic effect. It is up to the request manager
090: * (especially the load balancer) to ensure that no more requests are sent to
091: * this backend.
092: */
093: void disable();
094:
095: /**
096: * Returns the SQL statement to use to check the connection validity.
097: *
098: * @return a <code>String</code> containing a SQL statement
099: */
100: String getConnectionTestStatement();
101:
102: /**
103: * Returns the database native JDBC driver class name.
104: *
105: * @return the driver class name
106: */
107: String getDriverClassName();
108:
109: /**
110: * Returns the backend logical name.
111: *
112: * @return the backend logical name
113: */
114: String getName();
115:
116: /**
117: * Returns a description of the state of the backend
118: *
119: * @see org.continuent.sequoia.common.jmx.notifications.SequoiaNotificationList
120: * @return a string description of the state. Can be enabled, disabled,
121: * recovering, backuping ...
122: */
123: String getState();
124:
125: /**
126: * Return the integer value corresponding to the state of the backend. The
127: * values are defined in <code>BackendState</code>
128: *
129: * @return <tt>int</tt> value
130: * @see org.continuent.sequoia.common.jmx.management.BackendState
131: */
132: int getStateValue();
133:
134: /**
135: * Returns the list of pending requests for this backend.
136: *
137: * @param count number of requests to retrieve, if 0, return all.
138: * @param fromFirst count the request from first if true, or from last if
139: * false
140: * @param clone should clone the pending request if true, block it if false
141: * @return <code>List</code> of <code>String</code> description of
142: * each request.
143: */
144: List getPendingRequestsDescription(int count, boolean fromFirst,
145: boolean clone);
146:
147: /**
148: * Returns the list of active transactions for this backend.
149: *
150: * @return <code>List</code> of <code>Long</code>, corresponding to
151: * active transaction identifier.
152: */
153: List getActiveTransactions();
154:
155: /**
156: * Gets the names of the tables. <b>NOTE</b>: The returned array will contain
157: * only one entry per actual table prefixed by the schema name + "."
158: *
159: * @return the names as an array of <code>Strings</code>, or an empty array
160: * if no tables were found
161: */
162: String[] getTablesNames();
163:
164: /**
165: * Gets the names of the columns.
166: *
167: * @param tableName fully qualified name of the table (with
168: * <code><schema>.</code> prefix)
169: * @return an array containing the columns names, or null if tableName is not
170: * a valid table name.
171: */
172: String[] getColumnsNames(String tableName);
173:
174: /**
175: * Gets a description of the given table locks.
176: *
177: * @param tableName fully qualified name of the table (with
178: * <code><schema>.</code> prefix)
179: * @return a (localized) string containing either "No locks" or "Locked by
180: * <tid>"
181: */
182: String getLockInfo(String tableName);
183:
184: /**
185: * Lists all stored procedures in this schema. <b>Note:</b> There is an issue
186: * with stored procedures with same name (but different parameters): one will
187: * appear with 0 parameters, the 2nd with the total parameters from the 2
188: * stored proc. See SEQUOIA-296 for more info
189: *
190: * @return An array of Strings containing all stored procedure names (one
191: * array entry per procedure)
192: */
193: String[] getStoredProceduresNames();
194:
195: /**
196: * Returns the JDBC URL used to access the database.
197: *
198: * @return a JDBC URL
199: */
200: String getURL();
201:
202: /**
203: * @return Returns the schemaIsStatic.
204: */
205: boolean isSchemaStatic();
206:
207: /**
208: * Returns the driver path.
209: *
210: * @return the driver path
211: */
212: String getDriverPath();
213:
214: /**
215: * Returns the lastKnownCheckpoint value.
216: *
217: * @return Returns the lastKnownCheckpoint.
218: */
219: String getLastKnownCheckpoint();
220:
221: /**
222: * Is the backend accessible ?
223: *
224: * @return <tt>true</tt> if a jdbc connection is still possible from the
225: * controller, <tt>false</tt> if connectionTestStatement failed
226: */
227: boolean isJDBCConnected();
228:
229: /**
230: * The getXml() method does not return the schema if it is not static anymore,
231: * to avoid confusion between static and dynamic schema. This method returns a
232: * static view of the schema, whatever the dynamic precision is.
233: *
234: * @param expandSchema if we should force the schema to be expanded. This is
235: * needed as the default getXml should call this method.
236: * @return an xml formatted string
237: */
238: String getSchemaXml(boolean expandSchema);
239:
240: /**
241: * Return a string description of the backend in xml format. This does not
242: * include the schema description if the dynamic precision is not set to
243: * static.
244: *
245: * @return an xml formatted string
246: */
247: String getXml();
248: }
|