Package org.apache.jcs.engine.behavior

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


        if ( log.isDebugEnabled() )
        {
            log.debug( "handleRemoveAll> cacheName=" + cacheName );
        }
        getCacheManager();
        ICache cache = cacheMgr.getCache( cacheName );
        cache.removeAll();
    }
View Full Code Here


    /** Description of the Method */
    public void freeCache( String name )
        throws IOException
    {
        ICache c = null;

        synchronized ( caches )
        {
            c = ( ICache ) caches.get( name );
        }
        if ( c != null )
        {
            c.dispose();
        }
    }
View Full Code Here

        synchronized ( caches )
        {
            Iterator allCaches = caches.values().iterator();
            while ( allCaches.hasNext() )
            {
                ICache c = ( ICache ) allCaches.next();
                if ( c != null )
                {
                    try
                    {
                        c.dispose();
                    }
                    catch ( IOException ex )
                    {
                        log.error( ex );
                    }
View Full Code Here

            }
        }

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

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

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

                if ( ce.getElementAttributes().getIsRemote()
                     && ! localOnly )
                {
                    try
                    {
                        // need to make sure the group cache understands that the
                        // key is a group attribute on update
                        aux.update( ce );
                        if ( log.isDebugEnabled() )
                        {
                            log.debug( "Updated remote store for "
                                 + ce.getKey() + ce );
                        }
                    }
                    catch ( IOException ex )
                    {
                        log.error( "Failure in updateExclude", ex );
                    }
                }
                // SEND LATERALLY
            }
            else if ( aux != null
                 && 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()
                     && ce.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( ce );
                    if ( log.isDebugEnabled() )
                    {
                        log.debug( "updated lateral cache for " + ce.getKey() );
                    }
                }
            }
            else if ( aux != null && aux.getCacheType() == ICache.DISK_CACHE )
            {
                // do nothing, the memory manager will call spool where necesary
                // TODO: add option to put all element on disk
            }
        }
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;

                // write the last item to disk.2
                try
                {
                    // handle event, might move to a new method
                    ArrayList eventHandlers = ce.getElementAttributes().getElementEventHandlers();
                    if ( eventHandlers != null )
                    {
                        if ( log.isDebugEnabled() )
                        {
                            log.debug( "Handlers are registered.  Event -- ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE" );
                        }
                        IElementEvent event = new ElementEvent( ce, IElementEventConstants.ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE );
                        Iterator hIt = eventHandlers.iterator();
                        while ( hIt.hasNext() )
                        {
                            IElementEventHandler hand = ( IElementEventHandler ) hIt.next();
                            //hand.handleElementEvent( event );
                            addElementEvent( hand, event );
                        }
                    }

                    aux.update( ce );
                }
                catch ( IOException ex )
                {
                    // impossible case.
                    ex.printStackTrace();
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
                {
                    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 )
                {
                    continue;
                }

                // 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

                if ( aux.getCacheType() != ICacheType.LATERAL_CACHE
                     || this.cacheAttr.getUseLateral() )
                {
                    Iterator itr = memCache.getIterator();

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

                        ICacheElement ce = (ICacheElement) entry.getValue();
                        try
                        {
                            if ( aux.getCacheType() == ICacheType.LATERAL_CACHE
                                 && !ce.getElementAttributes().getIsLateral() )
                            {
                                continue;
                            }
                            aux.update( ce );
                        }
                        catch ( Exception e )
                        {
                            log.error( e );
                        }
                    }
                }

                // Only call the dispose method for disk auxilliaries

                // FIXME: Why not always call it?

                if ( aux.getCacheType() == ICache.DISK_CACHE )
                {
                    aux.dispose();
                }

            }
            catch ( IOException 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

        String result = "";

        try
        {

            ICache cache = 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

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.