use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.
the class ConnectionPoolHealthCheck method doCheck.
@Override
public HealthCheckResult doCheck() {
HealthCheckResult result = new HealthCheckResult();
Collection<JdbcResource> allJdbcResources = getAllJdbcResources();
for (JdbcResource resource : allJdbcResources) {
ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(resource);
JdbcConnectionPool pool = JdbcResourcesUtil.createInstance().getJdbcConnectionPoolOfResource(resourceInfo);
PoolInfo poolInfo = ResourceUtil.getPoolInfo(pool);
if (getOptions().getPoolName() != null) {
if (getOptions().getPoolName().equals(poolInfo.getName())) {
evaluatePoolUsage(result, poolInfo);
}
} else {
evaluatePoolUsage(result, poolInfo);
}
}
return result;
}
use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.
the class JdbcConnectionPoolValidator method isValid.
@Override
public boolean isValid(final ResourcePool pool, final ConstraintValidatorContext constraintValidatorContext) {
if (poolFaults == ConnectionPoolErrorMessages.MAX_STEADY_INVALID) {
if (pool instanceof JdbcConnectionPool) {
JdbcConnectionPool jdbcPool = (JdbcConnectionPool) pool;
String maxPoolSize = jdbcPool.getMaxPoolSize();
String steadyPoolSize = jdbcPool.getSteadyPoolSize();
if (steadyPoolSize == null) {
steadyPoolSize = Constants.DEFAULT_STEADY_POOL_SIZE;
}
if (maxPoolSize == null) {
maxPoolSize = Constants.DEFAULT_MAX_POOL_SIZE;
}
if (Integer.parseInt(maxPoolSize) < (Integer.parseInt(steadyPoolSize))) {
// max pool size fault
return false;
}
}
}
if (poolFaults == ConnectionPoolErrorMessages.STMT_WRAPPING_DISABLED) {
if (pool instanceof JdbcConnectionPool) {
JdbcConnectionPool jdbcPool = (JdbcConnectionPool) pool;
String stmtCacheSize = jdbcPool.getStatementCacheSize();
String stmtLeakTimeout = jdbcPool.getStatementLeakTimeoutInSeconds();
// PAYARA-661 allow empty "" sql trace listeners
if (jdbcPool.getSqlTraceListeners() != null && !jdbcPool.getSqlTraceListeners().isEmpty()) {
if (!Boolean.valueOf(jdbcPool.getWrapJdbcObjects())) {
return false;
}
}
if (stmtCacheSize != null && Integer.parseInt(stmtCacheSize) != 0) {
if (!Boolean.valueOf(jdbcPool.getWrapJdbcObjects())) {
return false;
}
}
if (stmtLeakTimeout != null && Integer.parseInt(stmtLeakTimeout) != 0) {
if (!Boolean.parseBoolean(jdbcPool.getWrapJdbcObjects())) {
return false;
}
}
if (Boolean.valueOf(jdbcPool.getStatementLeakReclaim())) {
if (!Boolean.valueOf(jdbcPool.getWrapJdbcObjects())) {
return false;
}
}
}
}
if (poolFaults == ConnectionPoolErrorMessages.TABLE_NAME_MANDATORY) {
if (pool instanceof JdbcConnectionPool) {
JdbcConnectionPool jdbcPool = (JdbcConnectionPool) pool;
if (Boolean.valueOf(jdbcPool.getIsConnectionValidationRequired())) {
if ("table".equals(jdbcPool.getConnectionValidationMethod())) {
if (jdbcPool.getValidationTableName() == null || jdbcPool.getValidationTableName().equals("")) {
return false;
}
}
}
}
}
if (poolFaults == ConnectionPoolErrorMessages.CUSTOM_VALIDATION_CLASS_NAME_MANDATORY) {
if (pool instanceof JdbcConnectionPool) {
JdbcConnectionPool jdbcPool = (JdbcConnectionPool) pool;
if (Boolean.valueOf(jdbcPool.getIsConnectionValidationRequired())) {
if ("custom-validation".equals(jdbcPool.getConnectionValidationMethod())) {
if (jdbcPool.getValidationClassname() == null || jdbcPool.getValidationClassname().equals("")) {
return false;
}
}
}
}
}
if (poolFaults == ConnectionPoolErrorMessages.RES_TYPE_MANDATORY) {
if (pool instanceof JdbcConnectionPool) {
JdbcConnectionPool jdbcPool = (JdbcConnectionPool) pool;
String resType = jdbcPool.getResType();
String dsClassName = jdbcPool.getDatasourceClassname();
String driverClassName = jdbcPool.getDriverClassname();
if (resType == null) {
// One of datasource/driver classnames must be provided.
if ((dsClassName == null || dsClassName.equals("")) && (driverClassName == null || driverClassName.equals(""))) {
return false;
} else {
// Check if both are provided and if so, return false
if (dsClassName != null && driverClassName != null) {
return false;
}
}
} else if (resType.equals("javax.sql.DataSource") || resType.equals("javax.sql.ConnectionPoolDataSource") || resType.equals("javax.sql.XADataSource")) {
// Then datasourceclassname cannot be empty
if (dsClassName == null || dsClassName.equals("")) {
return false;
}
} else if (resType.equals("java.sql.Driver")) {
// Then driver classname cannot be empty
if (driverClassName == null || driverClassName.equals("")) {
return false;
}
}
}
}
return true;
}
use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.
the class SQLTraceStoreImpl method collect.
@Override
public void collect(MonitoringWatchCollector collector) {
for (Entry<String, JdbcConnectionPool> poolEntry : connectionPoolByName.entrySet()) {
JdbcConnectionPool pool = poolEntry.getValue();
if (pool != null) {
String poolName = poolEntry.getKey();
long thresholdInMillis = thresholdInMillis(pool);
if (thresholdInMillis > 0) {
collector.watch("ns:sql @:" + poolName + " MaxExecutionTime", poolName + " Slow Query", "ms").red(thresholdInMillis, 0, false, null, null, false);
}
}
}
}
use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.
the class JdbcConnectionPoolDeployer method undeployResource.
/**
* {@inheritDoc}
*/
@Override
public synchronized void undeployResource(Object resource) throws Exception {
JdbcConnectionPool jdbcConnPool = (JdbcConnectionPool) resource;
PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(jdbcConnPool);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine(" JdbcConnectionPoolDeployer - unDeployResource : " + "calling actualUndeploy of " + poolInfo);
}
actualUndeployResource(poolInfo);
}
use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.
the class JdbcConnectionPoolDeployer method deployResource.
/**
* {@inheritDoc}
*/
@Override
public void deployResource(Object resource, String applicationName, String moduleName) throws Exception {
// deployResource is not synchronized as there is only one caller
// ResourceProxy which is synchronized
// intentional no-op
// From 8.1 PE/SE/EE, JDBC connection pools are no more resources and
// they would be available only to server instances that have a resoruce-ref
// that maps to a pool. So deploy resource would not be called during
// JDBC connection pool creation. The actualDeployResource method
// below is invoked by JdbcResourceDeployer when a resource-ref for a
// resource that is pointed to this pool is added to a server instance
JdbcConnectionPool jcp = (JdbcConnectionPool) resource;
PoolInfo poolInfo = new PoolInfo(jcp.getName(), applicationName, moduleName);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine(" JdbcConnectionPoolDeployer - deployResource : " + poolInfo + " calling actualDeploy");
}
actualDeployResource(resource, poolInfo);
}
Aggregations