org.openanzo.server.repository.rdb
Class RepositoryConnectionPool

java.lang.Object
  extended by org.openanzo.server.repository.rdb.RepositoryConnectionPool
All Implemented Interfaces:
IServerService, RepositoryConnectionPoolMBean

public class RepositoryConnectionPool
extends java.lang.Object
implements RepositoryConnectionPoolMBean, IServerService

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

Author:
Joe Betz

Constructor Summary
RepositoryConnectionPool(java.util.Properties properties)
          Create new ContainerConnectionPool
 
Method Summary
 RepositoryConnection acquireRepositoryConnection(int type)
          Get a repositoryConnection from the pool
 void clearNodeCaches()
          Clear the caches in all connections
 void close()
          Close the service
 int decrementUsageCount()
          Decrement the usage count for the pool
 CacheProvider getCacheProvider()
           
 java.lang.String getDatabaseDriver()
          Get the database driver's class name
 java.lang.String getDatabasePassword()
          Get the password for the database connection
 java.lang.String getDatabaseType()
          Get the type of database connection
 java.lang.String getDatabaseUrl()
          Get the database JDBC URL
 java.lang.String getDatabaseUserName()
          Get the username for the database connection
 boolean getIsStarted()
          Determine if the service is started
 int getQueryConnectionInactiveSize()
          Get the number of inactive connections in the QUERY connection pool
 int getQueryConnectionInUseSize()
          Get the number of connections currently in-use from the QUERY connection pool
 int getQueryConnectionMaxPoolSize()
          Get the max size of the QUERY connection pool
 int getQueryConnectionPoolMaxIdle()
          Get the max number of idle connections in the QUERY connection pool
 long getQueryConnectionPoolMaxWaitTime()
          Get max time to wait for a connection from the QUERY connection pool
 long getQueryConnectionPoolMinIdleTime()
          Get minimum time to wait before an idle connection from the QUERY connection pool is destroyed
 int getReadConnectionInactiveSize()
          Get the number of inactive connections in the READ connection pool
 int getReadConnectionInUseSize()
          Get the number of connections currently in-use from the READ connection pool
 int getReadConnectionMaxPoolSize()
          Get the max size of the READ connection pool
 int getReadConnectionPoolMaxIdle()
          Get the max number of idle connections in the READ connection pool
 long getReadConnectionPoolMaxWaitTime()
          Get max time to wait for a connection from the READ connection pool
 long getReadConnectionPoolMinIdleTime()
          Get minimum time to wait before an idle connection from the READ connection pool is destroyed
 int getUsageCount()
          Get the current usage count
 int getWriteConnectionInactiveSize()
          Get the number of inactive connections in the WRITE connection pool
 int getWriteConnectionInUseSize()
          Get the number of connections currently in-use from the WRITE connection pool
 int getWriteConnectionMaxPoolSize()
          Get the max size of the WRITE connection pool
 int getWriteConnectionPoolMaxIdle()
          Get the max number of idle connections in the WRITE connection pool
 long getWriteConnectionPoolMaxWaitTime()
          Get max time to wait for a connection from the WRITE connection pool
 long getWriteConnectionPoolMinIdleTime()
          Get minimum time to wait before an idle connection from the WRITE connection pool is destroyed
 int incrementUsageCount()
          Increment the usage count for the pool
 void prepareReleaseRepositoryConnections(int connectionsToPrepare)
          Acquire and release a number of rw and ro connection
 void purgeAndReset()
          Function to purge all connections in pool, and restart using current configuration values
 void registerMBean(javax.management.MBeanServer mbs, javax.management.ObjectName parentObjectName)
          Register the service with the server's jmx server
 void registerResetListener(IResetListener listener)
          Register IResetListener with ContainerConnectionPool
 void releaseRepositoryConnection(RepositoryConnection connection)
          Release a repositoryConnection from the pool
 void reset(java.lang.Long id)
          Notify all listeners about a database reset
 void setDatabaseDriver(java.lang.String dbDriver)
          Set the database driver's class name
 void setDatabasePassword(java.lang.String password)
          Set the password for the database connection
 void setDatabaseType(java.lang.String dbType)
          Set the type of database connection
 void setDatabaseUrl(java.lang.String jdbcUrl)
          Set the database JDBC URL
 void setDatabaseUserName(java.lang.String userName)
          Set the username for the database connection
 void setLiteralIndexer(LiteralIndexer literalIndexer)
          Set the literal index which this pool of connections can use
 void setQueryConnectionMaxPoolSize(int size)
          Set the max size of the QUERY connection pool
 void setQueryConnectionPoolMaxIdle(int max)
          Set the max number of idle connections in the QUERY connection pool
 void setQueryConnectionPoolMaxWaitTime(long maxWait)
          Get set the max time to wait for a connection from the QUERY connection pool
 void setQueryConnectionPoolMinIdleTime(long minWait)
          Set minimum time to wait before an idle connection from the QUERY connection pool is destroyed
 void setReadConnectionMaxPoolSize(int size)
          Set the max size of the READ connection pool
 void setReadConnectionPoolMaxIdle(int max)
          Set the max number of idle connections in the READ connection pool
 void setReadConnectionPoolMaxWaitTime(long maxWait)
          Get set the max time to wait for a connection from the READ connection pool
 void setReadConnectionPoolMinIdleTime(long minWait)
          Set minimum time to wait before an idle connection from the READ connection pool is destroyed
 void setWriteConnectionMaxPoolSize(int size)
          Set the max size of the WRITE connection pool
 void setWriteConnectionPoolMaxIdle(int max)
          Set the max number of idle connections in the WRITE connection pool
 void setWriteConnectionPoolMaxWaitTime(long maxWait)
          Get set the max time to wait for a connection from the WRITE connection pool
 void setWriteConnectionPoolMinIdleTime(long minWait)
          Set minimum time to wait before an idle connection from the WRITE connection pool is destroyed
 void start()
          Start the service
 void stop()
          Stop the service
 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

