5 Replies Latest reply on May 7, 2008 9:58 AM by sancheski

    Create an eviction Region with a non empty nodeEventQueue_

    sancheski

      Hi all,

      I wonder if I can create an eviction Region with a non empty nodeEventQueue_ using JbossCache-1.4.1-Sp8. As I see in the source code, any time you create an eviction Region, you create an empty queue associated to it.

      This situation deals to a non stable eviction policy configuration in cases when you add an eviction policy dinamically in a fqn that already has nodes created inside.

      Let's get into the situation:

      I got

      /NODE
       /SUBNODE
       /SUBNODE_A
       /SUBNODE_B
      


      If I create an eviction policy to fqn = /NODE/SUBNODE, neither SUBNODE_A nor SUBNODE_B will be evicted ever. Only nodes created after the eviction policy has been configured will be evicted.

      Is there any possibility do add these nodes to the eviction queue?

      Thanks in advandce!

      Sancheski

        • 1. Re: Create an eviction Region with a non empty nodeEventQueu
          mircea.markus

          At the moment that is just not supported. Not sure we even want to support that as it might create unnecessary complications, but rather not allow creating the eviction region if the given region is not empty - I'll raise another question on the design forums on that.

          The only way I see you can solve this is to create a new empty region and move the nodes from the existing one, so that events are being created and nodes are being considered for eviction.

          • 2. Re: Create an eviction Region with a non empty nodeEventQueu
            mircea.markus
            • 3. Re: Create an eviction Region with a non empty nodeEventQueu
              sancheski

               


              The only way I see you can solve this is to create a new empty region and move the nodes from the existing one, so that events are being created and nodes are being considered for eviction.


              I thought about that solution too but this would made the nodes to lose their state. They would not keep their primitive state, are they?

              Thanks a lot!

              • 4. Re: Create an eviction Region with a non empty nodeEventQueu
                manik

                I'm confused - how are you creating the eviction region? Isn't this in the XML config file (or Configuration object), which means the region will be created when the cache starts up?

                • 5. Re: Create an eviction Region with a non empty nodeEventQueu
                  sancheski

                  I have a requirement in my application that forces me to create eviction policies to regions once the whole system is running (that is, the cache has already started and is runnning properly).
                  What I am triying to do is to configure an eviction policy programatically. Here is how I am doing it:

                  public final void addEvictionPolicy(EvictionPolicy evictionPolicy, EvictionConfiguration evictionConfig, String fqn)
                   {
                   // Activate eviction Policies
                   RegionManager regionMgr = getUnderlyingTreeCache().getEvictionRegionManager();
                   if (regionMgr.hasRegion(fqn)) {
                   Region region = regionMgr.getRegion(fqn);
                   region.setEvictionConfiguration(evictionConfig);
                   logger.debug("Region[{}] configured with {}", fqn, evictionPolicy);
                   } else {
                   evictionPolicy.configure(getUnderlyingTreeCache());
                   try {
                   regionMgr.createRegion(fqn, evictionPolicy, evictionConfig);
                   } catch (RegionNameConflictException e) {
                   logger.error("Region Name conflict", e);
                   }
                   logger.debug(
                   "Region[{}] does not exist in RegionManager. Created and configured with {}",
                   fqn, evictionPolicy);
                   }
                   }


                  I do not know if there is a better way to create an eviction policy dinamically. Does any one know how to do it properly?

                  Thanks!