5 Replies Latest reply on Apr 7, 2009 6:33 AM by jorgemoralespou_2

    Request for Guide for creating new eviction policies

    jorgemoralespou_2

      Hi, I want to know if it is somehow documented what are the necessary steps for creating a new eviction policy? Something like:
      1- Create your own EvictionActionPolicy
      2- Create your own EvictionAlgorithm
      3- Create your own EvictionQueue if needed
      ...

      And then, how to package all, to make it configurable, through normal xml configuration.

        • 1. Re: Request for Guide for creating new eviction policies
          manik

          You're best off looking at the src code of one of the existing policies...

          • 2. Re: Request for Guide for creating new eviction policies
            jorgemoralespou_2

            Then If I suceed in creating my eviction policy, I´ll try to post this guide and what I have done.

            • 3. Re: Request for Guide for creating new eviction policies
              manik

              Yep, start a wiki page. Good man. :-)

              Feel free to post comments here as well if you need more help/need questions answered.

              • 4. Re: Request for Guide for creating new eviction policies
                jorgemoralespou_2

                Hi,
                I'm trying hard to create my new eviction policy, but I think my requirements are very difficult for first eviction policy.

                I have seen that EvictionQueue interface seems to poor for my use case. I have extended some methods to receive a Fqn. Also, I have made a custom EvictionAlgorithm reimplementing some logic in BaseEvictionAlgorithm. But I'm still facing some issues. I'll keep working on this, and posting questions if I have them. If I finally get this working, I'll try to make the guide.

                • 5. Re: Request for Guide for creating new eviction policies
                  jorgemoralespou_2

                  So far, for my requisites, I have to modify only one of JBoss Core classes, to make it possible to work. In some cases, it should be advisable to modify some other classes with instanceof statements, not required in my cases.

                  I have made a new interface, extending EvictionQueue, named SubcontextEvitionQueue with this code:

                  public interface SubcontextEvictionQueue extends EvictionQueue {
                   NodeEntry getFirstNodeEntry(Fqn fqn);
                   void modifyElementCount(Fqn fqn, int difference);
                   int getNumberOfNodes(Fqn fqn);
                   int getNumberOfElements(Fqn fqn);
                  }
                  


                  And modified:
                   public void NodeEntry.setNumberOfElements(int numberOfElements)
                   {
                   if (queue != null)
                   {
                   int difference = numberOfElements - this.numberOfElements;
                   if (queue instanceof SubcontextEvictionQueue){
                   queue.modifyElementCount(difference);
                   }else{
                   queue.modifyElementCount(fqn, difference);
                   }
                   }
                   this.numberOfElements = numberOfElements;
                   }
                  


                  This make it possible to create an EvictionAlgorithm/EvictionQueue assigned to a region, that handles number of items in subnodes, without the need for creating a region infraestructure.