RepositoryConnectionPool

public RepositoryConnectionPool(java.util.Properties properties)
Create new ContainerConnectionPool

Parameters:
properties - Configuration properties
Method Detail

setLiteralIndexer

public void setLiteralIndexer(LiteralIndexer literalIndexer)
Set the literal index which this pool of connections can use

Parameters:
literalIndexer -

start

public void start()
           throws AnzoException
Description copied from interface: IServerService
Start the service

Specified by:
start in interface IServerService
Throws:
AnzoException

getIsStarted

public boolean getIsStarted()
                     throws AnzoException
Description copied from interface: IServerService
Determine if the service is started

Specified by:
getIsStarted in interface IServerService
Returns:
true if the service is started
Throws:
AnzoException

stop

public void stop()
Description copied from interface: IServerService
Stop the service

Specified by:
stop in interface IServerService

registerMBean

public void registerMBean(javax.management.MBeanServer mbs,
                          javax.management.ObjectName parentObjectName)
Description copied from interface: IServerService
Register the service with the server's jmx server

Specified by:
registerMBean in interface IServerService
Parameters:
mbs - the jmx server
parentObjectName - the name under which this object will be registered

clearNodeCaches

public void clearNodeCaches()
Clear the caches in all connections


reset

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

Parameters:
id - of server being reset

prepareReleaseRepositoryConnections

public void prepareReleaseRepositoryConnections(int connectionsToPrepare)
                                         throws AnzoException
Acquire and release a number of rw and ro connection

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

acquireRepositoryConnection

public RepositoryConnection acquireRepositoryConnection(int type)
                                                 throws AnzoException
Get a repositoryConnection from the pool

Parameters:
type - Type of RepositoryConnection to acquire
Returns:
a repositoryConnection from the pool
Throws:
AnzoException

releaseRepositoryConnection

