org.openanzo.common.rdb.container
Class ContainerConnectionPool

java.lang.Object
  extended by org.openanzo.common.rdb.container.ContainerConnectionPool

public class ContainerConnectionPool
extends java.lang.Object

Manages a pool of RDBConnection objects. Database connections and SQL prepared statements are allocated for each RDBConnection according to the ModelServiceProperties.

Author:
Joe Betz

Constructor Summary
ContainerConnectionPool(java.util.Properties properties, LiteralIndexer literalIndexer)
          Create new ContainerConnectionPool
 
Method Summary
 RDBConnection acquireRDBConnection(int type)
          Get a RDBConnection from the pool
 void clearNodeCaches()
          Clear the caches in all connections
 void close()
          Close a reference to the pool, and if last reference, close the pool
 CacheProvider getCacheProvider()
          Get the cacheProvider
 java.lang.String getDatabaseDriver()
          Get the database driver's class name
 java.lang.String getDatabasePassword()
          Get the database password
 java.lang.String getDatabaseType()
          Get the database type
 java.lang.String getDatabaseUrl()
          Get the database connection URL
 java.lang.String getDatabaseUserName()
          Get the database username
 boolean getIsStarted()
          Determine if the pool is started
 int getQueryConnectionInactiveSize()
          Get the number of inactive connections in the query pool
 int getQueryConnectionInUseSize()
          Get the number of active connections in the query pool
 int getQueryConnectionMaxPoolSize()
          Get the the max number of connections in the query pool
 int getQueryConnectionPoolMaxIdle()
          Get the max idle connections in query pool
 long getQueryConnectionPoolMaxWaitTime()
          Get the max time to wait for a connection in the query pool
 long getQueryConnectionPoolMinIdleTime()
          Get the min idle time for connections in query pool
 java.lang.String getRepositoryInitFile()
          Get the filename for initialization and query file for database
 int getWriteConnectionInactiveSize()
          Get the number of inactive connections in the write pool
 int getWriteConnectionInUseSize()
          Get the number of active connections in the write pool
 int getWriteConnectionMaxPoolSize()
          Get the max number of connections in the write pool
 int getWriteConnectionPoolMaxIdle()
          Get the max idle connections in write pool
 long getWriteConnectionPoolMaxWaitTime()
          Get the max time to wait for a connection in the write pool
 long getWriteConnectionPoolMinIdleTime()
          Get the min idle time for connections in write pool
 void prepareReleaseRDBConnections(int connectionsToPrepare)
          Acquire and release a number of connections
 void purgeAndReset()
          Close all existing pools, and reinitialize with current configuration settings
 void registerMBean(javax.management.ObjectName parentObjectName)
          Register this pool with an MBean server
 void registerResetListener(IResetListener listener)
          Register IResetListener with ContainerConnectionPool
 void releaseRDBConnection(RDBConnection connection)
          Release a RDBConnection to the pool
 void reset(java.lang.Long id)
          Notify all listeners about reset
 void setDatabaseDriver(java.lang.String dbDriver)
          Set the name of the jdbc driver class
 void setDatabasePassword(java.lang.String password)
          Set the database password
 void setDatabaseType(java.lang.String dbType)
          Set the database type
 void setDatabaseUrl(java.lang.String jdbcUrl)
          Set the database connection URL
 void setDatabaseUserName(java.lang.String userName)
          Set the database username
 void setQueryConnectionMaxPoolSize(int size)
          set the max size of the query pool
 void setQueryConnectionPoolMaxIdle(int max)
          Set the max number of idle connections in the query pool
 void setQueryConnectionPoolMaxWaitTime(long maxWait)
          Set the max time to wait for a connection in the query pool
 void setQueryConnectionPoolMinIdleTime(long minWait)
          Set the minimum idle time for connections in the query pool
 void setRepositoryInitFile(java.lang.String dbInitFile)
          Set the filename of the initialization and query file for database
 void setWriteConnectionMaxPoolSize(int size)
          set the max size of the write pool
 void setWriteConnectionPoolMaxIdle(int max)
          Set the max number of idle connections in the write pool
 void setWriteConnectionPoolMaxWaitTime(long maxWait)
          Set the max time to wait for a connection in the write pool
 void setWriteConnectionPoolMinIdleTime(long minWait)
          Set the minimum idle time for connections in the write pool
 void start()
          Start the connection pools
 void stop()
          Stop the connection pools
 void unregisterResetListener(IResetListener listener)
          Unregister IResetListener from ContainerConnectionPool
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContainerConnectionPool

