Search in sources :

Example 21 with JdbcConnectionPool

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);
}
Also used : JdbcResource(org.glassfish.jdbc.config.JdbcResource) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) DataSourceDefinitionDescriptor(com.sun.enterprise.deployment.DataSourceDefinitionDescriptor)

Example 22 with JdbcConnectionPool

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;
        }
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) Resources(com.sun.enterprise.config.serverbeans.Resources) ResourceConflictException(org.glassfish.resourcebase.resources.api.ResourceConflictException)

Example 23 with JdbcConnectionPool

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));
}
Also used : JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool)

Example 24 with JdbcConnectionPool

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);
}
Also used : JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 25 with JdbcConnectionPool

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;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) HashSet(java.util.HashSet)

Aggregations

JdbcConnectionPool (org.glassfish.jdbc.config.JdbcConnectionPool)32 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)10 JdbcResource (org.glassfish.jdbc.config.JdbcResource)7 Test (org.junit.Test)7 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)5 Resources (com.sun.enterprise.config.serverbeans.Resources)4 Resource (com.sun.enterprise.config.serverbeans.Resource)3 ActionReport (org.glassfish.api.ActionReport)3 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)3 Domain (com.sun.enterprise.config.serverbeans.Domain)2 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)2 ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)2 DataSourceDefinitionDescriptor (com.sun.enterprise.deployment.DataSourceDefinitionDescriptor)2 ArrayList (java.util.ArrayList)2 ConnectionPoolDataSource (javax.sql.ConnectionPoolDataSource)2 DataSource (javax.sql.DataSource)2 XADataSource (javax.sql.XADataSource)2 ConnectorConnectionPool (org.glassfish.connectors.config.ConnectorConnectionPool)2 ResourceConflictException (org.glassfish.resourcebase.resources.api.ResourceConflictException)2 Property (org.jvnet.hk2.config.types.Property)2