public void releaseRepositoryConnection(RepositoryConnection connection)
Release a repositoryConnection from the pool

Parameters:
connection - RepositoryConnection to release

registerResetListener

public void registerResetListener(IResetListener listener)
Register IResetListener with ContainerConnectionPool

Parameters:
listener - Listener to register

unregisterResetListener

public void unregisterResetListener(IResetListener listener)
Unregister IResetListener from ContainerConnectionPool

Parameters:
listener - Listener to unregister

incrementUsageCount

public int incrementUsageCount()
Increment the usage count for the pool

Returns:
incremented usage count

decrementUsageCount

public int decrementUsageCount()
Decrement the usage count for the pool

Returns:
decremented usage count

getUsageCount

public int getUsageCount()
Get the current usage count

Returns:
the current usage count

close

public void close()
Description copied from interface: IServerService
Close the service

Specified by:
close in interface IServerService

purgeAndReset

public void purgeAndReset()
Description copied from interface: RepositoryConnectionPoolMBean
Function to purge all connections in pool, and restart using current configuration values

Specified by:
purgeAndReset in interface RepositoryConnectionPoolMBean

getQueryConnectionInUseSize

public int getQueryConnectionInUseSize()
Description copied from interface: RepositoryConnectionPoolMBean
Get the number of connections currently in-use from the QUERY connection pool

Specified by:
getQueryConnectionInUseSize in interface RepositoryConnectionPoolMBean
Returns:
the number of connections currently in-use from the QUERY connection pool

getQueryConnectionInactiveSize

public int getQueryConnectionInactiveSize()
Description copied from interface: RepositoryConnectionPoolMBean
Get the number of inactive connections in the QUERY connection pool

Specified by:
getQueryConnectionInactiveSize in interface RepositoryConnectionPoolMBean
Returns:
the number of inactive connections in the QUERY connection pool

getQueryConnectionMaxPoolSize

public int getQueryConnectionMaxPoolSize()
Description copied from interface: RepositoryConnectionPoolMBean
Get the max size of the QUERY connection pool

Specified by:
getQueryConnectionMaxPoolSize in interface RepositoryConnectionPoolMBean
Returns:
the max size of the QUERY connection pool

getReadConnectionInUseSize

public int getReadConnectionInUseSize()
Description copied from interface: RepositoryConnectionPoolMBean
Get the number of connections currently in-use from the READ connection pool

Specified by:
getReadConnectionInUseSize in interface RepositoryConnectionPoolMBean
Returns:
the number of connections currently in-use from the READ connection pool

getReadConnectionInactiveSize

public int getReadConnectionInactiveSize()
Description copied from interface: RepositoryConnectionPoolMBean
Get the number of inactive connections in the READ connection pool

Specified by:
getReadConnectionInactiveSize in interface RepositoryConnectionPoolMBean
Returns:
the number of inactive connections in the READ connection pool

getReadConnectionMaxPoolSize

public int getReadConnectionMaxPoolSize()
Description copied from interface: RepositoryConnectionPoolMBean
Get the max size of the READ connection pool

Specified by:
getReadConnectionMaxPoolSize in interface RepositoryConnectionPoolMBean
Returns:
the max size of the READ connection pool

getWriteConnectionInUseSize

public int getWriteConnectionInUseSize()
Description copied from interface: RepositoryConnectionPoolMBean
Get the number of connections currently in-use from the WRITE connection pool

Specified by:
getWriteConnectionInUseSize in interface RepositoryConnectionPoolMBean
Returns:
the number of connections currently in-use from the WRITE connection pool

getWriteConnectionInactiveSize

public int getWriteConnectionInactiveSize()
Description copied from interface: RepositoryConnectionPoolMBean
Get the number of inactive connections in the WRITE connection pool

Specified by:
getWriteConnectionInactiveSize in interface RepositoryConnectionPoolMBean
Returns:
the number of inactive connections in the WRITE connection pool

