Search in sources :

Example 41 with PoolInfo

use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.

the class PoolManagerImpl method putbackBadResourceToPool.

public void putbackBadResourceToPool(ResourceHandle h) {
    // notify pool
    PoolInfo poolInfo = h.getResourceSpec().getPoolInfo();
    if (poolInfo != null) {
        ResourcePool pool = poolTable.get(poolInfo);
        if (pool != null) {
            synchronized (pool) {
                pool.resourceClosed(h);
                h.setConnectionErrorOccurred();
                pool.resourceErrorOccurred(h);
            }
        }
    }
}
Also used : PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 42 with PoolInfo

use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.

the class PoolManagerImpl method reconfigPoolProperties.

public void reconfigPoolProperties(ConnectorConnectionPool ccp) throws PoolingException {
    PoolInfo poolInfo = ccp.getPoolInfo();
    ResourcePool pool = getPool(poolInfo);
    if (pool != null) {
        pool.reconfigurePool(ccp);
    }
}
Also used : PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 43 with PoolInfo

use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.

the class ConnectorsRecoveryResourceHandler method getdbUserPasswordOfConnectorConnectionPool.

private String[] getdbUserPasswordOfConnectorConnectionPool(ConnectorConnectionPool connectorConnectionPool) {
    String[] userPassword = new String[2];
    userPassword[0] = null;
    userPassword[1] = null;
    List<Property> properties = connectorConnectionPool.getProperty();
    if (properties != null) {
        boolean foundUserPassword = false;
        for (Property elementProperty : properties) {
            String prop = elementProperty.getName().toUpperCase(locale);
            if ("USERNAME".equals(prop) || "USER".equals(prop)) {
                userPassword[0] = elementProperty.getValue();
                foundUserPassword = true;
            } else if ("PASSWORD".equals(prop)) {
                userPassword[1] = elementProperty.getValue();
                foundUserPassword = true;
            }
        }
        if (foundUserPassword == true) {
            return userPassword;
        }
    }
    PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(connectorConnectionPool);
    String rarName = connectorConnectionPool.getResourceAdapterName();
    String connectionDefName = connectorConnectionPool.getConnectionDefinitionName();
    ConnectorRegistry connectorRegistry = ConnectorRegistry.getInstance();
    ConnectorDescriptor connectorDescriptor = connectorRegistry.getDescriptor(rarName);
    ConnectionDefDescriptor cdd = connectorDescriptor.getConnectionDefinitionByCFType(connectionDefName);
    Set configProps = cdd.getConfigProperties();
    for (Iterator iter = configProps.iterator(); iter.hasNext(); ) {
        ConnectorConfigProperty envProp = (ConnectorConfigProperty) iter.next();
        String prop = envProp.getName().toUpperCase(locale);
        if ("USER".equals(prop) || "USERNAME".equals(prop)) {
            userPassword[0] = envProp.getValue();
        } else if ("PASSWORD".equals(prop)) {
            userPassword[1] = envProp.getValue();
        }
    }
    if (userPassword[0] != null && !"".equals(userPassword[0].trim())) {
        return userPassword;
    }
    // else read the default username and password from the ra.xml
    ManagedConnectionFactory mcf = connectorRegistry.getManagedConnectionFactory(poolInfo);
    userPassword[0] = ConnectionPoolObjectsUtils.getValueFromMCF("UserName", poolInfo, mcf);
    userPassword[1] = ConnectionPoolObjectsUtils.getValueFromMCF("Password", poolInfo, mcf);
    return userPassword;
}
Also used : ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ManagedConnectionFactory(javax.resource.spi.ManagedConnectionFactory) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ConnectorRegistry(com.sun.enterprise.connectors.ConnectorRegistry) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) Property(org.jvnet.hk2.config.types.Property)

Example 44 with PoolInfo

use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.

the class JdbcStatsProvider method traceSQLEvent.

/**
 * Whenever a sql statement that is traced is to be cache for monitoring
 * purpose, the SQLTrace object is created for the specified sql and
 * updated in the SQLTraceCache. This is used to update the
 * frequently used and slowest sql queries.
 *
 * @param poolName
 * @param appName
 * @param sql
 * @param moduleName
 * @param executionTime
 */
@ProbeListener(JdbcRAConstants.SQL_TRACING_DOTTED_NAME + JdbcRAConstants.TRACE_SQL)
public void traceSQLEvent(@ProbeParam("poolName") String poolName, @ProbeParam("appName") String appName, @ProbeParam("moduleName") String moduleName, @ProbeParam("sql") String sql, @ProbeParam("executionTime") long executionTime) {
    PoolInfo poolInfo = new PoolInfo(poolName, appName, moduleName);
    if (this.poolInfo.equals(poolInfo)) {
        if (freqSqlTraceCache != null) {
            if (sql != null) {
                SQLTrace cacheObj = new SQLTrace(sql, 1, System.currentTimeMillis());
                freqSqlTraceCache.checkAndUpdateCache(cacheObj);
            }
        }
        // the cache
        if (slowSqlTraceCache != null && sql != null) {
            SQLTrace cacheObj = new SlowSqlTrace(sql, 1, System.currentTimeMillis(), executionTime);
            slowSqlTraceCache.checkAndUpdateCache(cacheObj);
        }
    }
}
Also used : SlowSqlTrace(fish.payara.jdbc.stats.SlowSqlTrace) SQLTrace(com.sun.gjc.util.SQLTrace) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ProbeListener(org.glassfish.external.probe.provider.annotations.ProbeListener)

Example 45 with PoolInfo

use of org.glassfish.resourcebase.resources.api.PoolInfo 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)

Aggregations

PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)52 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)17 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)15 NamingException (javax.naming.NamingException)10 JdbcConnectionPool (org.glassfish.jdbc.config.JdbcConnectionPool)9 ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)7 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)7 ProbeListener (org.glassfish.external.probe.provider.annotations.ProbeListener)7 ResourceException (javax.resource.ResourceException)6 Property (org.jvnet.hk2.config.types.Property)5 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)4 Resources (com.sun.enterprise.config.serverbeans.Resources)4 ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)4 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)4 ArrayList (java.util.ArrayList)4 JdbcResource (org.glassfish.jdbc.config.JdbcResource)4 ConnectorRegistry (com.sun.enterprise.connectors.ConnectorRegistry)3 ConnectorRuntime (com.sun.enterprise.connectors.ConnectorRuntime)3 ResourcePrincipal (com.sun.enterprise.deployment.ResourcePrincipal)3 ActionReport (org.glassfish.api.ActionReport)3