Package org.apache.jcs.engine.behavior

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


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


                            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() == CacheConstants.STATUS_ALIVE )
                            {
                                // may need to do this more gracefully
                                log.debug( "reseting no wait" );
                                facade.noWaits = new RemoteCacheNoWait[1];
                                facade.noWaits[0] = (RemoteCacheNoWait) ic;
View Full Code Here

            rca.setRemotePort( Integer.parseInt( server.substring( server.indexOf( ":" ) + 1 ) ) );
            RemoteCacheManager rcm = RemoteCacheManager.getInstance( rca, cacheMgr );

            // add a listener if there are none, need to tell rca what number it
            // is at
            ICache ic = rcm.getCache( rca.getCacheName() );
            // by default the listener id should be 0, else it will be the
            // listener
            // orignally associated with the remote cache. either way is fine.
            // We just don't want the listener id from a failover being used.
            // If the remote server was rebooted this couldbe a problem if new
            // locals were also added.

            if ( ic != null )
            {
                if ( ic.getStatus() == CacheConstants.STATUS_ALIVE )
                {
                    try
                    {
                        // we could have more than one listener registered right
                        // now.
View Full Code Here

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

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

                    Arrays.sort( list );

                    for ( int i = 0; i < list.length; i++ )
                    {
                        String name = list[i];
                        ICache cache = cacheMgr.getCache( name );
                        cache.removeAll();
                    }
                    out.println( "All caches have been cleared!" );
                }
                else
                {

                    ICache cache = cacheMgr.getCache( hashtableName );

                    String task = ( String ) params.get( "task" );
                    if ( task == null )
                    {
                        task = "delete";
                    }

                    if ( task.equalsIgnoreCase( "stats" ) )
                    {

//                        out.println( "<br><br>" );
//                        out.println( "<b>Stats for " + hashtableName + ":</b><br>" );
//                        out.println( cache.getStats() );
//                        out.println( "<br>" );

                    }
                    else
                    {

                        // Remove the specified cache.

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

                                if ( log.isDebugEnabled() )
                                {
                                    log.debug( "Removed all elements from " + hashtableName );
                                }
                                out.println( "key = " + key );
                            }
                            else
                            {
                                if ( log.isDebugEnabled() )
                                {
                                    log.debug( "key = " + key );
                                }
                                out.println( "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 " + hashtableName );
                                    }
                                }
                            }
                        }
                        else
                        {
                            out.println( "key is null" );
                        }

                    }
                    // end is task == delete

                }
            }
            else
            {
                out.println( "(No hashTableName specified.)" );
            }

            // PRINT OUT MENU
            out.println( "<br>" );
            int antiCacheRandom = ( int ) ( 10000.0 * Math.random() );
            out.println( "<a href=?antiCacheRandom=" + antiCacheRandom
                 + ">List all caches</a><br>" );
            out.println( "<br>" );
            out.println( "<a href=?hashtableName=ALL&key=ALL&antiCacheRandom="
                 + antiCacheRandom
                 + "><font color=RED>Clear All Cache Regions</font></a><br>" );
            out.println( "<br>" );
            String[] list = cacheMgr.getCacheNames();
            Arrays.sort( list );
            out.println( "<div align=CENTER>" );
            out.println( "<table border=1 width=80%>" );
            out.println( "<tr bgcolor=#eeeeee><td>Cache Region Name</td><td>Size</td><td>Status</td><td>Stats</td>" );
            for ( int i = 0; i < list.length; i++ )
            {
                String name = list[i];
                out.println( "<tr><td><a href=?hashtableName=" + name + "&key=ALL&antiCacheRandom="
                     + antiCacheRandom + ">" + name + "</a></td>" );
                ICache cache = cacheMgr.getCache( name );
                out.println( "<td>" );
                out.print( cache.getSize() );
                out.print( "</td><td>" );
                int status = cache.getStatus();
                out.print( status == CacheConstants.STATUS_ALIVE ? "ALIVE"
                     : status == CacheConstants.STATUS_DISPOSED ? "DISPOSED"
                     : status == CacheConstants.STATUS_ERROR ? "ERROR"
                     : "UNKNOWN" );
                out.print( "</td>" );
View Full Code Here

     * @param cacheName
     *            Name of cache to dispose.
     */
    public void freeCache( String cacheName )
    {
        ICache cache = (ICache) caches.get( cacheName );

        if ( cache != null )
        {
            try
            {
                cache.dispose();
            }
            catch ( Exception e )
            {
                log.error( "Failure disposing cache: " + cacheName, e );
            }
View Full Code Here

        {
            Enumeration allCaches = caches.elements();

            while ( allCaches.hasMoreElements() )
            {
                ICache cache = (ICache) allCaches.nextElement();

                if ( cache != null )
                {
                    try
                    {
                        cache.dispose();
                    }
                    catch ( Exception e )
                    {
                        log.error( "Failure disposing cache: " + cache.getCacheName(), e );
                    }
                }
            }
        }
    }
View Full Code Here

            String key = (String) en.nextElement();
            if ( key.startsWith( SYSTEM_REGION_PREFIX ) && ( key.indexOf( "attributes" ) == -1 ) )
            {
                String regionName = key.substring( SYSTEM_REGION_PREFIX.length() );
                String value = OptionConverter.findAndSubst( key, props );
                ICache cache;
                synchronized ( regionName )
                {
                    cache = parseRegion( props, regionName, value, null, SYSTEM_REGION_PREFIX );
                }
                compositeCacheManager.systemCaches.put( regionName, cache );
View Full Code Here

                String regionName = key.substring( REGION_PREFIX.length() );

                regionNames.add( regionName );

                String value = OptionConverter.findAndSubst( key, props );
                ICache cache;
                synchronized ( regionName )
                {
                    cache = parseRegion( props, regionName, value );
                }
                compositeCacheManager.caches.put( regionName, cache );
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.