getWriteConnectionMaxPoolSize

public int getWriteConnectionMaxPoolSize()
Description copied from interface: RepositoryConnectionPoolMBean
Get the max size of the WRITE connection pool

Specified by:
getWriteConnectionMaxPoolSize in interface RepositoryConnectionPoolMBean
Returns:
the max size of the WRITE connection pool

setQueryConnectionMaxPoolSize

public void setQueryConnectionMaxPoolSize(int size)
Description copied from interface: RepositoryConnectionPoolMBean
Set the max size of the QUERY connection pool

Specified by:
setQueryConnectionMaxPoolSize in interface RepositoryConnectionPoolMBean
Parameters:
size - the max size of the QUERY connection pool

setReadConnectionMaxPoolSize

public void setReadConnectionMaxPoolSize(int size)
Description copied from interface: RepositoryConnectionPoolMBean
Set the max size of the READ connection pool

Specified by:
setReadConnectionMaxPoolSize in interface RepositoryConnectionPoolMBean
Parameters:
size - the max size of the READ connection pool

setWriteConnectionMaxPoolSize

public void setWriteConnectionMaxPoolSize(int size)
Description copied from interface: RepositoryConnectionPoolMBean
Set the max size of the WRITE connection pool

Specified by:
setWriteConnectionMaxPoolSize in interface RepositoryConnectionPoolMBean
Parameters:
size - the max size of the WRITE connection pool

getQueryConnectionPoolMaxWaitTime

public long getQueryConnectionPoolMaxWaitTime()
Description copied from interface: RepositoryConnectionPoolMBean
Get max time to wait for a connection from the QUERY connection pool

Specified by:
getQueryConnectionPoolMaxWaitTime in interface RepositoryConnectionPoolMBean
Returns:
max time to wait for a connection from the QUERY connection pool

getReadConnectionPoolMaxWaitTime

public long getReadConnectionPoolMaxWaitTime()
Description copied from interface: RepositoryConnectionPoolMBean
Get max time to wait for a connection from the READ connection pool

Specified by:
getReadConnectionPoolMaxWaitTime in interface RepositoryConnectionPoolMBean
Returns:
max time to wait for a connection from the READ connection pool

getWriteConnectionPoolMaxWaitTime

public long getWriteConnectionPoolMaxWaitTime()
Description copied from interface: RepositoryConnectionPoolMBean
Get max time to wait for a connection from the WRITE connection pool

Specified by:
getWriteConnectionPoolMaxWaitTime in interface RepositoryConnectionPoolMBean
Returns:
max time to wait for a connection from the WRITE connection pool

setQueryConnectionPoolMaxWaitTime

public void setQueryConnectionPoolMaxWaitTime(long maxWait)
Description copied from interface: RepositoryConnectionPoolMBean
Get set the max time to wait for a connection from the QUERY connection pool

Specified by:
setQueryConnectionPoolMaxWaitTime in interface RepositoryConnectionPoolMBean
Parameters:
maxWait - max time to wait for a connection from the QUERY connection pool

setReadConnectionPoolMaxWaitTime

public void setReadConnectionPoolMaxWaitTime(long maxWait)
Description copied from interface: RepositoryConnectionPoolMBean
Get set the max time to wait for a connection from the READ connection pool

Specified by:
setReadConnectionPoolMaxWaitTime in interface RepositoryConnectionPoolMBean
Parameters:
maxWait - max time to wait for a connection from the READ connection pool

setWriteConnectionPoolMaxWaitTime

public void setWriteConnectionPoolMaxWaitTime(long maxWait)
Description copied from interface: RepositoryConnectionPoolMBean
Get set the max time to wait for a connection from the WRITE connection pool

Specified by:
setWriteConnectionPoolMaxWaitTime in interface RepositoryConnectionPoolMBean
Parameters:
maxWait - max time to wait for a connection from the WRITE connection pool

getQueryConnectionPoolMaxIdle

