Package org.apache.jcs.engine.behavior

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


        {
            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


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

                        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() == 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;
                                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() == CacheConstants.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

                primayDefined = true;

                failovers.add( rca.getRemoteHost() + ":" + rca.getRemotePort() );

                RemoteCacheManager rcm = RemoteCacheManager.getInstance( rca );
                ICache ic = rcm.getCache( rca );
                if ( ic != null )
                {
                    noWaits.add( ic );
                }
                else
                {
                    //p( "noWait is null" );
                }
            }

            // GET HANDLE BUT DONT REGISTER A LISTENER FOR FAILOVERS
            String failoverList = rca.getFailoverServers();
            if ( failoverList != null )
            {
                StringTokenizer fit = new StringTokenizer( failoverList, "," );
                int fCnt = 0;
                while ( fit.hasMoreElements() )
                {
                    fCnt++;

                    String server = ( String ) fit.nextElement();
                    failovers.add( server );

                    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
                    if ( ( !primayDefined && fCnt == 1 ) || noWaits.size() <= 0 )
                    {
                        ICache ic = rcm.getCache( rca );
                        if ( ic != null )
                        {
                            noWaits.add( ic );
                        }
                        else
                        {
                            //p( "noWait is null" );
                        }
                    }
                }
                // end while
            }
            // end if failoverList != null

            rca.setFailovers( ( String[] ) failovers.toArray( new String[0] ) );

            // if CLUSTER
        }
        else
            if ( rca.getRemoteType() == rca.CLUSTER )
        {

            // REGISTER LISTENERS FOR EACH SYSTEM CLUSTERED CACHEs
            StringTokenizer it = new StringTokenizer( rca.getClusterServers(), "," );
            while ( it.hasMoreElements() )
            {
                //String server = (String)it.next();
                String server = ( String ) it.nextElement();
                //p( "tcp server = " +  server );
                rca.setRemoteHost( server.substring( 0, server.indexOf( ":" ) ) );
                rca.setRemotePort( Integer.parseInt( server.substring( server.indexOf( ":" ) + 1 ) ) );
                RemoteCacheManager rcm = RemoteCacheManager.getInstance( rca );
                rca.setRemoteType( rca.CLUSTER );
                ICache ic = rcm.getCache( rca );
                if ( ic != null )
                {
                    noWaits.add( ic );
                }
                else
View Full Code Here

                primayDefined = true;

                failovers.add( rca.getRemoteHost() + ":" + rca.getRemotePort() );

                RemoteCacheManager rcm = RemoteCacheManager.getInstance( rca, cacheMgr );
                ICache ic = rcm.getCache( rca );
                if ( ic != null )
                {
                    noWaits.add( ic );
                }
                else
                {
                    log.info( "noWait is null" );
                }
            }

            // GET HANDLE BUT DONT REGISTER A LISTENER FOR FAILOVERS
            String failoverList = rca.getFailoverServers();
            if ( failoverList != null )
            {
                StringTokenizer fit = new StringTokenizer( failoverList, "," );
                int fCnt = 0;
                while ( fit.hasMoreElements() )
                {
                    fCnt++;

                    String server = (String) fit.nextElement();
                    failovers.add( server );

                    rca.setRemoteHost( server.substring( 0, server.indexOf( ":" ) ) );
                    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
                    if ( ( !primayDefined && fCnt == 1 ) || noWaits.size() <= 0 )
                    {
                        ICache ic = rcm.getCache( rca );
                        if ( ic != null )
                        {
                            noWaits.add( ic );
                        }
                        else
                        {
                            log.info( "noWait is null" );
                        }
                    }
                }
                // end while
            }
            // end if failoverList != null

            rca.setFailovers( (String[]) failovers.toArray( new String[0] ) );

            // if CLUSTER
        }
        else if ( rca.getRemoteType() == RemoteCacheAttributes.CLUSTER )
        {
            // REGISTER LISTENERS FOR EACH SYSTEM CLUSTERED CACHEs
            StringTokenizer it = new StringTokenizer( rca.getClusterServers(), "," );
            while ( it.hasMoreElements() )
            {
                // String server = (String)it.next();
                String server = (String) it.nextElement();
                // p( "tcp server = " + server );
                rca.setRemoteHost( server.substring( 0, server.indexOf( ":" ) ) );
                rca.setRemotePort( Integer.parseInt( server.substring( server.indexOf( ":" ) + 1 ) ) );
                RemoteCacheManager rcm = RemoteCacheManager.getInstance( rca, cacheMgr );
                rca.setRemoteType( RemoteCacheAttributes.CLUSTER );
                ICache ic = rcm.getCache( rca );
                if ( ic != null )
                {
                    noWaits.add( ic );
                }
                else
View Full Code Here

                    log.debug( "tcp server = " + server );
                }
                ITCPLateralCacheAttributes lacC = (ITCPLateralCacheAttributes) lac.copy();
                lacC.setTcpServer( server );
                LateralTCPCacheManager lcm = LateralTCPCacheManager.getInstance( lacC, cacheMgr );
                ICache ic = lcm.getCache( lacC.getCacheName() );
                if ( ic != null )
                {
                    noWaits.add( ic );
                }
                else
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

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.