Package org.apache.jcs.engine.behavior

Examples of org.apache.jcs.engine.behavior.ICache


            }
        }

        for ( int i = 0; i < auxCaches.length; i++ )
        {
            ICache aux = auxCaches[i];

            if ( log.isDebugEnabled() )
            {
                log.debug( "Auxilliary cache type: " + aux.getCacheType() );
            }

            if ( aux == null )
            {
                continue;
            }

            // SEND TO REMOTE STORE
            if ( aux.getCacheType() == ICache.REMOTE_CACHE )
            {
                if ( log.isDebugEnabled() )
                {
                    log.debug( "ce.getElementAttributes().getIsRemote() = "
                        + cacheElement.getElementAttributes().getIsRemote() );
                }

                if ( cacheElement.getElementAttributes().getIsRemote() && !localOnly )
                {
                    try
                    {
                        // need to make sure the group cache understands that
                        // the key is a group attribute on update
                        aux.update( cacheElement );
                        if ( log.isDebugEnabled() )
                        {
                            log.debug( "Updated remote store for " + cacheElement.getKey() + cacheElement );
                        }
                    }
                    catch ( IOException ex )
                    {
                        log.error( "Failure in updateExclude", ex );
                    }
                }
                // SEND LATERALLY
            }
            else if ( aux.getCacheType() == ICache.LATERAL_CACHE )
            {
                // lateral can't do the checking since it is dependent on the
                // cache region restrictions
                if ( log.isDebugEnabled() )
                {
                    log.debug( "lateralcache in aux list: cattr " + cacheAttr.getUseLateral() );
                }
                if ( cacheAttr.getUseLateral() && cacheElement.getElementAttributes().getIsLateral() && !localOnly )
                {
                    // later if we want a multicast, possibly delete abnormal
                    // broadcaster
                    // DISTRIBUTE LATERALLY
                    // Currently always multicast even if the value is
                    // unchanged,
                    // just to cause the cache item to move to the front.
                    aux.update( cacheElement );
                    if ( log.isDebugEnabled() )
                    {
                        log.debug( "updated lateral cache for " + cacheElement.getKey() );
                    }
                }
            }
            // update disk if the usage pattern permits
            else if ( aux.getCacheType() == ICache.DISK_CACHE )
            {
                if ( log.isDebugEnabled() )
                {
                    log.debug( "diskcache in aux list: cattr " + cacheAttr.getUseDisk() );
                }
                if ( cacheAttr.getUseDisk()
                    && ( cacheAttr.getDiskUsagePattern() == ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE )
                    && cacheElement.getElementAttributes().getIsSpool() )
                {
                    aux.update( cacheElement );
                    if ( log.isDebugEnabled() )
                    {
                        log.debug( "updated disk cache for " + cacheElement.getKey() );
                    }
                }
View Full Code Here


        boolean diskAvailable = false;

        // SPOOL TO DISK.
        for ( int i = 0; i < auxCaches.length; i++ )
        {
            ICache aux = auxCaches[i];

            if ( aux != null && aux.getCacheType() == ICache.DISK_CACHE )
            {
                diskAvailable = true;

                if ( cacheAttr.getDiskUsagePattern() == ICompositeCacheAttributes.DISK_USAGE_PATTERN_SWAP )
                {
                    // write the last items to disk.2
                    try
                    {
                        handleElementEvent( ce, IElementEventConstants.ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE );

                        aux.update( ce );
                    }
                    catch ( IOException ex )
                    {
                        // impossible case.
                        log.error( "Problem spooling item to disk cache.", ex );
View Full Code Here

        }

        // Removes from all auxiliary caches.
        for ( int i = 0; i < auxCaches.length; i++ )
        {
            ICache aux = auxCaches[i];

            if ( aux == null )
            {
                continue;
            }

            int cacheType = aux.getCacheType();

            // for now let laterals call remote remove but not vice versa

            if ( localOnly && ( cacheType == REMOTE_CACHE || cacheType == LATERAL_CACHE ) )
            {
                continue;
            }
            try
            {
                if ( log.isDebugEnabled() )
                {
                    log.debug( "Removing " + key + " from cacheType" + cacheType );
                }

                boolean b = aux.remove( key );

                // Don't take the remote removal into account.
                if ( !removed && cacheType != REMOTE_CACHE )
                {
                    removed = b;
View Full Code Here

        }

        // Removes from all auxiliary disk caches.
        for ( int i = 0; i < auxCaches.length; i++ )
        {
            ICache aux = auxCaches[i];

            int cacheType = aux.getCacheType();

            if ( aux != null && ( cacheType == ICache.DISK_CACHE || !localOnly ) )
            {
                try
                {
                    if ( log.isDebugEnabled() )
                    {
                        log.debug( "Removing All keys from cacheType" + cacheType );
                    }

                    aux.removeAll();
                }
                catch ( IOException ex )
                {
                    log.error( "Failure removing all from aux", ex );
                }
View Full Code Here

        for ( int i = 0; i < auxCaches.length; i++ )
        {
            try
            {
                ICache aux = auxCaches[i];

                // Skip this auxilliary if:
                // - The auxilliary is null
                // - The auxilliary is not alive
                // - The auxilliary is remote and the invocation was remote

                if ( aux == null || aux.getStatus() != CacheConstants.STATUS_ALIVE
                    || ( fromRemote && aux.getCacheType() == REMOTE_CACHE ) )
                {
                    if ( log.isInfoEnabled() )
                    {
                        log.info( "In DISPOSE, [" + this.cacheName + "] SKIPPING auxiliary [" + aux + "] fromRemote ["
                            + fromRemote + "]" );
                    }
                    continue;
                }

                if ( log.isInfoEnabled() )
                {
                    log.info( "In DISPOSE, [" + this.cacheName + "] auxiliary [" + aux + "]" );
                }

                // IT USED TO BE THE CASE THAT (If the auxilliary is not a lateral, or the cache
                // attributes
                // have 'getUseLateral' set, all the elements currently in
                // memory are written to the lateral before disposing)
                // I changed this. It was excessive. Only the disk cache needs the items, since only
                // the disk cache
                // is in a situation to not get items on a put.

                if ( aux.getCacheType() == ICacheType.DISK_CACHE )
                {
                    int numToFree = memCache.getSize();
                    memCache.freeElements( numToFree );

                    if ( log.isInfoEnabled() )
                    {
                        log.info( "In DISPOSE, [" + this.cacheName + "] put " + numToFree + " into auxiliary " + aux );
                    }
                }

                // Dispose of the auxiliary
                aux.dispose();
            }
            catch ( IOException ex )
            {
                log.error( "Failure disposing of aux.", ex );
            }
View Full Code Here

            for ( int i = 0; i < auxCaches.length; i++ )
            {
                try
                {
                    ICache aux = auxCaches[i];

                    if ( aux.getStatus() == CacheConstants.STATUS_ALIVE )
                    {

                        Iterator itr = memCache.getIterator();

                        while ( itr.hasNext() )
                        {
                            Map.Entry entry = (Map.Entry) itr.next();

                            ICacheElement ce = (ICacheElement) entry.getValue();

                            aux.update( ce );
                        }
                    }
                }
                catch ( IOException ex )
                {
View Full Code Here

        // some junk to return for a synchronous call
        String result = "";

        try
        {
            ICache cache = this.cacheMgr.getCache( cacheName );

            if ( key != null )
            {
                if ( key.toUpperCase().equals( "ALL" ) )
                {
                    cache.removeAll();

                    if ( log.isDebugEnabled() )
                    {
                        log.debug( "Removed all elements from " + cacheName );
                    }
                    result = "key = " + key;
                }
                else
                {
                    if ( log.isDebugEnabled() )
                    {
                        log.debug( "key = " + key );
                    }
                    result = "key = " + key;
                    StringTokenizer toke = new StringTokenizer( key, "_" );

                    while ( toke.hasMoreElements() )
                    {
                        String temp = (String) toke.nextElement();
                        cache.remove( key );

                        if ( log.isDebugEnabled() )
                        {
                            log.debug( "Removed " + temp + " from " + cacheName );
                        }
View Full Code Here

        {
            Hashtable ht = new Hashtable();
            String name = list[i];
            ht.put( "name", name );

            ICache cache = this.cacheMgr.getCache( name );
            int size = cache.getSize();
            ht.put( "size", Integer.toString( size ) );

            int status = cache.getStatus();
            String stat = status == CacheConstants.STATUS_ALIVE
                                                               ? "ALIVE"
                                                               : status == CacheConstants.STATUS_DISPOSED
                                                                                                         ? "DISPOSED"
                                                                                                         : status == CacheConstants.STATUS_ERROR
View Full Code Here

    {
        if ( log.isInfoEnabled() )
        {
            log.info( "freeCache [" + name + "]" );
        }
        ICache c = null;
        synchronized ( caches )
        {
            c = (ICache) caches.get( name );
        }
        if ( c != null )
        {
            this.removeRemoteCacheListener( name );
            c.dispose();
        }
    }
View Full Code Here

    {
        StringBuffer stats = new StringBuffer();
        Iterator allCaches = caches.values().iterator();
        while ( allCaches.hasNext() )
        {
            ICache c = (ICache) allCaches.next();
            if ( c != null )
            {
                stats.append( c.getCacheName() );
            }
        }
        return stats.toString();
    }
View Full Code Here

TOP

Related Classes of org.apache.jcs.engine.behavior.ICache

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.