public int getQueryConnectionPoolMaxIdle()
Description copied from interface: RepositoryConnectionPoolMBean
Get the max number of idle connections in the QUERY connection pool

Specified by:
getQueryConnectionPoolMaxIdle in interface RepositoryConnectionPoolMBean
Returns:
the max number of idle connections in the QUERY connection pool

getQueryConnectionPoolMinIdleTime

public long getQueryConnectionPoolMinIdleTime()
Description copied from interface: RepositoryConnectionPoolMBean
Get minimum time to wait before an idle connection from the QUERY connection pool is destroyed

Specified by:
getQueryConnectionPoolMinIdleTime in interface RepositoryConnectionPoolMBean
Returns:
minimum time to wait before an idle connection from the QUERY connection pool is destroyed

getReadConnectionPoolMaxIdle

public int getReadConnectionPoolMaxIdle()
Description copied from interface: RepositoryConnectionPoolMBean
Get the max number of idle connections in the READ connection pool

Specified by:
getReadConnectionPoolMaxIdle in interface RepositoryConnectionPoolMBean
Returns:
the max number of idle connections in the READ connection pool

getReadConnectionPoolMinIdleTime

public long getReadConnectionPoolMinIdleTime()
Description copied from interface: RepositoryConnectionPoolMBean
Get minimum time to wait before an idle connection from the READ connection pool is destroyed

Specified by:
getReadConnectionPoolMinIdleTime in interface RepositoryConnectionPoolMBean
Returns:
minimum time to wait before an idle connection from the READ connection pool is destroyed

getWriteConnectionPoolMaxIdle

public int getWriteConnectionPoolMaxIdle()
Description copied from interface: RepositoryConnectionPoolMBean
Get the max number of idle connections in the WRITE connection pool

Specified by:
getWriteConnectionPoolMaxIdle in interface RepositoryConnectionPoolMBean
Returns:
the max number of idle connections in the WRITE connection pool

getWriteConnectionPoolMinIdleTime

public long getWriteConnectionPoolMinIdleTime()
Description copied from interface: RepositoryConnectionPoolMBean
Get minimum time to wait before an idle connection from the WRITE connection pool is destroyed

Specified by:
getWriteConnectionPoolMinIdleTime in interface RepositoryConnectionPoolMBean
Returns:
minimum time to wait before an idle connection from the WRITE connection pool is destroyed

setQueryConnectionPoolMaxIdle

public void setQueryConnectionPoolMaxIdle(int max)
Description copied from interface: RepositoryConnectionPoolMBean
Set the max number of idle connections in the QUERY connection pool

Specified by:
setQueryConnectionPoolMaxIdle in interface RepositoryConnectionPoolMBean
Parameters:
max - the max number of idle connections in the READ connection pool

setQueryConnectionPoolMinIdleTime

public void setQueryConnectionPoolMinIdleTime(long minWait)
Description copied from interface: RepositoryConnectionPoolMBean
Set minimum time to wait before an idle connection from the QUERY connection pool is destroyed

Specified by:
setQueryConnectionPoolMinIdleTime in interface RepositoryConnectionPoolMBean
Parameters:
minWait - minimum time to wait before an idle connection from the QUERY connection pool is destroyed

setReadConnectionPoolMaxIdle

public void setReadConnectionPoolMaxIdle(int max)
Description copied from interface: RepositoryConnectionPoolMBean
Set the max number of idle connections in the READ connection pool

Specified by:
setReadConnectionPoolMaxIdle in interface RepositoryConnectionPoolMBean
Parameters:
max - the max number of idle connections in the READ connection pool

setReadConnectionPoolMinIdleTime

public void setReadConnectionPoolMinIdleTime(long minWait)
Description copied from interface: RepositoryConnectionPoolMBean
Set minimum time to wait before an idle connection from the READ connection pool is destroyed

