Package org.apache.jcs.engine.control

Examples of org.apache.jcs.engine.control.CompositeCache


    public void testHitInT1ThenT2BelowMax()
        throws Exception
    {
        CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance();
        cacheMgr.configure( "/TestARCCache.ccf" );
        CompositeCache cache = cacheMgr.getCache( "testGetKeyArray" );

        ARCMemoryCache arc = new ARCMemoryCache();
        arc.initialize( cache );

        int max = cache.getCacheAttributes().getMaxObjects();
        int items = max / 2;

        for ( int i = 0; i < items; i++ )
        {
            ICacheElement ice = new CacheElement( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i );
            ice.setElementAttributes( cache.getElementAttributes() );
            arc.update( ice );
        }

        ICacheElement element = arc.get( 0 + ":key" );
View Full Code Here


    public void testHitInT1AtMax()
        throws Exception
    {
        CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance();
        cacheMgr.configure( "/TestARCCache.ccf" );
        CompositeCache cache = cacheMgr.getCache( "testGetKeyArray" );

        ARCMemoryCache arc = new ARCMemoryCache();
        arc.initialize( cache );

        int max = cache.getCacheAttributes().getMaxObjects();
        int items = max;

        for ( int i = 0; i < items; i++ )
        {
            ICacheElement ice = new CacheElement( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i );
            ice.setElementAttributes( cache.getElementAttributes() );
            arc.update( ice );
        }

        ICacheElement element = arc.get( 0 + ":key" );
View Full Code Here

    public void SKIPtestHitInT1OverMax()
        throws Exception
    {
        CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance();
        cacheMgr.configure( "/TestARCCache.ccf" );
        CompositeCache cache = cacheMgr.getCache( "testGetKeyArray" );

        ARCMemoryCache arc = new ARCMemoryCache();
        arc.initialize( cache );

        int max = cache.getCacheAttributes().getMaxObjects();
        int items = max + 1;

        for ( int i = 0; i < items; i++ )
        {
            ICacheElement ice = new CacheElement( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i );
            ice.setElementAttributes( cache.getElementAttributes() );
            arc.update( ice );
        }

        ICacheElement element = arc.get( 0 + ":key" );
View Full Code Here

    public void testPutInT1ToMax()
        throws Exception
    {
        CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance();
        cacheMgr.configure( "/TestARCCache.ccf" );
        CompositeCache cache = cacheMgr.getCache( "testGetKeyArray" );

        ARCMemoryCache arc = new ARCMemoryCache();
        arc.initialize( cache );

        int max = cache.getCacheAttributes().getMaxObjects();
        int items = max;

        for ( int i = 0; i < items; i++ )
        {
            ICacheElement ice = new CacheElement( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i );
            ice.setElementAttributes( cache.getElementAttributes() );
            arc.update( ice );
        }

        //ICacheElement element = arc.get( 0 + ":key" );
View Full Code Here

            Serializable val = item.getVal();

            log.debug( "item read in = " + item );
            log.debug( "item.getKey = " + item.getKey() );

            CompositeCache cache = (CompositeCache) cacheMgr.getCache( hashtableName );
            try
            {
                // need to set as from lateral
                cache.localUpdate( item );
            }
            catch ( Exception e )
            {
                log.error( "Problem putting item in cache " + item, e );
            }
View Full Code Here

    public void testGetKeyArray()
        throws Exception
    {
        CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance();
        cacheMgr.configure( "/TestMRUCache.ccf" );
        CompositeCache cache = cacheMgr.getCache( "testGetKeyArray" );

        MRUMemoryCache mru = new MRUMemoryCache();
        mru.initialize( cache );

        int max = cache.getCacheAttributes().getMaxObjects();
        int items = max / 2;

        for ( int i = 0; i < items; i++ )
        {
            ICacheElement ice = new CacheElement( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i );
            ice.setElementAttributes( cache.getElementAttributes() );
            mru.update( ice );
        }

        Object[] keys = mru.getKeyArray();
View Full Code Here

            // ordered cache item update and notification.
            synchronized ( cacheDesc )
            {
                try
                {
                    CompositeCache c = (CompositeCache) cacheDesc.cache;

                    // If the source of this request was not from a cluster,
                    // then consider it a local update. The cache manager will
                    // try to
                    // update all auxiliaries.
                    //
                    // This requires that two local caches not be connected to
                    // two clustered remote caches. The failover runner will
                    // have to make sure of this. ALos, the local cache needs
                    // avoid updating this source. Will need to pass the source
                    // id somehow. The remote cache should udate all local
                    // caches
                    // but not update the cluster source. Cluster remote caches
                    // should only be updated by the server and not the
                    // RemoteCache.
                    if ( fromCluster )
                    {
                        if ( log.isDebugEnabled() )
                        {
                            log.debug( "Put FROM cluster, NOT updating other auxiliaries for region. "
                                + " requesterId [" + requesterId + "]" );
                        }
                        c.localUpdate( item );
                    }
                    else
                    {
                        if ( log.isDebugEnabled() )
                        {
                            log.debug( "Put NOT from cluster, updating other auxiliaries for region. "
                                + " requesterId [" + requesterId + "]" );
                        }
                        c.update( item );
                    }
                }
                catch ( Exception ce )
                {
                    // swallow
View Full Code Here

        if ( cacheDesc == null )
        {
            return null;
        }
        CompositeCache c = (CompositeCache) cacheDesc.cache;

        ICacheElement element = null;

        // If we have a get come in from a client and we don't have the item
        // locally, we will allow the cache to look in other non local sources,
        // such as a remote cache or a lateral.
        //
        // Since remote servers never get from clients and clients never go
        // remote from a remote call, this
        // will not result in any loops.
        //
        // This is the only instance I can think of where we allow a remote get
        // from a remote call. The purpose is to allow remote cache servers to
        // talk to each other. If one goes down, you want it to be able to get
        // data from those that were up when the failed server comes back o
        // line.

        if ( !fromCluster && this.rcsa.getAllowClusterGet() )
        {
            if ( log.isDebugEnabled() )
            {
                log.debug( "NonLocalGet. fromCluster [" + fromCluster + "] AllowClusterGet [" + this.rcsa.getAllowClusterGet() + "]"  );
            }
            element = c.get( key );
        }
        else
        {
            // Gets from cluster type remote will end up here.
            // Gets from all clients will end up here if allow cluster get is
            // false.

            if ( log.isDebugEnabled() )
            {
                log.debug( "LocalGet.  fromCluster [" + fromCluster + "] AllowClusterGet [" + this.rcsa.getAllowClusterGet() + "]" );
            }
            element = c.localGet( key );
        }

        return element;
    }
View Full Code Here

        if ( cacheDesc == null )
        {
            return Collections.EMPTY_SET;
        }
        CompositeCache c = (CompositeCache) cacheDesc.cache;
        return c.getGroupKeys( group );
    }
View Full Code Here

            synchronized ( cacheDesc )
            {
                boolean removeSuccess = false;

                // No need to notify if it was not cached.
                CompositeCache c = (CompositeCache) cacheDesc.cache;

                if ( fromCluster )
                {
                    if ( log.isDebugEnabled() )
                    {
                        log.debug( "Remove FROM cluster, NOT updating other auxiliaries for region" );
                    }
                    removeSuccess = c.localRemove( key );
                }
                else
                {
                    if ( log.isDebugEnabled() )
                    {
                        log.debug( "Remove NOT from cluster, updating other auxiliaries for region" );
                    }
                    removeSuccess = c.remove( key );
                }

                if ( log.isDebugEnabled() )
                {
                    log.debug( "remove [" + key + "] from cache [" + cacheName + "] success (was it found) = "
View Full Code Here

TOP

Related Classes of org.apache.jcs.engine.control.CompositeCache

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.