KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > hajdbc > DatabaseClusterMBean


1 /*
2  * HA-JDBC: High-Availability JDBC
3  * Copyright (c) 2004-2006 Paul Ferraro
4  *
5  * This library is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by the
7  * Free Software Foundation; either version 2.1 of the License, or (at your
8  * option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: ferraro@users.sourceforge.net
20  */

21 package net.sf.hajdbc;
22
23 import java.util.Collection JavaDoc;
24
25 /**
26  * @author Paul Ferraro
27  * @version $Revision: 977 $
28  * @since 1.0
29  */

30 public interface DatabaseClusterMBean
31 {
32     /**
33      * Returns the name of this database cluster.
34      * @return the database cluster name
35      */

36     public String JavaDoc getId();
37     
38     /**
39      * Determines whether or not the specified database is responsive
40      * @param databaseId a database identifier
41      * @return true, if the database is alive, false otherwise
42      * @throws IllegalArgumentException if no database exists with the specified identifier.
43      */

44     public boolean isAlive(String JavaDoc databaseId);
45     
46     /**
47      * Deactivates the specified database.
48      * @param databaseId a database identifier
49      * @throws IllegalArgumentException if no database exists with the specified identifier.
50      * @throws IllegalStateException if mbean could not be re-registered using inactive database interface.
51      */

52     public void deactivate(String JavaDoc databaseId);
53
54     /**
55      * Synchronizes, using the default strategy, and reactivates the specified database.
56      * @param databaseId a database identifier
57      * @throws IllegalArgumentException if no database exists with the specified identifier.
58      * @throws IllegalStateException if synchronization fails, or if mbean could not be re-registered using active database interface.
59      */

60     public void activate(String JavaDoc databaseId);
61
62     /**
63      * Synchronizes, using the specified strategy, and reactivates the specified database.
64      * @param databaseId a database identifier
65      * @param syncId the class name of a synchronization strategy
66      * @throws IllegalArgumentException if no database exists with the specified identifier, or no synchronization strategy exists with the specified identifier.
67      * @throws IllegalStateException if synchronization fails, or if mbean could not be re-registered using active database interface.
68      */

69     public void activate(String JavaDoc databaseId, String JavaDoc syncId);
70     
71     /**
72      * Returns a collection of active databases in this cluster.
73      * @return a list of database identifiers
74      */

75     public Collection JavaDoc<String JavaDoc> getActiveDatabases();
76     
77     /**
78      * Returns a collection of inactive databases in this cluster.
79      * @return a collection of database identifiers
80      */

81     public Collection JavaDoc<String JavaDoc> getInactiveDatabases();
82     
83     /**
84      * Return the current HA-JDBC version
85      * @return the current version
86      */

87     public String JavaDoc getVersion();
88     
89     /**
90      * Adds a new database to this cluster using the specified identifier, url, and driver.
91      * @param databaseId a database identifier
92      * @param url a JDBC url
93      * @param driver a JDBC driver class name
94      * @throws IllegalArgumentException if this database already exists, if the specified driver is invalid, or if the specified url is invalid.
95      * @throws IllegalStateException if mbean registration fails.
96      */

97     public void add(String JavaDoc databaseId, String JavaDoc driver, String JavaDoc url);
98     
99     /**
100      * Adds a new DataSource to this cluster using the specified identifier and JNDI name.
101      * @param databaseId a database identifier
102      * @param name the JNDI name use to lookup the DataSource
103      * @throws IllegalArgumentException if this database already exists, or no DataSource was found using the specified name.
104      * @throws IllegalStateException if mbean registration fails.
105      */

106     public void add(String JavaDoc databaseId, String JavaDoc name);
107     
108     /**
109      * Removes the specified database/DataSource from the cluster.
110      * @param databaseId a database identifier
111      * @throws IllegalStateException if database is still active, or if mbean unregistration fails.
112      */

113     public void remove(String JavaDoc databaseId);
114 }
115
Popular Tags