Specified by:
setReadConnectionPoolMinIdleTime in interface RepositoryConnectionPoolMBean
Parameters:
minWait - minimum time to wait before an idle connection from the READ connection pool is destroyed

setWriteConnectionPoolMaxIdle

public void setWriteConnectionPoolMaxIdle(int max)
Description copied from interface: RepositoryConnectionPoolMBean
Set the max number of idle connections in the WRITE connection pool

Specified by:
setWriteConnectionPoolMaxIdle in interface RepositoryConnectionPoolMBean
Parameters:
max - the max number of idle connections in the WRITE connection pool

setWriteConnectionPoolMinIdleTime

public void setWriteConnectionPoolMinIdleTime(long minWait)
Description copied from interface: RepositoryConnectionPoolMBean
Set minimum time to wait before an idle connection from the WRITE connection pool is destroyed

Specified by:
setWriteConnectionPoolMinIdleTime in interface RepositoryConnectionPoolMBean
Parameters:
minWait - minimum time to wait before an idle connection from the WRITE connection pool is destroyed

getDatabaseUrl

public java.lang.String getDatabaseUrl()
Description copied from interface: RepositoryConnectionPoolMBean
Get the database JDBC URL

Specified by:
getDatabaseUrl in interface RepositoryConnectionPoolMBean
Returns:
the database JDBC URL

getDatabaseUserName

public java.lang.String getDatabaseUserName()
Description copied from interface: RepositoryConnectionPoolMBean
Get the username for the database connection

Specified by:
getDatabaseUserName in interface RepositoryConnectionPoolMBean
Returns:
the username for the database connection

setDatabaseUrl

public void setDatabaseUrl(java.lang.String jdbcUrl)
Description copied from interface: RepositoryConnectionPoolMBean
Set the database JDBC URL

Specified by:
setDatabaseUrl in interface RepositoryConnectionPoolMBean
Parameters:
jdbcUrl - the database JDBC URL

setDatabaseUserName

public void setDatabaseUserName(java.lang.String userName)
Description copied from interface: RepositoryConnectionPoolMBean
Set the username for the database connection

Specified by:
setDatabaseUserName in interface RepositoryConnectionPoolMBean
Parameters:
userName - the username for the database connection

getDatabasePassword

public java.lang.String getDatabasePassword()
Description copied from interface: RepositoryConnectionPoolMBean
Get the password for the database connection

Specified by:
getDatabasePassword in interface RepositoryConnectionPoolMBean
Returns:
the password for the database connection

setDatabasePassword

public void setDatabasePassword(java.lang.String password)
Description copied from interface: RepositoryConnectionPoolMBean
Set the password for the database connection

Specified by:
setDatabasePassword in interface RepositoryConnectionPoolMBean
Parameters:
password - the password for the database connection

getDatabaseDriver

public java.lang.String getDatabaseDriver()
Description copied from interface: RepositoryConnectionPoolMBean
Get the database driver's class name

Specified by:
getDatabaseDriver in interface RepositoryConnectionPoolMBean
Returns:
the database driver's class name

setDatabaseDriver

public void setDatabaseDriver(java.lang.String dbDriver)
Description copied from interface: RepositoryConnectionPoolMBean
Set the database driver's class name

Specified by:
setDatabaseDriver in interface RepositoryConnectionPoolMBean
Parameters:
dbDriver - the database driver's class name

getDatabaseType

public java.lang.String getDatabaseType()
Description copied from interface: RepositoryConnectionPoolMBean
Get the type of database connection

Specified by:
getDatabaseType in interface RepositoryConnectionPoolMBean
Returns:
the type of database connection

setDatabaseType

public void setDatabaseType(java.lang.String dbType)
Description copied from interface: RepositoryConnectionPoolMBean
Set the type of database connection

Specified by:
setDatabaseType in interface RepositoryConnectionPoolMBean
Parameters:
dbType - the type of database connection

getCacheProvider

public CacheProvider getCacheProvider()
Returns:
the cacheProvider


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