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);
}
}
}
}
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);
}
}
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;
}
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);
}
}
}
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;
}
}
}
Aggregations