public class AnterosDBCPConfig extends Object implements AnterosDBCPConfigMXBean
| Constructor and Description |
|---|
AnterosDBCPConfig()
Default constructor
|
AnterosDBCPConfig(Properties properties)
Construct a AnterosDBCPConfig from the specified properties object.
|
AnterosDBCPConfig(String propertyFileName)
Construct a AnterosDBCPConfig from the specified property file name.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDataSourceProperty(String propertyName,
Object value)
Add a property (name/value pair) that will be used to configure the
DataSource/Driver. |
void |
addHealthCheckProperty(String key,
String value) |
void |
copyStateTo(AnterosDBCPConfig other)
Copies the state of
this into other. |
String |
getCatalog()
Get the default catalog name to be set on connections.
|
String |
getConnectionInitSql()
Get the SQL string that will be executed on all new connections when they are
created, before they are added to the pool.
|
String |
getConnectionTestQuery()
Get the SQL query to be executed to test the validity of connections.
|
long |
getConnectionTimeout()
Get the maximum number of milliseconds that a client will wait for a connection from the pool.
|
DataSource |
getDataSource()
Get the
DataSource that has been explicitly specified to be wrapped by the
pool. |
String |
getDataSourceClassName()
Get the name of the JDBC
DataSource class used to create Connections. |
String |
getDataSourceJNDI() |
Properties |
getDataSourceProperties() |
String |
getDriverClassName() |
Properties |
getHealthCheckProperties() |
Object |
getHealthCheckRegistry()
Get the HealthCheckRegistry that will be used for registration of health checks by AnterosDBCPCP.
|
long |
getIdleTimeout()
This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit
idle in the pool.
|
long |
getInitializationFailTimeout()
Get the pool initialization failure timeout.
|
String |
getJdbcUrl() |
long |
getLeakDetectionThreshold()
This property controls the amount of time that a connection can be out of the pool before a message is
logged indicating a possible connection leak.
|
int |
getMaximumPoolSize()
The property controls the maximum number of connections that AnterosDBCPCP will keep in the pool,
including both idle and in-use connections.
|
long |
getMaxLifetime()
This property controls the maximum lifetime of a connection in the pool.
|
Object |
getMetricRegistry()
Get the MetricRegistry instance to used for registration of metrics used by AnterosDBCPCP.
|
MetricsTrackerFactory |
getMetricsTrackerFactory() |
int |
getMinimumIdle()
The property controls the minimum number of idle connections that AnterosDBCPCP tries to maintain in the pool,
including both idle and in-use connections.
|
String |
getPassword()
Get the default password to use for DataSource.getConnection(username, password) calls.
|
String |
getPoolName()
The name of the connection pool.
|
ScheduledExecutorService |
getScheduledExecutor()
Get the ScheduledExecutorService used for housekeeping.
|
String |
getSchema()
Get the default schema name to be set on connections.
|
ThreadFactory |
getThreadFactory()
Get the thread factory used to create threads.
|
String |
getTransactionIsolation() |
String |
getUsername()
Get the default username used for DataSource.getConnection(username, password) calls.
|
long |
getValidationTimeout()
Get the maximum number of milliseconds that the pool will wait for a connection to be validated as
alive.
|
boolean |
isAllowPoolSuspension()
Get the pool suspension behavior (allowed or disallowed).
|
boolean |
isAutoCommit()
Get the default auto-commit behavior of connections in the pool.
|
boolean |
isIsolateInternalQueries()
Determine whether internal pool queries, principally aliveness checks, will be isolated in their own transaction
via
Connection.rollback(). |
boolean |
isReadOnly()
Determine whether the Connections in the pool are in read-only mode.
|
boolean |
isRegisterMbeans()
Determine whether AnterosDBCPCP will self-register
AnterosDBCPConfigMXBean and AnterosDBCPPoolMXBean instances
in JMX. |
void |
setAllowPoolSuspension(boolean isAllowPoolSuspension)
Set whether or not pool suspension is allowed.
|
void |
setAutoCommit(boolean isAutoCommit)
Set the default auto-commit behavior of connections in the pool.
|
void |
setCatalog(String catalog)
Set the default catalog name to be set on connections.
|
void |
setConnectionInitSql(String connectionInitSql)
Set the SQL string that will be executed on all new connections when they are
created, before they are added to the pool.
|
void |
setConnectionTestQuery(String connectionTestQuery)
Set the SQL query to be executed to test the validity of connections.
|
void |
setConnectionTimeout(long connectionTimeoutMs)
Set the maximum number of milliseconds that a client will wait for a connection from the pool.
|
void |
setDataSource(DataSource dataSource)
Set a
DataSource for the pool to explicitly wrap. |
void |
setDataSourceClassName(String className)
Set the fully qualified class name of the JDBC
DataSource that will be used create Connections. |
void |
setDataSourceJNDI(String jndiDataSource) |
void |
setDataSourceProperties(Properties dsProperties) |
void |
setDriverClassName(String driverClassName) |
void |
setHealthCheckProperties(Properties healthCheckProperties) |
void |
setHealthCheckRegistry(Object healthCheckRegistry)
Set the HealthCheckRegistry that will be used for registration of health checks by AnterosDBCPCP.
|
void |
setIdleTimeout(long idleTimeoutMs)
This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit
idle in the pool.
|
void |
setInitializationFailTimeout(long initializationFailTimeout)
Set the pool initialization failure timeout.
|
void |
setIsolateInternalQueries(boolean isolate)
Configure whether internal pool queries, principally aliveness checks, will be isolated in their own transaction
via
Connection.rollback(). |
void |
setJdbcUrl(String jdbcUrl) |
void |
setLeakDetectionThreshold(long leakDetectionThresholdMs)
This property controls the amount of time that a connection can be out of the pool before a message is
logged indicating a possible connection leak.
|
void |
setMaximumPoolSize(int maxPoolSize)
The property controls the maximum size that the pool is allowed to reach, including both idle and in-use
connections.
|
void |
setMaxLifetime(long maxLifetimeMs)
This property controls the maximum lifetime of a connection in the pool.
|
void |
setMetricRegistry(Object metricRegistry)
Set a MetricRegistry instance to use for registration of metrics used by AnterosDBCPCP.
|
void |
setMetricsTrackerFactory(MetricsTrackerFactory metricsTrackerFactory) |
void |
setMinimumIdle(int minIdle)
The property controls the minimum number of idle connections that AnterosDBCPCP tries to maintain in the pool,
including both idle and in-use connections.
|
void |
setPassword(String password)
Set the default password to use for DataSource.getConnection(username, password) calls.
|
void |
setPoolName(String poolName)
Set the name of the connection pool.
|
void |
setReadOnly(boolean readOnly)
Configures the Connections to be added to the pool as read-only Connections.
|
void |
setRegisterMbeans(boolean register)
Configures whether AnterosDBCPCP self-registers the
AnterosDBCPConfigMXBean and AnterosDBCPPoolMXBean in JMX. |
void |
setScheduledExecutor(ScheduledExecutorService executor)
Set the ScheduledExecutorService used for housekeeping.
|
void |
setSchema(String schema)
Set the default schema name to be set on connections.
|
void |
setThreadFactory(ThreadFactory threadFactory)
Set the thread factory to be used to create threads.
|
void |
setTransactionIsolation(String isolationLevel)
Set the default transaction isolation level.
|
void |
setUsername(String username)
Set the default username used for DataSource.getConnection(username, password) calls.
|
void |
setValidationTimeout(long validationTimeoutMs)
Sets the maximum number of milliseconds that the pool will wait for a connection to be validated as
alive.
|
void |
validate() |
public AnterosDBCPConfig()
public AnterosDBCPConfig(Properties properties)
properties - the name of the property filepublic AnterosDBCPConfig(String propertyFileName)
propertyFileName
will first be treated as a path in the file-system, and if that fails the
Class.getResourceAsStream(propertyFileName) will be tried.propertyFileName - the name of the property filepublic String getCatalog()
getCatalog in interface AnterosDBCPConfigMXBeanpublic void setCatalog(String catalog)
WARNING: THIS VALUE SHOULD ONLY BE CHANGED WHILE THE POOL IS SUSPENDED, AFTER CONNECTIONS HAVE BEEN EVICTED.
setCatalog in interface AnterosDBCPConfigMXBeancatalog - the catalog name, or nullpublic long getConnectionTimeout()
DataSource.getConnection().getConnectionTimeout in interface AnterosDBCPConfigMXBeanpublic void setConnectionTimeout(long connectionTimeoutMs)
DataSource.getConnection().setConnectionTimeout in interface AnterosDBCPConfigMXBeanconnectionTimeoutMs - the connection timeout in millisecondspublic long getIdleTimeout()
getIdleTimeout in interface AnterosDBCPConfigMXBeanpublic void setIdleTimeout(long idleTimeoutMs)
setIdleTimeout in interface AnterosDBCPConfigMXBeanidleTimeoutMs - the idle timeout in millisecondspublic long getLeakDetectionThreshold()
getLeakDetectionThreshold in interface AnterosDBCPConfigMXBeanpublic void setLeakDetectionThreshold(long leakDetectionThresholdMs)
setLeakDetectionThreshold in interface AnterosDBCPConfigMXBeanleakDetectionThresholdMs - the connection leak detection threshold in millisecondspublic long getMaxLifetime()
getMaxLifetime in interface AnterosDBCPConfigMXBeanpublic void setMaxLifetime(long maxLifetimeMs)
setMaxLifetime in interface AnterosDBCPConfigMXBeanmaxLifetimeMs - the maximum connection lifetime in millisecondspublic int getMaximumPoolSize()
getMaximumPoolSize in interface AnterosDBCPConfigMXBeanpublic void setMaximumPoolSize(int maxPoolSize)
When the pool reaches this size, and no idle connections are available, calls to getConnection() will block for up to connectionTimeout milliseconds before timing out.
setMaximumPoolSize in interface AnterosDBCPConfigMXBeanmaxPoolSize - the maximum number of connections in the poolpublic int getMinimumIdle()
getMinimumIdle in interface AnterosDBCPConfigMXBeanpublic void setMinimumIdle(int minIdle)
setMinimumIdle in interface AnterosDBCPConfigMXBeanminIdle - the minimum number of idle connections in the pool to maintainpublic String getPassword()
public void setPassword(String password)
setPassword in interface AnterosDBCPConfigMXBeanpassword - the passwordpublic String getUsername()
public void setUsername(String username)
setUsername in interface AnterosDBCPConfigMXBeanusername - the usernamepublic long getValidationTimeout()
getValidationTimeout in interface AnterosDBCPConfigMXBeanpublic void setValidationTimeout(long validationTimeoutMs)
setValidationTimeout in interface AnterosDBCPConfigMXBeanvalidationTimeoutMs - the validation timeout in millisecondspublic String getConnectionTestQuery()
public void setConnectionTestQuery(String connectionTestQuery)
Connection.isValid() method to test connection validity can
be more efficient on some databases and is recommended.connectionTestQuery - a SQL query stringpublic String getConnectionInitSql()
public void setConnectionInitSql(String connectionInitSql)
connectionInitSql - the SQL to execute on new connectionspublic DataSource getDataSource()
DataSource that has been explicitly specified to be wrapped by the
pool.DataSource instance, or nullpublic void setDataSource(DataSource dataSource)
DataSource for the pool to explicitly wrap. This setter is not
available through property file based initialization.dataSource - a specific DataSource to be wrapped by the poolpublic String getDataSourceClassName()
DataSource class used to create Connections.DataSource classpublic void setDataSourceClassName(String className)
DataSource that will be used create Connections.className - the fully qualified name of the JDBC DataSource classpublic void addDataSourceProperty(String propertyName, Object value)
DataSource/Driver.
In the case of a DataSource, the property names will be translated to Java setters following the Java Bean
naming convention. For example, the property cachePrepStmts will translate into setCachePrepStmts()
with the value passed as a parameter.
In the case of a Driver, the property will be added to a Properties instance that will
be passed to the driver during Driver.connect(String, Properties) calls.propertyName - the name of the propertyvalue - the value to be used by the DataSource/Driverpublic String getDataSourceJNDI()
public void setDataSourceJNDI(String jndiDataSource)
public Properties getDataSourceProperties()
public void setDataSourceProperties(Properties dsProperties)
public String getDriverClassName()
public void setDriverClassName(String driverClassName)
public String getJdbcUrl()
public void setJdbcUrl(String jdbcUrl)
public boolean isAutoCommit()
public void setAutoCommit(boolean isAutoCommit)
isAutoCommit - the desired auto-commit default for connectionspublic boolean isAllowPoolSuspension()
public void setAllowPoolSuspension(boolean isAllowPoolSuspension)
isAllowPoolSuspension - the desired pool suspension allowancepublic long getInitializationFailTimeout()
#setInitializationFailTimeout(long)
for details.setInitializationFailTimeout(long)public void setInitializationFailTimeout(long initializationFailTimeout)
AnterosDBCPDataSource is constructed with a AnterosDBCPConfig,
or when AnterosDBCPDataSource is constructed using the no-arg constructor
and AnterosDBCPDataSource.getConnection() is called.
PoolInitializationException will be thrown. connectionTestQuery
and connectionInitSql are valid. If those validations fail, an exception
will be thrown. If a connection cannot be obtained, the validation is skipped
and the the pool will start and continue to try to obtain connections in the
background. This can mean that callers to DataSource#getConnection() may
encounter exceptions. DataSource#getConnection() may encounter exceptions. connectionTimeout or validationTimeout; they will be honored before this
timeout is applied. The default value is one millisecond.initializationFailTimeout - the number of milliseconds before the
pool initialization fails, or 0 to validate connection setup but continue with
pool start, or less than zero to skip all initialization checks and start the
pool without delay.public boolean isIsolateInternalQueries()
Connection.rollback(). Defaults to false.true if internal pool queries are isolated, false if notpublic void setIsolateInternalQueries(boolean isolate)
Connection.rollback(). Defaults to false.isolate - true if internal pool queries should be isolated, false if notpublic MetricsTrackerFactory getMetricsTrackerFactory()
public void setMetricsTrackerFactory(MetricsTrackerFactory metricsTrackerFactory)
public Object getMetricRegistry()
null.public void setMetricRegistry(Object metricRegistry)
metricRegistry - the MetricRegistry instance to usepublic Object getHealthCheckRegistry()
public void setHealthCheckRegistry(Object healthCheckRegistry)
null.healthCheckRegistry - the HealthCheckRegistry to be usedpublic Properties getHealthCheckProperties()
public void setHealthCheckProperties(Properties healthCheckProperties)
public boolean isReadOnly()
true if the Connections in the pool are read-only, false if notpublic void setReadOnly(boolean readOnly)
readOnly - true if the Connections in the pool are read-only, false if notpublic boolean isRegisterMbeans()
AnterosDBCPConfigMXBean and AnterosDBCPPoolMXBean instances
in JMX.true if AnterosDBCPCP will register MXBeans, false if it will notpublic void setRegisterMbeans(boolean register)
AnterosDBCPConfigMXBean and AnterosDBCPPoolMXBean in JMX.register - true if AnterosDBCPCP should register MXBeans, false if it should notpublic String getPoolName()
getPoolName in interface AnterosDBCPConfigMXBeanpublic void setPoolName(String poolName)
poolName - the name of the connection pool to usepublic ScheduledExecutorService getScheduledExecutor()
public void setScheduledExecutor(ScheduledExecutorService executor)
executor - the ScheduledExecutorServicepublic String getTransactionIsolation()
public String getSchema()
public void setSchema(String schema)
schema - the name of the default schemapublic void setTransactionIsolation(String isolationLevel)
Connection class, eg.
TRANSACTION_REPEATABLE_READ.isolationLevel - the name of the isolation levelpublic ThreadFactory getThreadFactory()
public void setThreadFactory(ThreadFactory threadFactory)
threadFactory - the thread factory (setting to null causes the default thread factory to be used)public void copyStateTo(AnterosDBCPConfig other)
this into other.other - Other AnterosDBCPConfig to copy the state to.public void validate()
Copyright © 2019 Anteros Tecnologia. All rights reserved.