14 Replies Latest reply on Aug 10, 2005 6:43 AM by nithinnambiar

    Standalone TreeCache with Configured LRU policy???

    cork

      Hi,

      I'm trying to get TreeCache running standalone, but I'm having problems working out how to configure the eviction policy LRUPolicy. I'm using the following to create the cache...

      cache = new TreeCache();
      cache.setEvictionPolicyClass("org.jboss.cache.eviction.LRUPolicy");
      //would like to configure LRU here...
      cache.createService();
      cache.startService();

      It seems like this policy can only be configured from the MBeans xml?? I'm running outside of JBoss so not sure what I should do...

      Any help appreciated,

      Peter

      PS I can't find documentation on anon cvs checkout of the source code.

        • 1. Re: Standalone TreeCache with Configured LRU policy???

          There is no good way to configure eviction policy programmtically since by design it is supposed to be pluggable.

          So from the start, we can only setEvictionPolicyConfig as an opaque Element and inject it to the specific policy for it to parse.

          In addition, the injection has to be done during cache start up time.

          -Ben

          • 2. Re: Standalone TreeCache with Configured LRU policy???
            cork

            Okay then is there some documentation how to configure this for standalone use. ie what xml I need and where to put it etc. Maybe an example would be good.

            Many Thanks

            Peter

            • 3. Re: Standalone TreeCache with Configured LRU policy???
              cork

              Also is the LRU limited to 20,000 items or is this also configurable?

              Cheers

              Peter

              • 4. Re: Standalone TreeCache with Configured LRU policy???

                No, but it buffer size is fixed so you will need to tune your time to live and also the eviction thread frequency (wakeUpIntervals).

                -Ben

                • 5. Re: Standalone TreeCache with Configured LRU policy???
                  cork

                  Hi Ben,

                  I'm still struggling with this, can you tell me how to get a copy of the source so that I can see whats going on.

                  Some documentation on how to configure this standalone would also be appreciated.

                  Cheers

                  Peter

                  • 6. Re: Standalone TreeCache with Configured LRU policy???

                    http://www.jboss.org/wiki/Wiki.jsp?page=CVSRepository

                    to check out the source. THere if no documentation on how to configure your own eviction policy progrmatically.

                    Would you like contribute one if you get it to work. :-)

                    -Ben

                    • 7. Re: Standalone TreeCache with Configured LRU policy???
                      cork

                      I thought I read somewhere that the source for JBossCache was now on a seperate cvs branch someplace else?

                      I don't mind to configure it from xml for now, but I can't find documentation to do that either... only for the mbean/jboss environment.

                      Maybe when I have the source and got it working I will put together a little HowTo for you :)

                      Cheers

                      Peter

                      • 8. Re: Standalone TreeCache with Configured LRU policy???
                        cork

                        I got it configured at last :) I just hadn't realised it was using the same xml file as for an MBean environment. So I was just missing the loading of the configuration.

                        cache = new TreeCache();
                        PropertyConfigurator config = new PropertyConfigurator();
                        config.configure(cache, "cacheconfig.xml");
                        cache.start();

                        One thing I did notice was that the performance is nearly twice as slow for the gets now compared to having no configuration loaded, any ideas?

                        Cheers

                        Peter

                        • 9. Re: Standalone TreeCache with Configured LRU policy???
                          dnielben

                          Maybe the configuration is using now a cacheLoader, so is persiting the changes made in the cache. You can review if your conf file has something like.

                          <attribute name="CacheLoaderClass">org.jboss.cache.loader.FileCacheLoader</attribute>
                           <attribute name="CacheLoaderConfig">
                           location=c:\\tmp
                           </attribute>
                           <attribute name="CacheLoaderShared">true</attribute>
                           <attribute name="CacheLoaderPreload">/</attribute>


                          And if you have it, comment it to deactivate cacheloader.

                          Regards

                          • 10. Re: Standalone TreeCache with Configured LRU policy???
                            cork

                            I'm adding 100,000 items to the cache (single node). Then I do 100,000 random reads. Without the config it takes around 774ms with this config 1273ms. The same test using a LinkedHashMap only takes 182ms (with synchronization).

                            This is the config I'm using:

                            <?xml version="1.0" encoding="UTF-8"?>
                            <server>
                             <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
                             <mbean code="org.jboss.cache.TreeCache"
                             name="jboss.cache:service=TreeCache">
                             <depends>jboss:service=Naming</depends>
                             <depends>jboss:service=TransactionManager</depends>
                             <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
                             <attribute name="CacheMode">LOCAL</attribute>
                             <attribute name="MaxCapacity">200000</attribute>
                             <attribute name="InitialStateRetrievalTimeout">2000000</attribute>
                             <attribute name="SyncReplTimeout">10000</attribute>
                             <attribute name="LockAcquisitionTimeout">15000</attribute>
                             <attribute name="LockLeaseTimeout">60000</attribute>
                             <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
                             <attribute name="EvictionPolicyConfig">
                             <config>
                             <attribute name="wakeUpIntervalSeconds">1</attribute>
                             <region name="/_default_">
                             <attribute name="maxNodes">200000</attribute>
                             <attribute name="timeToIdleSeconds">0</attribute>
                             </region>
                             </config>
                             </attribute>
                             </mbean>
                            </server>


                            • 11. Re: Standalone TreeCache with Configured LRU policy???
                              belaban

                              Do you have the test available ? I suggest create a JIRA (jira.jboss.com) issue and attach the test to it.
                              Locking comes with a cost, if you used IsolationLevel=NONE you'd probably get better numbers.

                              • 12. Re: Standalone TreeCache with Configured LRU policy???
                                cork

                                He Bela,

                                I created an issue and attached a small test. JBCACHE-172
                                Hope it's just something silly I'm doing :)

                                btw, IsolationLevel=NONE made no difference

                                Cheers,

                                Peter

                                • 13. Re: Standalone TreeCache with Configured LRU policy???
                                  belaban

                                  I'll look at this in the 1.3 time frame.

                                  • 14. Re: Standalone TreeCache with Configured LRU policy???
                                    nithinnambiar

                                    Hi Cork,

                                    Could you please send us detailed information on how to setup TreeCache as Standalone application?

                                    We need the xml file information and where should we put the xml file when we start the TreeCache as Standalone application.

                                    Also, give me your email ID.

                                    Advance Thanks,
                                    Nitin