You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by as...@apache.org on 2002/02/21 07:42:53 UTC

cvs commit: jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control CompositeCacheManager.java CompositeCacheConfigurator.java

asmuts      02/02/20 22:42:53

  Modified:    src/java/org/apache/stratum/jcs/access TestCacheAccess.java
               src/java/org/apache/stratum/jcs/engine/control
                        CompositeCacheManager.java
                        CompositeCacheConfigurator.java
  Log:
  you can now set the element attributes in the cache.ccf file for each region, or establish defaults.  This will save a lot of code.
  
  Need to revisit the copy method.
  
  Revision  Changes    Path
  1.15      +23 -16    jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/access/TestCacheAccess.java
  
  Index: TestCacheAccess.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/access/TestCacheAccess.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TestCacheAccess.java	19 Feb 2002 04:46:54 -0000	1.14
  +++ TestCacheAccess.java	21 Feb 2002 06:42:53 -0000	1.15
  @@ -455,13 +455,13 @@
                           }
                           else
                           {
  -                            IElementAttributes attrp = new ElementAttributes();
  -                            attrp.setIsLateral(true);
  -                            attrp.setIsRemote(true);
  +//                            IElementAttributes attrp = new ElementAttributes();
  +//                            attrp.setIsLateral(true);
  +//                            attrp.setIsRemote(true);
                               long n_start = System.currentTimeMillis();
                               cache_control.putInGroup( key,
                                   group,
  -                                "data from putg ----asdfasfas-asfasfas-asfas in group " + group, attrp.copy() );
  +                                "data from putg ----asdfasfas-asfasfas-asfas in group " + group );
                               long n_end = System.currentTimeMillis();
                               p( "---put " + key + " in group " + group + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
                           }
  @@ -496,15 +496,15 @@
                           }
                           else
                           {
  -                            IElementAttributes attrp = new ElementAttributes();
  -                            attrp.setIsLateral(true);
  -                            attrp.setIsRemote(true);
  +//                            IElementAttributes attrp = new ElementAttributes();
  +//                            attrp.setIsLateral(true);
  +//                            attrp.setIsRemote(true);
                               long n_start = System.currentTimeMillis();
                               for ( int a = 0; a < num; a++ )
                               {
                                   cache_control.putInGroup( "keygr" + a,
                                       group,
  -                                    "data " + a + " from putag ----asdfasfas-asfasfas-asfas in group " + group, attrp.copy() );
  +                                    "data " + a + " from putag ----asdfasfas-asfasfas-asfas in group " + group );
                               }
                               long n_end = System.currentTimeMillis();
                               p( "---put " + num + " in group " + group + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
  @@ -521,17 +521,17 @@
                           }
                           else
                           {
  -                            IElementAttributes attrp = new ElementAttributes();
  +//                            IElementAttributes attrp = new ElementAttributes();
                               //attrp.setIsEternal(false);
                               //attrp.setMaxLifeSeconds(30);
   
  -                            attrp.setIsLateral(true);
  -                            attrp.setIsRemote(true);
  +//                            attrp.setIsLateral(true);
  +//                            attrp.setIsRemote(true);
                               long n_start = System.currentTimeMillis();
                               for ( int n = 0; n < num; n++ )
                               {
                                   cache_control.put( "key" + n,
  -                                    "data" + n + " put from ta = junk", attrp.copy() );
  +                                    "data" + n + " put from ta = junk" );
                               }
                               long n_end = System.currentTimeMillis();
                               p( "---put " + num + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
  @@ -566,11 +566,12 @@
                           }
                           else
                           {
  -                            IElementAttributes attrp = new ElementAttributes();
  -                            attrp.setIsLateral(true);
  -                            attrp.setIsRemote(true);
  +//                            IElementAttributes attrp = new ElementAttributes();
  +//                            attrp.setIsLateral(true);
  +//                            attrp.setIsRemote(true);
                               long n_start = System.currentTimeMillis();
  -                            cache_control.put( key, val, attrp.copy() );
  +//                            cache_control.put( key, val, attrp.copy() );
  +                            cache_control.put( key, val );
                               long n_end = System.currentTimeMillis();
                               p( "---put " + key + " | " + val + " in " + String.valueOf( n_end - n_start ) + " millis ---" );
                           }
  @@ -581,6 +582,12 @@
                           String key = message.substring( message.indexOf( " " ) + 1, message.length() );
                           cache_control.remove( key );
                           p( "removed " + key );
  +                    }
  +                    else
  +                        if ( message.startsWith( "deattr" ) )
  +                    {
  +                        IElementAttributes ae = cache_control.getElementAttributes( );
  +                        p( "Default IElementAttributes " + ae );
                       }
                       else
                           if ( message.startsWith( "cloneattr" ) )
  
  
  
  1.9       +22 -0     jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/CompositeCacheManager.java
  
  Index: CompositeCacheManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/CompositeCacheManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CompositeCacheManager.java	18 Feb 2002 17:14:25 -0000	1.8
  +++ CompositeCacheManager.java	21 Feb 2002 06:42:53 -0000	1.9
  @@ -156,6 +156,28 @@
           this.defaultCacheAttr = icca;
       }
   
  +    /**
  +     * Sets the defaultElementAttributes attribute of the CompositeCacheManager
  +     * object
  +     *
  +     * @param icca The new defaultElementAttributes value
  +     */
  +    public void setDefaultElementAttributes( IElementAttributes iea )
  +    {
  +        this.defaultElementAttr = iea;
  +    }
  +
  +    /**
  +     * Gets the defaultElementAttributes attribute of the CompositeCacheManager
  +     * object
  +     *
  +     * @return The defaultElementAttributes value
  +     */
  +    public IElementAttributes getDefaultElementAttributes()
  +    {
  +        return this.defaultElementAttr.copy();
  +    }
  +
       /** */
       private void createCaches( Properties props )
           throws IOException, NotBoundException
  
  
  
  1.7       +57 -3     jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/CompositeCacheConfigurator.java
  
  Index: CompositeCacheConfigurator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/CompositeCacheConfigurator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CompositeCacheConfigurator.java	18 Feb 2002 17:14:25 -0000	1.6
  +++ CompositeCacheConfigurator.java	21 Feb 2002 06:42:53 -0000	1.7
  @@ -86,8 +86,10 @@
           ccMgr.props = properties;
           // set default value list
           setDefaultAuxValues( properties );
  -        // set default attr
  +        // set default cache attr
           setDefaultCompositeCacheAttributes( properties );
  +        // set default element attr
  +        setDefaultElementAttributes( properties );
   
           // set up ssytem caches to be used by non system caches
           // need to make sure there is no circuarity of reference
  @@ -117,6 +119,16 @@
           log.info( "setting defaultCompositeCacheAttributes to " + icca );
       }
   
  +    /** Set the default ElementAttributes for new caches. */
  +    protected void setDefaultElementAttributes( Properties props )
  +    {
  +        IElementAttributes iea =
  +            parseElementAttributes( props, "", this.DEFAULT_REGION );
  +        ccMgr.setDefaultElementAttributes( iea );
  +
  +        log.info( "setting defaultElementAttributes to " + iea );
  +    }
  +
       /**
        * Create caches used internally. System status gives them creation
        * priority.
  @@ -235,14 +247,19 @@
               cca = parseCompositeCacheAttributes( props, regName, regionPrefix );
           }
   
  +        IElementAttributes ea = parseElementAttributes( props, regName, regionPrefix );
  +
  +
           ICache cache = null;
           if ( regionPrefix.equals( SYSTEM_REGION_PREFIX ) )
           {
  -            cache = ccMgr.createSystemCache( regName, auxCaches, cca, new ElementAttributes() );
  +            //cache = ccMgr.createSystemCache( regName, auxCaches, cca, new ElementAttributes() );
  +            cache = ccMgr.createSystemCache( regName, auxCaches, cca, ea );
           }
           else
           {
  -            cache = ccMgr.createCache( regName, auxCaches, cca, new ElementAttributes() );
  +            //cache = ccMgr.createCache( regName, auxCaches, cca, new ElementAttributes() );
  +            cache = ccMgr.createCache( regName, auxCaches, cca, ea );
           }
           return cache;
       }
  @@ -290,6 +307,43 @@
           ccAttr.setCacheName( regName );
           return ccAttr;
       }
  +
  +    /** */
  +    protected IElementAttributes
  +        parseElementAttributes( Properties props,
  +                                       String regName,
  +                                       String regionPrefix )
  +    {
  +        IElementAttributes eAttr;
  +
  +        String attrName = regionPrefix + regName + this.ELEMENT_ATTRIBUTE_PREFIX;
  +
  +        // auxFactory was not previously initialized.
  +        //String prefix = regionPrefix + regName + ATTRIBUTE_PREFIX;
  +        eAttr = ( IElementAttributes ) OptionConverter.instantiateByKey( props, attrName,
  +            org.apache.stratum.jcs.engine.behavior.IElementAttributes.class,
  +            null );
  +        if ( eAttr == null )
  +        {
  +            log.warn( "Could not instantiate eAttr named '" + attrName +
  +                "', using defaults." );
  +
  +            IElementAttributes eAttr2 = ccMgr.getDefaultElementAttributes();
  +            eAttr = eAttr2.copy();
  +        }
  +
  +        log.debug( "Parsing options for '" + attrName + "'" );
  +
  +        PropertySetter.setProperties( eAttr, props, attrName + "." );
  +        //eAttr.setCacheName( regName );
  +
  +        log.debug( "End of parsing for \"" + attrName + "\"." );
  +
  +        // GET CACHE FROM FACTORY WITH ATTRIBUTES
  +        //eAttr.setCacheName( regName );
  +        return eAttr;
  +    }
  +
   
       /** Get an aux cache for the listed aux for a region. */
       protected ICache parseAuxiliary( Properties props,
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>