public ContainerConnectionPool(java.util.Properties properties,
                               LiteralIndexer literalIndexer)
Create new ContainerConnectionPool

Parameters:
properties - Configuration properties
literalIndexer - optional literal indexer
Method Detail

start

public void start()
           throws AnzoException
Start the connection pools

Throws:
AnzoException

getIsStarted

public boolean getIsStarted()
                     throws AnzoException
Determine if the pool is started

Returns:
true if pool is started
Throws:
AnzoException

stop

public void stop()
Stop the connection pools


registerMBean

public void registerMBean(javax.management.ObjectName parentObjectName)
Register this pool with an MBean server

Parameters:
parentObjectName - name of parent in MBean server

clearNodeCaches

public void clearNodeCaches()
Clear the caches in all connections


reset

public void reset(java.lang.Long id)
Notify all listeners about reset

Parameters:
id - of server that was reset

prepareReleaseRDBConnections

public void prepareReleaseRDBConnections(int connectionsToPrepare)
                                  throws AnzoException
Acquire and release a number of connections

Parameters:
connectionsToPrepare - Number of connections to prepare and release
Throws:
AnzoException

acquireRDBConnection

public RDBConnection acquireRDBConnection(int type)
                                   throws AnzoException
Get a RDBConnection from the pool

Parameters:
type - Type of RDBConnection to acquire
Returns:
RDBConnection from the pool
Throws:
AnzoException

releaseRDBConnection

public void releaseRDBConnection(RDBConnection connection)
Release a RDBConnection to the pool

Parameters:
connection - RDBConnection to release

close

public void close()
Close a reference to the pool, and if last reference, close the pool


purgeAndReset

public void purgeAndReset()
Close all existing pools, and reinitialize with current configuration settings


getQueryConnectionInUseSize

public int getQueryConnectionInUseSize()
Get the number of active connections in the query pool

Returns:
number of active connections in the query pool

getQueryConnectionInactiveSize

public int getQueryConnectionInactiveSize()
Get the number of inactive connections in the query pool

Returns:
number of inactive connections in the query pool

getQueryConnectionMaxPoolSize

public int getQueryConnectionMaxPoolSize()
Get the the max number of connections in the query pool

Returns:
the max number of connections in the query pool

getWriteConnectionInUseSize

public int getWriteConnectionInUseSize()
Get the number of active connections in the write pool

Returns:
number of active connections in the write pool

getWriteConnectionInactiveSize

public int getWriteConnectionInactiveSize()
Get the number of inactive connections in the write pool

Returns:
number of inactive connections in the write pool

getWriteConnectionMaxPoolSize

public int getWriteConnectionMaxPoolSize()
Get the max number of connections in the write pool

Returns:
the max number of connections in the write pool

setQueryConnectionMaxPoolSize

public void setQueryConnectionMaxPoolSize(int size)
set the max size of the query pool

Parameters:
size - max size of the query pool

setWriteConnectionMaxPoolSize

public void setWriteConnectionMaxPoolSize(int size)
set the max size of the write pool

Parameters:
size - max size of the write pool

getQueryConnectionPoolMaxWaitTime

public long getQueryConnectionPoolMaxWaitTime()
Get the max time to wait for a connection in the query pool

Returns:
the max time to wait for a connection in the query pool

getWriteConnectionPoolMaxWaitTime

public long getWriteConnectionPoolMaxWaitTime()
Get the max time to wait for a connection in the write pool

Returns:
the max time to wait for a connection in the write pool

