Package org.apache.stratum.jcs.engine.behavior

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


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


        // more can be added if future auxiliary caches don't fit the model
        // You could run a database cache as either a remote or a local disk.
        // The types would describe the purpose.
        for ( int i = 0; i < auxCaches.length; i++ )
        {
            ICache aux = auxCaches[i];

            if ( log.isDebugEnabled() )
            {
                log.debug( "aux.getCacheType() = " + 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() && updateRemoteCache )
                {
                    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 )
                    {
                        handleException( 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() && updateRemoteCache )
                {

                    // 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() );
                    }
                }
                // end if lateral

                // DISK CACHE
            }
            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

    {

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

            if ( aux != null && aux.getCacheType() == ICache.DISK_CACHE )
            {
                // write the last item to disk.2
                try
                {
                    aux.update( ce );
                }
                catch ( IOException ex )
                {
                    // impossible case.
                    ex.printStackTrace();
View Full Code Here

            {
                // Item not found in memory.  Try the auxiliary caches if local.

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

                    if ( aux != null )
                    {

                        if ( ( invocation == this.LOCAL_INVOKATION ) || aux.getCacheType() == aux.DISK_CACHE )
                        {
                            if ( log.isDebugEnabled() )
                            {
                                log.debug( "get(key,container,invocation) > in local block, aux.getCacheType() = " + aux.getCacheType() );
                            }

                            try
                            {
                                ce = ( ICacheElement ) aux.get( key, true );
                            }
                            catch ( IOException ex )
                            {
                                handleException( 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;
            }
            // avoid notification dead loop.
            int cacheType = aux.getCacheType();

            // for now let laterals call remote remove but not vice versa
            if ( nonLocal && ( cacheType == REMOTE_CACHE || cacheType == LATERAL_CACHE ) )
            {
                continue;
            }
            try
            {
                boolean b = aux.remove( key );

                // Don't take the remote removal into account.
                if ( !removed && cacheType != REMOTE_CACHE )
                {
                    removed = b;
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

    {
        StringBuffer stats = new StringBuffer();
        Iterator allCaches = caches.values().iterator();
        while ( allCaches.hasNext() )
        {
            ICache c = ( ICache ) allCaches.next();
            if ( c != null )
            {
                stats.append( "<br>&nbsp;&nbsp;&nbsp;" + c.getStats() );
            }
        }
        return stats.toString();
    }
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

                        rca.setRemoteHost( server.substring( 0, server.indexOf( ":" ) ) );
                        rca.setRemotePort( Integer.parseInt( server.substring( server.indexOf( ":" ) + 1 ) ) );
                        RemoteCacheManager rcm = RemoteCacheManager.getInstance( rca );
                        log.debug( "RemoteCacheAttributes for failover = " + rca.toString() );
                        // add a listener if there are none, need to tell rca what number it is at
                        ICache ic = rcm.getCache( rca.getCacheName() );
                        if ( ic != null )
                        {
                            if ( ic.getStatus() == ic.STATUS_ALIVE )
                            {
                                // may need to do this more gracefully
                                log.debug( "reseting no wait" );
                                facade.noWaits = new RemoteCacheNoWait[1];
                                facade.noWaits[0] = ( RemoteCacheNoWait ) ic;
                                facade.rca.setFailoverIndex( i );

                                synchronized ( this )
                                {
                                    log.debug( "setting ALRIGHT to true, moving to Primary Recovery Mode" );
                                    alright = true;
                                    log.debug( "CONNECTED to " + rca.getRemoteHost() + ":" + rca.getRemotePort() + "\n\n" );
                                }

                            }
                        }
                        else
                        {
                            //p( "noWait is null" );
                        }

                    }
                    catch ( Exception ex )
                    {
                        bad();
                        log.debug( "FAILED to connect to " + rca.getRemoteHost() + ":" + rca.getRemotePort() );
                        // Problem encountered in fixing the caches managed by a RemoteCacheManager instance.
                        // Soldier on to the next RemoteCacheManager instance.
                        log.error( ex.toString() );
                    }
                }

            }
            // end if !alright
            else
            {
                log.warn( "ALRIGHT is true --  failover runner is in primary recovery mode" );
            }

            //try to move back to the primary
            String[] failovers = facade.rca.getFailovers();
            String server = failovers[0];
            try
            {

                RemoteCacheAttributes rca = ( RemoteCacheAttributes ) facade.rca.copy();
                rca.setRemoteHost( server.substring( 0, server.indexOf( ":" ) ) );
                rca.setRemotePort( Integer.parseInt( server.substring( server.indexOf( ":" ) + 1 ) ) );
                RemoteCacheManager rcm = RemoteCacheManager.getInstance( rca );
                // add a listener if there are none, need to tell rca what number it is at
                ICache ic = rcm.getCache( rca.getCacheName() );
                if ( ic != null )
                {
                    if ( ic.getStatus() == ic.STATUS_ALIVE )
                    {
                        // may need to do this more gracefully
                        log.debug( "reseting no wait to PRIMARY" );
                        facade.noWaits = new RemoteCacheNoWait[1];
                        facade.noWaits[0] = ( RemoteCacheNoWait ) ic;
View Full Code Here

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

TOP

Related Classes of org.apache.stratum.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.