Search in sources :

Example 11 with ResourceHandle

use of com.sun.enterprise.resource.ResourceHandle in project Payara by payara.

the class ConnectionPool method internalGetResource.

protected ResourceHandle internalGetResource(ResourceSpec spec, ResourceAllocator alloc, Transaction tran) throws PoolingException {
    if (!poolInitialized) {
        initPool(alloc);
    }
    ResourceHandle result;
    result = getResourceFromTransaction(tran, alloc, spec);
    if (result != null) {
        return result;
    }
    result = prefetch(spec, alloc, tran);
    if (result != null) {
        return result;
    }
    // We didnt get a connection that is already enlisted in the current transaction (if any).
    result = getUnenlistedResource(spec, alloc, tran);
    if (result != null) {
        if (maxConnectionUsage_ > 0) {
            result.incrementUsageCount();
        }
        if (poolLifeCycleListener != null) {
            poolLifeCycleListener.connectionUsed(result.getId());
            // Decrement numConnFree
            poolLifeCycleListener.decrementNumConnFree();
        }
    }
    return result;
}
Also used : ResourceHandle(com.sun.enterprise.resource.ResourceHandle)

Example 12 with ResourceHandle

use of com.sun.enterprise.resource.ResourceHandle in project Payara by payara.

the class PoolManagerImpl method resourceEnlisted.

public void resourceEnlisted(Transaction tran, com.sun.appserv.connectors.internal.api.ResourceHandle h) throws IllegalStateException {
    ResourceHandle res = (ResourceHandle) h;
    PoolInfo poolInfo = res.getResourceSpec().getPoolInfo();
    try {
        JavaEETransaction j2eeTran = (JavaEETransaction) tran;
        if (poolInfo != null && j2eeTran.getResources(poolInfo) == null) {
            addSyncListener(tran);
        }
    } catch (ClassCastException e) {
        addSyncListener(tran);
    }
    if (poolInfo != null) {
        ResourcePool pool = getPool(poolInfo);
        if (pool != null) {
            pool.resourceEnlisted(tran, res);
        }
    }
}
Also used : JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) ResourceHandle(com.sun.enterprise.resource.ResourceHandle) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 13 with ResourceHandle

use of com.sun.enterprise.resource.ResourceHandle in project Payara by payara.

the class PoolManagerImpl method unregisterResource.

public void unregisterResource(com.sun.appserv.connectors.internal.api.ResourceHandle resource, int xaresFlag) {
    ResourceHandle h = (ResourceHandle) resource;
    ResourceManager rm = getResourceManager(h.getResourceSpec());
    rm.unregisterResource(h, xaresFlag);
}
Also used : ResourceHandle(com.sun.enterprise.resource.ResourceHandle)

Example 14 with ResourceHandle

use of com.sun.enterprise.resource.ResourceHandle in project Payara by payara.

the class UnpooledResource method getUnenlistedResource.

@Override
protected ResourceHandle getUnenlistedResource(ResourceSpec spec, ResourceAllocator alloc, Transaction tran) throws PoolingException {
    ResourceHandle handle = null;
    if (incrementPoolSize()) {
        try {
            handle = createSingleResource(alloc);
        } catch (PoolingException ex) {
            decrementPoolSize();
            throw ex;
        }
        ResourceState state = new ResourceState();
        handle.setResourceState(state);
        state.setEnlisted(false);
        setResourceStateToBusy(handle);
        return handle;
    }
    String msg = localStrings.getStringWithDefault("poolmgr.max.pool.size.reached", "In-use connections equal max-pool-size therefore cannot allocate any more connections.");
    throw new PoolingException(msg);
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceHandle(com.sun.enterprise.resource.ResourceHandle) ResourceState(com.sun.enterprise.resource.ResourceState)

Example 15 with ResourceHandle

use of com.sun.enterprise.resource.ResourceHandle in project Payara by payara.

the class RWLockDataStructure method getResource.

/**
 * {@inheritDoc}
 */
public ResourceHandle getResource() {
    readLock.lock();
    for (int i = 0; i < resources.size(); i++) {
        ResourceHandle h = resources.get(i);
        if (!h.isBusy()) {
            readLock.unlock();
            writeLock.lock();
            try {
                if (!h.isBusy()) {
                    h.setBusy(true);
                    return h;
                } else {
                    readLock.lock();
                    continue;
                }
            } finally {
                writeLock.unlock();
            }
        } else {
            continue;
        }
    }
    readLock.unlock();
    return null;
}
Also used : ResourceHandle(com.sun.enterprise.resource.ResourceHandle)

Aggregations

ResourceHandle (com.sun.enterprise.resource.ResourceHandle)36 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)11 ResourceException (javax.resource.ResourceException)9 ResourceState (com.sun.enterprise.resource.ResourceState)6 JavaEETransaction (com.sun.enterprise.transaction.api.JavaEETransaction)5 HashSet (java.util.HashSet)5 AssocWithThreadResourceHandle (com.sun.enterprise.resource.AssocWithThreadResourceHandle)4 ManagedConnection (javax.resource.spi.ManagedConnection)3 RetryableUnavailableException (javax.resource.spi.RetryableUnavailableException)3 ResourceSpec (com.sun.enterprise.resource.ResourceSpec)2 JavaEETransactionManager (com.sun.enterprise.transaction.api.JavaEETransactionManager)2 Set (java.util.Set)2 InvocationException (org.glassfish.api.invocation.InvocationException)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 XAResourceWrapper (com.sun.enterprise.resource.XAResourceWrapper)1 ConnectionEventListener (com.sun.enterprise.resource.listener.ConnectionEventListener)1 PoolManager (com.sun.enterprise.resource.pool.PoolManager)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Iterator (java.util.Iterator)1 List (java.util.List)1