Search in sources :

Example 1 with ResourceAllocator

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

the class ConnectionPool method cleanupResource.

protected boolean cleanupResource(ResourceHandle handle) {
    boolean cleanupSuccessful = true;
    // cleanup resource
    try {
        ResourceAllocator alloc = handle.getResourceAllocator();
        alloc.cleanup(handle);
    } catch (PoolingException ex) {
        Object[] params = new Object[] { poolInfo, ex };
        _logger.log(Level.WARNING, "cleanup.resource.failed", params);
        cleanupSuccessful = false;
        resourceErrorOccurred(handle);
    }
    return cleanupSuccessful;
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceAllocator(com.sun.enterprise.resource.allocator.ResourceAllocator)

Example 2 with ResourceAllocator

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

the class Resizer method isResourceEligibleForRemoval.

protected boolean isResourceEligibleForRemoval(ResourceHandle h, int validConnectionsCounter) {
    boolean isResourceEligibleForRemoval = false;
    ResourceState state = h.getResourceState();
    // remove all idle-time lapsed resources.
    ResourceAllocator alloc = h.getResourceAllocator();
    if (preferValidateOverRecreate && alloc.hasValidatingMCF()) {
        // is valid but only till the steady pool size.
        if (validConnectionsCounter < pool.getSteadyPoolSize() && alloc.isConnectionValid(h)) {
            h.setLastValidated(System.currentTimeMillis());
            state.touchTimestamp();
        } else {
            // Connection invalid and hence remove resource.
            if (_logger.isLoggable(Level.FINEST)) {
                if (validConnectionsCounter <= pool.getSteadyPoolSize()) {
                    _logger.log(Level.FINEST, "PreferValidateOverRecreate: " + "Removing idle resource " + h + " from the free pool as the RA reports it to be invalid");
                } else {
                    _logger.log(Level.FINEST, "PreferValidateOverRecreate: " + "Removing idle resource " + h + " from the free pool as the steady part size has " + "already been exceeded (" + validConnectionsCounter + " > " + pool.getSteadyPoolSize() + ")");
                }
            }
            isResourceEligibleForRemoval = true;
        }
    } else {
        isResourceEligibleForRemoval = true;
    }
    return isResourceEligibleForRemoval;
}
Also used : ResourceAllocator(com.sun.enterprise.resource.allocator.ResourceAllocator) ResourceState(com.sun.enterprise.resource.ResourceState)

Example 3 with ResourceAllocator

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

the class ConnectionManagerImpl method getResource.

private Object getResource(int txLevel, PoolManager poolmgr, ManagedConnectionFactory mcf, ResourceSpec spec, Subject subject, ConnectionRequestInfo cxRequestInfo, ClientSecurityInfo info, ConnectorDescriptor desc, boolean shareable) throws PoolingException, ResourceAllocationException, IllegalStateException, RetryableUnavailableException {
    ResourceAllocator alloc;
    switch(txLevel) {
        case ConnectorConstants.NO_TRANSACTION_INT:
            alloc = new NoTxConnectorAllocator(poolmgr, mcf, spec, subject, cxRequestInfo, info, desc);
            break;
        case ConnectorConstants.LOCAL_TRANSACTION_INT:
            alloc = new LocalTxConnectorAllocator(poolmgr, mcf, spec, subject, cxRequestInfo, info, desc, shareable);
            break;
        case ConnectorConstants.XA_TRANSACTION_INT:
            if (rarName.equals(ConnectorRuntime.DEFAULT_JMS_ADAPTER)) {
                shareable = false;
            }
            spec.markAsXA();
            alloc = new ConnectorAllocator(poolmgr, mcf, spec, subject, cxRequestInfo, info, desc, shareable);
            return poolmgr.getResource(spec, alloc, info);
        default:
            String i18nMsg = getLocalStrings().getString("con_mgr.illegal_tx_level", txLevel + " ");
            throw new IllegalStateException(i18nMsg);
    }
    return poolmgr.getResource(spec, alloc, info);
}
Also used : NoTxConnectorAllocator(com.sun.enterprise.resource.allocator.NoTxConnectorAllocator) ConnectorAllocator(com.sun.enterprise.resource.allocator.ConnectorAllocator) LocalTxConnectorAllocator(com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator) IllegalStateException(javax.resource.spi.IllegalStateException) NoTxConnectorAllocator(com.sun.enterprise.resource.allocator.NoTxConnectorAllocator) LocalTxConnectorAllocator(com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator) ResourceAllocator(com.sun.enterprise.resource.allocator.ResourceAllocator)

Aggregations

ResourceAllocator (com.sun.enterprise.resource.allocator.ResourceAllocator)3 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)1 ResourceState (com.sun.enterprise.resource.ResourceState)1 ConnectorAllocator (com.sun.enterprise.resource.allocator.ConnectorAllocator)1 LocalTxConnectorAllocator (com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator)1 NoTxConnectorAllocator (com.sun.enterprise.resource.allocator.NoTxConnectorAllocator)1 IllegalStateException (javax.resource.spi.IllegalStateException)1