use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.
the class DataSourceDefinitionDeployer method undeployResource.
@Override
public void undeployResource(Object resource) throws Exception {
final DataSourceDefinitionDescriptor desc = (DataSourceDefinitionDescriptor) resource;
String poolName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(), DSDPOOL);
String resourceName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(), desc.getResourceType());
if (_logger.isLoggable(FINE)) {
_logger.log(FINE, "DataSourceDefinitionDeployer.undeployResource() : pool-name [" + poolName + "], " + " resource-name [" + resourceName + "]");
}
// Undeploy resource
JdbcResource jdbcResource = new MyJdbcResource(poolName, resourceName);
getDeployer(jdbcResource).undeployResource(jdbcResource);
// Undeploy pool
JdbcConnectionPool jdbcCp = new MyJdbcConnectionPool(desc, poolName);
getDeployer(jdbcCp).undeployResource(jdbcCp);
desc.setDeployed(false);
}
use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.
the class JdbcResourceDeployer method checkAndDeletePool.
/**
* Checks if no more resource-refs to resources exists for the
* JDBC connection pool and then deletes the pool
*
* @param cr Jdbc Resource Config bean
* @throws Exception if unable to access configuration/undeploy resource.
* @since 8.1 pe/se/ee
*/
private void checkAndDeletePool(JdbcResource cr) throws Exception {
String poolName = cr.getPoolName();
ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(cr);
PoolInfo poolInfo = new PoolInfo(poolName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
Resources resources = (Resources) cr.getParent();
// Its possible that the JdbcResource here is a DataSourceDefinition. Ignore optimization.
if (resources != null) {
try {
boolean poolReferred = JdbcResourcesUtil.createInstance().isJdbcPoolReferredInServerInstance(poolInfo);
if (!poolReferred) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Deleting JDBC pool [" + poolName + " ] as there are no more " + "resource-refs to the pool in this server instance");
}
JdbcConnectionPool jcp = (JdbcConnectionPool) ConnectorsUtil.getResourceByName(resources, JdbcConnectionPool.class, poolName);
// Delete/Undeploy Pool
runtime.getResourceDeployer(jcp).undeployResource(jcp);
}
} catch (Exception ce) {
_logger.warning(ce.getMessage());
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Exception while deleting pool [ " + poolName + " ] : " + ce);
}
throw ce;
}
}
}
use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.
the class SQLTraceStoreImpl method trace.
@Override
public void trace(SQLTraceRecord record, String sql) {
JdbcConnectionPool connectionPool = getJdbcConnectionPool(record.getPoolName());
if (connectionPool == null) {
return;
}
long threshold = thresholdInMillis(connectionPool);
Queue<SQLTraceEntry> queue = uncollectedTracesByPoolName.computeIfAbsent(record.getPoolName(), key -> new ConcurrentLinkedQueue<>());
if (queue.size() >= 50) {
// avoid queue creating a memory leak by accumulating entries in case no consumer polls them
queue.poll();
}
queue.add(new SQLTraceEntry(threshold, record, sql));
}
use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.
the class JdbcConnectionPoolDeployer method undeployResource.
/**
* {@inheritDoc}
*/
@Override
public void undeployResource(Object resource, String applicationName, String moduleName) throws Exception {
JdbcConnectionPool jdbcConnPool = (JdbcConnectionPool) resource;
PoolInfo poolInfo = new PoolInfo(jdbcConnPool.getName(), applicationName, moduleName);
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 redeployResource.
/**
* {@inheritDoc}
*/
@Override
public synchronized void redeployResource(Object resource) throws Exception {
final JdbcConnectionPool adminPool = (JdbcConnectionPool) resource;
PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(adminPool);
if (!runtime.isConnectorConnectionPoolDeployed(poolInfo)) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("The JDBC connection pool " + poolInfo + " is not referred or not yet created in this server " + "instance and hence pool redeployment is ignored");
}
return;
}
final ConnectorConnectionPool connConnPool = createConnectorConnectionPool(adminPool, poolInfo);
if (connConnPool == null) {
throw new ConnectorRuntimeException("Unable to create ConnectorConnectionPool" + "from JDBC connection pool");
}
// now do internal book keeping
HashSet excludes = new HashSet();
// add MCF config props to the set that need to be excluded
// in checking for the equality of the props with old pool
excludes.add("TransactionIsolation");
excludes.add("GuaranteeIsolationLevel");
excludes.add("ValidationTableName");
excludes.add("ConnectionValidationRequired");
excludes.add("ValidationMethod");
excludes.add("StatementWrapping");
excludes.add("StatementTimeout");
excludes.add("ValidationClassName");
excludes.add("StatementCacheSize");
excludes.add("StatementCacheType");
excludes.add("StatementLeakTimeoutInSeconds");
excludes.add("StatementLeakReclaim");
try {
if (_logger.isLoggable(Level.FINEST)) {
_logger.finest("Calling reconfigure pool");
}
boolean requirePoolRecreation = runtime.reconfigureConnectorConnectionPool(connConnPool, excludes);
if (requirePoolRecreation) {
if (runtime.isServer() || runtime.isEmbedded()) {
handlePoolRecreation(connConnPool);
} else {
recreatePool(connConnPool);
}
}
} catch (ConnectorRuntimeException cre) {
Object[] params = new Object[] { poolInfo, cre };
_logger.log(Level.WARNING, "error.redeploying.jdbc.pool", params);
throw cre;
}
}
Aggregations