org.apache.avalon.excalibur.datasource.cluster
Interface HashedDataSourceCluster

All Superinterfaces:
Component, Configurable, DataSourceComponent, ThreadSafe
All Known Implementing Classes:
DefaultHashedDataSourceCluster

public interface HashedDataSourceCluster
extends DataSourceComponent

Since:
4.1
Version:
CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:20 $
Author:
Avalon Development Team

Field Summary
static java.lang.String ROLE
          The name of the role for convenience
 
Method Summary
 int getClusterSize()
          Returns the number of DataSources in the cluster.
 java.sql.Connection getConnectionForHashCode(int hashCode)
          Gets a Connection to a database given a hash code.
 java.sql.Connection getConnectionForHashObject(java.lang.Object hashObject)
          Gets a Connection to a database given a hash object.
 java.sql.Connection getConnectionForIndex(int index)
          Gets a Connection to a database given an index.
 int getIndexForHashCode(int hashCode)
          Gets the index which will be resolved for a given hashCode.
 int getIndexForHashObject(java.lang.Object hashObject)
          Gets the index which will be resolved for a given hashCode.
 
Methods inherited from interface org.apache.avalon.excalibur.datasource.DataSourceComponent
getConnection
 
Methods inherited from interface org.apache.avalon.framework.configuration.Configurable
configure
 

Field Detail

ROLE

public static final java.lang.String ROLE
The name of the role for convenience

Method Detail

getClusterSize

public int getClusterSize()
Returns the number of DataSources in the cluster.

Returns:
size of the cluster.

getConnectionForHashObject

public java.sql.Connection getConnectionForHashObject(java.lang.Object hashObject)
                                               throws java.sql.SQLException
Gets a Connection to a database given a hash object.

Parameters:
hashObject - Object whose hashCode will be used to select which of the Clusted DataSources will be provide a Connection.
Throws:
NoValidConnectionException - when there is no valid Connection wrapper available in the classloader or when the index is not valid.
NoAvailableConnectionException - when there are no more available Connections in the pool.
java.sql.SQLException

getConnectionForHashCode

public java.sql.Connection getConnectionForHashCode(int hashCode)
                                             throws java.sql.SQLException
Gets a Connection to a database given a hash code.

Parameters:
hashCode - HashCode which will be used to select which of the Clusted DataSources will be provide a Connection.
Throws:
NoValidConnectionException - when there is no valid Connection wrapper available in the classloader or when the index is not valid.
NoAvailableConnectionException - when there are no more available Connections in the pool.
java.sql.SQLException

getConnectionForIndex

public java.sql.Connection getConnectionForIndex(int index)
                                          throws java.sql.SQLException
Gets a Connection to a database given an index.

Parameters:
index - Index of the DataSource for which a connection is to be returned.
Throws:
NoValidConnectionException - when there is no valid Connection wrapper available in the classloader or when the index is not valid.
NoAvailableConnectionException - when there are no more available Connections in the pool.
java.sql.SQLException

getIndexForHashObject

public int getIndexForHashObject(java.lang.Object hashObject)
Gets the index which will be resolved for a given hashCode. This can be used by user code to optimize the use of DataSource Clusters.

Parameters:
hashObject - Object whose hashCode will be used to select which of the Clusted DataSources will be provide a Connection.

getIndexForHashCode

public int getIndexForHashCode(int hashCode)
Gets the index which will be resolved for a given hashCode. This can be used by user code to optimize the use of DataSource Clusters.

Parameters:
hashCode - HashCode which will be used to select which of the Clusted DataSources will be provide a Connection.


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.