Package com.sun.enterprise.resource

Examples of com.sun.enterprise.resource.ResourceState


                        if (h.hasConnectionErrorOccurred()) {
                            iter.remove();
                            continue;
                        }

                        ResourceState state = h.getResourceState();
                        /*
                         * One can share a resource only for the following conditions:
                         * 1. The caller resource is shareable (look at the outermost
                         *    if marked comment-1
                         * 2. The resource enlisted inside the transaction is shareable
                         * 3. We are dealing with XA resources OR
                         *    We are dealing with a non-XA resource that's not in use
                         *    Note that sharing a non-xa resource that's in use involves
                         *    associating physical connections.
                         * 4. The credentials of the resources match
                         */
                        if (h.getResourceAllocator().shareableWithinComponent()) {
                            if (spec.isXA() || poolTxHelper.isNonXAResourceAndFree(j2eetran, h)) {
                                if (matchConnections) {
                                    if (!alloc.matchConnection(h)) {
                                        if (poolLifeCycleListener != null) {
                                            poolLifeCycleListener.connectionNotMatched();
                                        }
                                        continue;
                                    }
                                    if (h.hasConnectionErrorOccurred()) {
                                        if (failAllConnections) {
                                            //if failAllConnections has happened, we flushed the
                                            //pool, so we don't have to do iter.remove else we
                                            //will get a ConncurrentModificationException
                                            result = null;
                                            break;
                                        }
                                        iter.remove();
                                        continue;
                                    }
                                    if (poolLifeCycleListener != null) {
                                        poolLifeCycleListener.connectionMatched();
                                    }
                                }
                                if (state.isFree())
                                    setResourceStateToBusy(h);
                                result = h;
                                break;
                            }
                        }
View Full Code Here


            throws IllegalStateException {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "Pool: resourceClosed: " + h);
        }

        ResourceState state = getResourceState(h);
        if (state == null) {
            throw new IllegalStateException("State is null");
        }

        if (!state.isBusy()) {
            throw new IllegalStateException("state.isBusy() : false");
        }

        setResourceStateToFree(h)// mark as not busy
        state.touchTimestamp();

        if (state.isUnenlisted() || (poolTxHelper.isNonXAResource(h) &&
                poolTxHelper.isLocalTransactionInProgress()
                && poolTxHelper.isLocalResourceEligibleForReuse(h))) {
            freeUnenlistedResource(h);
        }
       
View Full Code Here

        if (failAllConnections) {
            doFailAllConnectionsProcessing();
            return;
        }

        ResourceState state = getResourceState(h);
        // The reason is that normally connection error is expected
        // to occur only when the connection is in use by the application.
        // When there is connection validation involved, the connection
        // can be checked for validity "before" it is passed to the
        // application i.e. when the resource is still free. Since,
View Full Code Here

    public ResourceHandle createResource(ResourceAllocator alloc) throws PoolingException {
        //NOTE : Pool should not call this method directly, it should be called only by pool-datastructure
        ResourceHandle result = createSingleResource(alloc);

        ResourceState state = new ResourceState();
        state.setBusy(false);
        state.setEnlisted(false);
        result.setResourceState(state);

        if (poolLifeCycleListener != null) {
            poolLifeCycleListener.connectionCreated();
        }
View Full Code Here

                handle = createSingleResource(alloc);
            }catch (PoolingException ex){
                decrementPoolSize();
                throw ex;
            }
            ResourceState state = new ResourceState();
            handle.setResourceState(state);
            state.setEnlisted(false);
            setResourceStateToBusy(handle);
            return handle;
        }
        _logger.info("Fail as poolSize : " + poolSize);
        String msg = localStrings.getStringWithDefault(
View Full Code Here

                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",
View Full Code Here

    protected int removeIdleAndInvalidResources() {

        int poolSizeBeforeRemoval = ds.getResourcesSize();
        int noOfResourcesRemoved;
        //Find all Connections that are free/not-in-use
        ResourceState state;
        int size = ds.getFreeListSize();
        // let's cache the current time since precision is not required here.
        long currentTime = System.currentTimeMillis();
        int validConnectionsCounter = 0;
        int idleConnKeptInSteadyCounter = 0;
       
        //iterate through all thre active resources to find idle-time lapsed ones.
        ResourceHandle h;
        Set<ResourceHandle> activeResources = new HashSet<ResourceHandle>();
        Set<String> resourcesToValidate = new HashSet<String>();
        try {
            while ((h = ds.getResource()) != null ) {
                state = h.getResourceState();
                if (currentTime - state.getTimestamp() < pool.getIdleTimeout()) {
                    //Should be added for validation.
                    validConnectionsCounter++;
                    resourcesToValidate.add(h.toString());
                    activeResources.add(h);
                } else {
View Full Code Here

    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()) {
            //validConnectionsCounter is incremented if the connection
            //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: "
View Full Code Here

        int noOfResourcesRemoved = 0;
        // let's cache the current time since precision is not required here.
        long currentTime = System.currentTimeMillis();
        int validConnectionsCounter = 0;
        int idleConnKeptInSteadyCounter = 0;
        ResourceState state;

        Set<ResourceHandle> resourcesToValidate = new HashSet<ResourceHandle>();
        Set<ResourceHandle> resourcesToRemove = new HashSet<ResourceHandle>();
        try {
            //iterate through all the resources to find idle-time lapsed ones.
            for (ResourceHandle h : ds.getAllResources()) {
                synchronized (h.lock) {
                    state = h.getResourceState();
                    if (!state.isBusy()) {
                        if (currentTime - state.getTimestamp() < pool.getIdleTimeout()) {
                            //Should be added for validation.
                            if (state.isUnenlisted() && state.isFree()) {
                                if (((AssocWithThreadResourceHandle) h).isAssociated()) {
                                    ((AssocWithThreadResourceHandle) h).setAssociated(false);
                                    validConnectionsCounter++;
                                    resourcesToValidate.add(h);
                                }
View Full Code Here

                        if (h.hasConnectionErrorOccurred()) {
                            iter.remove();
                            continue;
                        }

                        ResourceState state = h.getResourceState();
                        /*
                         * One can share a resource only for the following conditions:
                         * 1. The caller resource is shareable (look at the outermost
                         *    if marked comment-1
                         * 2. The resource enlisted inside the transaction is shareable
                         * 3. We are dealing with XA resources OR
                         *    We are dealing with a non-XA resource that's not in use
                         *    Note that sharing a non-xa resource that's in use involves
                         *    associating physical connections.
                         * 4. The credentials of the resources match
                         */
                        if (h.getResourceAllocator().shareableWithinComponent()) {
                            if (spec.isXA() || poolTxHelper.isNonXAResourceAndFree(j2eetran, h)) {
                                if (matchConnections) {
                                    if (!alloc.matchConnection(h)) {
                                        if (poolLifeCycleListener != null) {
                                            poolLifeCycleListener.connectionNotMatched();
                                        }
                                        continue;
                                    }
                                    if (h.hasConnectionErrorOccurred()) {
                                        if (failAllConnections) {
                                            //if failAllConnections has happened, we flushed the
                                            //pool, so we don't have to do iter.remove else we
                                            //will get a ConncurrentModificationException
                                            result = null;
                                            break;
                                        }
                                        iter.remove();
                                        continue;
                                    }
                                    if (poolLifeCycleListener != null) {
                                        poolLifeCycleListener.connectionMatched();
                                    }
                                }
                                if (state.isFree())
                                    setResourceStateToBusy(h);
                                result = h;
                                break;
                            }
                        }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.resource.ResourceState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.