001: /*
002: * HA-JDBC: High-Availability JDBC
003: * Copyright (c) 2004-2007 Paul Ferraro
004: *
005: * This library is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU Lesser General Public License as published by the
007: * Free Software Foundation; either version 2.1 of the License, or (at your
008: * option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful, but WITHOUT
011: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
013: * for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public License
016: * along with this library; if not, write to the Free Software Foundation,
017: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * Contact: ferraro@users.sourceforge.net
020: */
021: package net.sf.hajdbc;
022:
023: import java.net.URL;
024: import java.util.Set;
025:
026: /**
027: * @author Paul Ferraro
028: * @version $Revision: 1679 $
029: * @since 1.0
030: */
031: public interface DatabaseClusterMBean {
032: /**
033: * Determines whether or not the specified database is responsive
034: * @param databaseId a database identifier
035: * @return true, if the database is alive, false otherwise
036: * @throws IllegalArgumentException if no database exists with the specified identifier.
037: */
038: public boolean isAlive(String databaseId);
039:
040: /**
041: * Deactivates the specified database.
042: * @param databaseId a database identifier
043: * @throws IllegalArgumentException if no database exists with the specified identifier.
044: * @throws IllegalStateException if mbean could not be re-registered using inactive database interface.
045: */
046: public void deactivate(String databaseId);
047:
048: /**
049: * Synchronizes, using the default strategy, and reactivates the specified database.
050: * @param databaseId a database identifier
051: * @throws IllegalArgumentException if no database exists with the specified identifier.
052: * @throws IllegalStateException if synchronization fails, or if mbean could not be re-registered using active database interface.
053: */
054: public void activate(String databaseId);
055:
056: /**
057: * Synchronizes, using the specified strategy, and reactivates the specified database.
058: * @param databaseId a database identifier
059: * @param syncId the class name of a synchronization strategy
060: * @throws IllegalArgumentException if no database exists with the specified identifier, or no synchronization strategy exists with the specified identifier.
061: * @throws IllegalStateException if synchronization fails, or if mbean could not be re-registered using active database interface.
062: */
063: public void activate(String databaseId, String syncId);
064:
065: /**
066: * Returns a collection of active databases in this cluster.
067: * @return a list of database identifiers
068: */
069: public Set<String> getActiveDatabases();
070:
071: /**
072: * Returns a collection of inactive databases in this cluster.
073: * @return a collection of database identifiers
074: */
075: public Set<String> getInactiveDatabases();
076:
077: /**
078: * Return the current HA-JDBC version
079: * @return the current version
080: */
081: public String getVersion();
082:
083: /**
084: * Removes the specified database/DataSource from the cluster.
085: * @param databaseId a database identifier
086: * @throws IllegalStateException if database is still active, or if mbean unregistration fails.
087: */
088: public void remove(String databaseId);
089:
090: /**
091: * Flushes this cluster's cache of DatabaseMetaData.
092: */
093: public void flushMetaDataCache();
094:
095: /**
096: * Returns the set of synchronization strategies available to this cluster.
097: * @return a set of synchronization strategy identifiers
098: */
099: public Set<String> getSynchronizationStrategies();
100:
101: /**
102: * Returns the default synchronization strategy used by this cluster.
103: * @return a synchronization strategy identifier
104: */
105: public String getDefaultSynchronizationStrategy();
106:
107: /**
108: * Returns the URL of the configuration file for this cluster.
109: * @return a URL
110: */
111: public URL getUrl();
112:
113: /**
114: * Provided so that mbean proxies will use mbean toString() implementation
115: * @return string representation of this cluster
116: */
117: public String toString();
118: }
|