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

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


                    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 == ICache.STATUS_ALIVE ? "ALIVE"
                     : status == ICache.STATUS_DISPOSED ? "DISPOSED"
                     : status == ICache.STATUS_ERROR ? "ERROR"
                     : "UNKNOWN" );
                out.print( "</td>" );
View Full Code Here


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

     * defaults if none are specified. We might want to create separate method
     * for creating/getting. . .
     */
    public ICache getCache( ICompositeCacheAttributes cattr, IElementAttributes attr )
    {
        ICache cache = ( ICache ) caches.get( cattr.getCacheName() );

        if ( cache == null )
        {
            synchronized ( caches )
            {
View Full Code Here

        Enumeration allCaches = caches.elements();

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

            if ( cache != null )
            {
                stats.append( "Cache stats: " ).append( cache.getStats() )
                    .append( " clients = " ).append( clients );
            }
        }

        return stats.toString();
View Full Code Here

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

     *
     * @return The cache value
     */
    public ICache getCache( IJISPCacheAttributes cattr )
    {
        ICache raf = null;

        log.debug( "cacheName = " + cattr.getCacheName() );

        synchronized ( caches )
        {
View Full Code Here

        StringBuffer stats = new StringBuffer();
        Enumeration allCaches = caches.elements();

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

            if ( raf != null )
            {
                stats.append( raf.getStats() );
                stats.append( ", " );
            }
        }

        return stats.toString();
View Full Code Here

     *
     * @return The cache value
     */
    public ICache getCache( IHSQLCacheAttributes cattr )
    {
        ICache raf = null;

        log.debug( "cacheName = " + cattr.getCacheName() );

        synchronized ( caches )
        {
View Full Code Here

        StringBuffer stats = new StringBuffer();
        Enumeration allCaches = caches.elements();

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

            if ( raf != null )
            {
                stats.append( raf.getStats() );
                stats.append( ", " );
            }
        }

        return stats.toString();
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.