setQueryConnectionPoolMaxWaitTime

public void setQueryConnectionPoolMaxWaitTime(long maxWait)
Set the max time to wait for a connection in the query pool

Parameters:
maxWait - time

setWriteConnectionPoolMaxWaitTime

public void setWriteConnectionPoolMaxWaitTime(long maxWait)
Set the max time to wait for a connection in the write pool

Parameters:
maxWait - time

getQueryConnectionPoolMaxIdle

public int getQueryConnectionPoolMaxIdle()
Get the max idle connections in query pool

Returns:
the max idle connections in query pool

getQueryConnectionPoolMinIdleTime

public long getQueryConnectionPoolMinIdleTime()
Get the min idle time for connections in query pool

Returns:
the min idle time for connections in query pool

getWriteConnectionPoolMaxIdle

public int getWriteConnectionPoolMaxIdle()
Get the max idle connections in write pool

Returns:
the max idle connections in write pool

getWriteConnectionPoolMinIdleTime

public long getWriteConnectionPoolMinIdleTime()
Get the min idle time for connections in write pool

Returns:
the min idle time for connections in write pool

setQueryConnectionPoolMaxIdle

public void setQueryConnectionPoolMaxIdle(int max)
Set the max number of idle connections in the query pool

Parameters:
max - number of idle connections

setQueryConnectionPoolMinIdleTime

public void setQueryConnectionPoolMinIdleTime(long minWait)
Set the minimum idle time for connections in the query pool

Parameters:
minWait - idle time for connections in the query pool

setWriteConnectionPoolMaxIdle

public void setWriteConnectionPoolMaxIdle(int max)
Set the max number of idle connections in the write pool

Parameters:
max - number of idle connections

setWriteConnectionPoolMinIdleTime

public void setWriteConnectionPoolMinIdleTime(long minWait)
Set the minimum idle time for connections in the write pool

Parameters:
minWait - idle time for connections in the write pool

getDatabaseUrl

public java.lang.String getDatabaseUrl()
Get the database connection URL

Returns:
the database connection URL

getDatabaseUserName

public java.lang.String getDatabaseUserName()
Get the database username

Returns:
the database username

setDatabaseUrl

public void setDatabaseUrl(java.lang.String jdbcUrl)
Set the database connection URL

Parameters:
jdbcUrl - for connections in the pool

setDatabaseUserName

public void setDatabaseUserName(java.lang.String userName)
Set the database username

Parameters:
userName - for database connections

getDatabasePassword

public java.lang.String getDatabasePassword()
Get the database password

Returns:
the database password

setDatabasePassword

public void setDatabasePassword(java.lang.String password)
Set the database password

Parameters:
password - for database connections

getDatabaseDriver

public java.lang.String getDatabaseDriver()
Get the database driver's class name

Returns:
the database driver's class name

setDatabaseDriver

public void setDatabaseDriver(java.lang.String dbDriver)
Set the name of the jdbc driver class

Parameters:
dbDriver - classname of jdbc driver

getDatabaseType

public java.lang.String getDatabaseType()
Get the database type

Returns:
the database type

setDatabaseType

public void setDatabaseType(java.lang.String dbType)
Set the database type

Parameters:
dbType - type of database

getRepositoryInitFile

public java.lang.String getRepositoryInitFile()
Get the filename for initialization and query file for database

Returns:
the filename for initialization and query file for database

setRepositoryInitFile

public void setRepositoryInitFile(java.lang.String dbInitFile)
Set the filename of the initialization and query file for database

Parameters:
dbInitFile - initialization and query file for database

unregisterResetListener

public void unregisterResetListener(IResetListener listener)
Unregister IResetListener from ContainerConnectionPool

Parameters:
listener - Listener to unregister

registerResetListener

public void registerResetListener(IResetListener listener)
Register IResetListener with ContainerConnectionPool

Parameters:
listener - Listener to register

getCacheProvider

public CacheProvider getCacheProvider()
Get the cacheProvider

Returns:
the cacheProvider


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.