use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.
the class ConnectorConnectionPoolAdminServiceImpl method updateMCFAndPoolAttributes.
private void updateMCFAndPoolAttributes(ConnectorConnectionPool ccp) throws ConnectorRuntimeException {
PoolInfo poolInfo = ccp.getPoolInfo();
try {
ConnectorConnectionPool origCcp = getOriginalConnectorConnectionPool(poolInfo);
// update properties
origCcp.setSteadyPoolSize(ccp.getSteadyPoolSize());
origCcp.setMaxPoolSize(ccp.getMaxPoolSize());
origCcp.setMaxWaitTimeInMillis(ccp.getMaxWaitTimeInMillis());
origCcp.setPoolResizeQuantity(ccp.getPoolResizeQuantity());
origCcp.setIdleTimeoutInSeconds(ccp.getIdleTimeoutInSeconds());
origCcp.setFailAllConnections(ccp.isFailAllConnections());
// lazyEnlist, lazyAssoc and assocWithThread not required since they result
// in a pool restart anyways, so they wouldn't have changed if we
// came here
origCcp.setMatchConnections(ccp.matchConnections());
origCcp.setMaxConnectionUsage(ccp.getMaxConnectionUsage());
origCcp.setNonComponent(ccp.isNonComponent());
origCcp.setNonTransactional(ccp.isNonTransactional());
origCcp.setConCreationRetryAttempts(ccp.getConCreationRetryAttempts());
origCcp.setConCreationRetryInterval(ccp.getConCreationRetryInterval());
origCcp.setValidateAtmostOncePeriod(ccp.getValidateAtmostOncePeriod());
origCcp.setConnectionLeakTracingTimeout(ccp.getConnectionLeakTracingTimeout());
origCcp.setConnectionReclaim(ccp.isConnectionReclaim());
// now rebind the object in jndi
String jndiNameForPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo);
_runtime.getResourceNamingService().unpublishObject(poolInfo, jndiNameForPool);
_runtime.getResourceNamingService().publishObject(poolInfo, jndiNameForPool, origCcp, true);
} catch (NamingException ne) {
throw new ConnectorRuntimeException(ne.getMessage());
}
// Check if this pool has been brought into memory
// If its already in memory, just call reconfig on it
PoolManager poolMgr = _runtime.getPoolManager();
try {
poolMgr.reconfigPoolProperties(ccp);
} catch (PoolingException pe) {
throw new ConnectorRuntimeException(pe.getMessage());
}
// Run setXXX methods on the copy of the MCF that we have
// this is done to update the MCF to reflect changes in the
// MCF properties for which we don't really need to recreate
// the pool
ConnectorRegistry registry = ConnectorRegistry.getInstance();
ManagedConnectionFactory mcf = registry.getManagedConnectionFactory(poolInfo);
SetMethodAction sma = new SetMethodAction(mcf, ccp.getConnectorDescriptorInfo().getMCFConfigProperties());
try {
sma.run();
} catch (Exception e) {
_logger.log(Level.WARNING, e.getMessage());
ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
cre.initCause(e);
throw cre;
}
// update the properties "allow-non-component-callers" and
// "non-transactional-connections" in the PoolMetaData
PoolMetaData pmd = registry.getPoolMetaData(poolInfo);
pmd.setIsPM(ccp.isNonComponent());
pmd.setIsNonTx(ccp.isNonTransactional());
pmd.setAuthCredentialsDefinedInPool(ccp.getAuthCredentialsDefinedInPool());
logFine("Pool properties reconfiguration done");
}
use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.
the class ConnectorConnectionPoolAdminServiceImpl method recreateConnectorConnectionPool.
/**
* Recreate a connector connection pool. This method essentially does
* the following things:
* 1. Delete the said connector connection pool<br>
* 2. Bind the pool to JNDI<br>
* 3. Create an MCF for this pool and register with the connector registry<br>
*
* @param ccp - the ConnectorConnectionPool to publish
*/
public void recreateConnectorConnectionPool(ConnectorConnectionPool ccp) throws ConnectorRuntimeException {
ConnectorRegistry registry = ConnectorRegistry.getInstance();
if (registry == null) {
throw new ConnectorRuntimeException("Cannot get ConnectorRegistry");
}
PoolInfo poolInfo = ccp.getPoolInfo();
// First remove this pool from memory
try {
unloadAndKillPool(poolInfo);
} catch (ConnectorRuntimeException cre) {
throw cre;
}
// kill the pool
// FIXME: deleteConnectorConnectionPool should do this
// PoolManager poolManager = Switch.getSwitch().getPoolManager();
// poolManager.killPool( poolName );
// Now bind the updated pool and
// obtain a new managed connection factory for this pool
String jndiNameForPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo);
ManagedConnectionFactory mcf = null;
try {
_runtime.getResourceNamingService().publishObject(poolInfo, jndiNameForPool, ccp, true);
mcf = obtainManagedConnectionFactory(poolInfo);
} catch (NamingException ne) {
_logger.log(Level.SEVERE, "rardeployment.pool_jndi_bind_failure", poolInfo);
String i18nMsg = localStrings.getString("ccp_adm.could_not_recreate_pool", poolInfo);
ConnectorRuntimeException crex = new ConnectorRuntimeException(i18nMsg);
crex.initCause(ne);
throw crex;
} finally {
if (mcf == null) {
try {
_runtime.getResourceNamingService().unpublishObject(poolInfo, jndiNameForPool);
} catch (NamingException e) {
_logger.log(Level.WARNING, "Unable to unbind the pool configuration object " + "of pool [ " + poolInfo + " ] during MCF creation failure");
}
_logger.log(Level.WARNING, "rardeployment.mcf_creation_failure", poolInfo);
String i18nMsg = localStrings.getString("ccp_adm.failed_to_create_mcf", poolInfo);
throw new ConnectorRuntimeException(i18nMsg);
}
}
}
use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.
the class FlushConnectionPool method execute.
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
Resources resources = domain.getResources();
String scope = "";
if (moduleName != null) {
if (!poolUtil.isValidModule(applicationName, moduleName, poolName, report)) {
return;
}
Application application = applications.getApplication(applicationName);
Module module = application.getModule(moduleName);
resources = module.getResources();
scope = ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX;
} else if (applicationName != null) {
if (!poolUtil.isValidApplication(applicationName, poolName, report)) {
return;
}
Application application = applications.getApplication(applicationName);
resources = application.getResources();
scope = ConnectorConstants.JAVA_APP_SCOPE_PREFIX;
}
if (!poolUtil.isValidPool(resources, poolName, scope, report)) {
return;
}
boolean poolingEnabled = false;
ResourcePool pool = (ResourcePool) ConnectorsUtil.getResourceByName(resources, ResourcePool.class, poolName);
if (pool instanceof ConnectorConnectionPool) {
ConnectorConnectionPool ccp = (ConnectorConnectionPool) pool;
poolingEnabled = Boolean.valueOf(ccp.getPooling());
} else {
JdbcConnectionPool ccp = (JdbcConnectionPool) pool;
poolingEnabled = Boolean.valueOf(ccp.getPooling());
}
if (!poolingEnabled) {
String i18nMsg = localStrings.getLocalString("flush.connection.pool.pooling.disabled", "Attempt to Flush Connection Pool failed because Pooling is disabled for pool : {0}", poolName);
report.setMessage(i18nMsg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
PoolInfo poolInfo = new PoolInfo(poolName, applicationName, moduleName);
_runtime.flushConnectionPool(poolInfo);
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
} catch (ConnectorRuntimeException e) {
report.setMessage(localStrings.getLocalString("flush.connection.pool.fail", "Flush connection pool for {0} failed", poolName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
}
use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.
the class ConnectorResourceDeployer method deployResource.
/**
* {@inheritDoc}
*/
public synchronized void deployResource(Object resource, String applicationName, String moduleName) throws Exception {
// deployResource is not synchronized as there is only one caller
// ResourceProxy which is synchronized
ConnectorResource domainResource = (ConnectorResource) resource;
ResourceInfo resourceInfo = new ResourceInfo(domainResource.getJndiName(), applicationName, moduleName);
PoolInfo poolInfo = new PoolInfo(domainResource.getPoolName(), applicationName, moduleName);
createConnectorResource(domainResource, resourceInfo, poolInfo);
}
use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.
the class ConnectorResourceDeployer method checkAndDeletePool.
/**
* Checks if no more resource-refs to resources exists for the
* connector connection pool and then deletes the pool
*
* @param cr ConnectorResource
* @throws Exception (ConfigException / undeploy exception)
* @since 8.1 pe/se/ee
*/
private void checkAndDeletePool(ConnectorResource 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 ConnectorResource here is a ConnectorResourceeDefinition. Ignore optimization.
if (resources != null) {
try {
boolean poolReferred = ResourcesUtil.createInstance().isPoolReferredInServerInstance(poolInfo);
if (!poolReferred) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Deleting connector connection pool [" + poolName + "] as there are no more " + "resource-refs to the pool in this server instance");
}
ConnectorConnectionPool ccp = (ConnectorConnectionPool) ConnectorsUtil.getResourceByName(resources, ConnectorConnectionPool.class, poolName);
// Delete/Undeploy Pool
runtime.getResourceDeployer(ccp).undeployResource(ccp);
}
} catch (Exception ce) {
_logger.warning(ce.getMessage());
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Exception while deleting pool [ " + poolName + " ] : " + ce);
}
throw ce;
}
}
}
Aggregations