8 Replies Latest reply on Nov 12, 2004 9:02 AM by kkalmbach

    Questions about functionality

    kkalmbach Newbie

      We are looking into deploying a caching solution into a jboss server, so jbossCache is an obvious candidate. It looks like it does 90%+ of what we want. I have a few questions about the remaining functionality

      1) We would like to assign a timeToIdleSeconds when we put something in the cache (programatically, not a global from the .xml). Is this possible? Can I get the RegionManager after I insert the new entry into the cache and add a new region that only affects my new entry?

      2) Can JbossCache keep statistics? In order to properly set the idleTimeToLive/maxEntries etc.. We want to look at how many times a paticular node was successfully retrieved from the cache, as well as how many times an entry was attempted to be retireved and it had already been evicted (or was never there)

      If this functionality does not already exist, are there hooks where I could write my own implementations (and of course submit the changes back).

      -Thanks
      -Kevin

        • 1. Re: Questions about functionality
          Jimmy Wilson Apprentice

           

          If this functionality does not already exist, are there hooks where I could write my own implementations (and of course submit the changes back).


          I am sure that Ben and Bela can answer your questions more directly than I can, but I had some of the same requirements just from a testing point of view. Though JBossCache comes with a graphical viewer of the cache encapsulated by the TreeCacheView class, it did not always work correctly for me, so I implemented the TreeCacheListener interface to print out when cache access (there are a variety of different methods) occurred to verify that my code was working as expected.

          • 2. Re: Questions about functionality
            Ben Wang Master

            To asnwer your questions, both items are on our roadmap. First one is to make the region configurable dynamically through api, and the second one is to intrument JBossCache so we can know, for example, the cache hit/miss ratio.

            Unfortunately, I can't think of an exisiting way to solve your first problem yet.

            -Ben

            • 3. Re: Questions about functionality
              Bela Ban Master

               

              "kkalmbach" wrote:

              2) Can JbossCache keep statistics? In order to properly set the idleTimeToLive/maxEntries etc.. We want to look at how many times a paticular node was successfully retrieved from the cache, as well as how many times an entry was attempted to be retireved and it had already been evicted (or was never there)

              If this functionality does not already exist, are there hooks where I could write my own implementations (and of course submit the changes back).



              Not in 1.1. I'm working on refactoring right now, all aspects such as replication, locking, cache loading etc are converted to aspects (a.k.a interceptors). This is only in the CVS (head) as of now, but will be part of 1.2 (timeframe for release: end of November)

              To do stats, you'd write an interceptor, then get the interceptor chain (List cache.getInterceptors()), and insert your interceptor dynamically at the place where you want to insert it.
              The interceptor chain is currently assembled according to the cache attributes set, but I plan to expose it later via XML as well (for advanced users).

              So if you are impatient, you can check out the CVS head code and take a look. The invoke() method gives you access to method name, arguments etc. Note though that the MethodCall argument will be replaced by Invocation in the 2.x timeframe.

              Regards,

              Bela

              • 4. Re: Questions about functionality
                kkalmbach Newbie

                To get the timeout like I would like, would it be possible in LRUAlgorithm in the prune method to factor out the call the region.getIdleTimeout. That is, put it in a method called getTimeout passing in the region and the nodeEntry, the default implementation just returns the region.getIdleTimeout, but I could then override this new method and look at the nodeEntry to get the specific node's timeout.

                I can include a diff if this does not make sense.

                Thanks again for your help

                • 5. Re: Questions about functionality
                  Ben Wang Master

                  Ok, let me look into it and get back to you later this week.

                  -Ben

                  • 6. Re: Questions about functionality
                    kkalmbach Newbie

                    one more idea about how to do this.
                    1) in the xml file make several timeout policies
                    i.e. 5m expires in 5 mintes, 10m expires in 10m etc
                    2) When someone request to put something in the cache, prepend the approriate the timeout value onto the node.

                    The ideal in this case would be to query the regionMangager to find the appropriate value to prepend on the node. So if someone passed in a 7 minute timeout, I could find that the 10m node is the next value above the desired threshold.

                    This would mean a way to get the regionManager from the TreeCache, which I do not think I can do right now, but I could extend TreeCache and LRUPoliocy to get add a couple of get Methods.

                    Is this a better idea? Is it possible? It does mess up our node stragity a little bit (cleanup/queries for a specific node would have to look through several top level nodes), but it might be our best option.

                    • 7. Re: Questions about functionality
                      Ben Wang Master

                      OK, I can refactor the region_.getTimeToIdleSeconds() into a public method. Will that do what you want then?

                      -ben

                      • 8. Re: Questions about functionality
                        kkalmbach Newbie

                        I think that would work great. Thanks for all your help on this.

                        -Kevin