use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.
the class PoolWaitQueueFactory method initializeCustomWaitQueueInPrivilegedMode.
private static PoolWaitQueue initializeCustomWaitQueueInPrivilegedMode(final String className) throws PoolingException {
Object result = AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
Object result = null;
try {
result = initializeCustomWaitQueue(className);
} catch (Exception e) {
_logger.log(Level.WARNING, "pool.waitqueue.init.failure", className);
_logger.log(Level.WARNING, "pool.waitqueue.init.failure.exception", e);
}
return result;
}
});
if (result != null) {
return (PoolWaitQueue) result;
} else {
throw new PoolingException("Unable to initalize custom PoolWaitQueue : " + className);
}
}
use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.
the class ResourceManagerImpl method registerResource.
/**
* Register the <code>ResourceHandle</code> in the transaction
*
* @param handle <code>ResourceHandle</code> object
* @exception <code>PoolingException</code>
*/
public void registerResource(ResourceHandle handle) throws PoolingException {
try {
Transaction tran = null;
JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager();
// enlist if necessary
if (handle.isTransactional()) {
InvocationManager invmgr = ConnectorRuntime.getRuntime().getInvocationManager();
ComponentInvocation inv = invmgr.getCurrentInvocation();
if (inv == null) {
// in that, you return the transaction from the TxManager
try {
tran = tm.getTransaction();
} catch (Exception e) {
tran = null;
_logger.log(Level.INFO, e.getMessage());
}
} else {
tran = (Transaction) inv.getTransaction();
tm.registerComponentResource(handle);
}
if (tran != null) {
try {
tm.enlistResource(tran, handle);
} catch (Exception ex) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Exception whle trying to enlist resource " + ex.getMessage());
}
// to enlist the resource
if (inv != null) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Attempting to unregister component resource");
}
tm.unregisterComponentResource(handle);
}
throw ex;
}
}
}
} catch (Exception ex) {
_logger.log(Level.SEVERE, "poolmgr.component_register_exception", ex);
throw new PoolingException(ex.toString(), ex);
}
}
use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.
the class ConnectionPool method createSingleResource.
/**
* Method to be used to create resource, instead of calling ResourceAllocator.createConfigBean().
* This method handles the connection creation retrial in case of failure
*
* @param resourceAllocator ResourceAllocator
* @return ResourceHandle newly created resource
* @throws PoolingException when unable create a resource
*/
protected ResourceHandle createSingleResource(ResourceAllocator resourceAllocator) throws PoolingException {
ResourceHandle resourceHandle;
int count = 0;
long startTime = 0;
while (true) {
try {
count++;
startTime = System.currentTimeMillis();
resourceHandle = resourceAllocator.createResource();
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Time taken to create a single " + "resource : " + resourceHandle.getResourceSpec().getResourceId() + " and adding to the pool (ms) : " + (System.currentTimeMillis() - startTime));
}
if (validation || validateAtmostEveryIdleSecs)
resourceHandle.setLastValidated(System.currentTimeMillis());
break;
} catch (Exception ex) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Connection creation failed for " + count + " time. It will be retried, " + "if connection creation retrial is enabled.", ex);
}
if (!connectionCreationRetry_ || count > connectionCreationRetryAttempts_)
throw new PoolingException(ex);
try {
Thread.sleep(conCreationRetryInterval_);
} catch (InterruptedException ie) {
// ignore this exception
}
}
}
return resourceHandle;
}
use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.
the class ConnectionPool method getPoolConfigurationFromJndi.
protected ConnectorConnectionPool getPoolConfigurationFromJndi(Hashtable env) throws PoolingException {
ConnectorConnectionPool poolResource;
try {
String jndiNameOfPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo);
poolResource = (ConnectorConnectionPool) ConnectorRuntime.getRuntime().getResourceNamingService().lookup(poolInfo, jndiNameOfPool, env);
} catch (NamingException ex) {
throw new PoolingException(ex);
}
return poolResource;
}
use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.
the class PoolManagerImpl method getResource.
// invoked by DataSource objects to obtain a connection
public Object getResource(ResourceSpec spec, ResourceAllocator alloc, ClientSecurityInfo info) throws PoolingException, RetryableUnavailableException {
Transaction tran = null;
boolean transactional = alloc.isTransactional();
if (transactional) {
tran = getResourceManager(spec).getTransaction();
}
ResourceHandle handle = getResourceFromPool(spec, alloc, info, tran);
if (!handle.supportsLazyAssociation()) {
spec.setLazyAssociatable(false);
}
if (spec.isLazyAssociatable() && spec.getConnectionToAssociate() != null) {
// we need to associate a new connection with it
try {
Object connection = spec.getConnectionToAssociate();
ManagedConnection dmc = (ManagedConnection) handle.getResource();
dmc.associateConnection(connection);
} catch (ResourceException e) {
putbackDirectToPool(handle, spec.getPoolInfo());
PoolingException pe = new PoolingException(e.getMessage());
pe.initCause(e);
throw pe;
}
}
// we cannot either
if (!handle.supportsLazyEnlistment()) {
spec.setLazyEnlistable(false);
}
handle.setResourceSpec(spec);
try {
if (handle.getResourceState().isUnenlisted()) {
// The spec being used here is the spec with the updated
// lazy enlistment info
// Here's the real place where we care about the correct
// resource manager (which in turn depends upon the ResourceSpec)
// and that's because if lazy enlistment needs to be done
// we need to get the LazyEnlistableResourceManager
getResourceManager(spec).enlistResource(handle);
}
} catch (Exception e) {
// In the rare cases where enlistResource throws exception, we
// should throw the resource away
putbackBadResourceToPool(handle);
_logger.log(Level.WARNING, "poolmgr.err_enlisting_res_in_getconn", spec.getPoolInfo());
logFine("rm.enlistResource threw Exception. Evicting resource from pool");
// and rethrow the exception
throw new PoolingException(e);
}
return handle.getUserConnection();
}
Aggregations