5 Replies Latest reply on Sep 17, 2007 9:01 AM by manik

    What is the relation between in-memory nodes and nodes in db

    sg283

      I have configured one of my cache region ( called fare) as below:-
      maxNodes = 4500
      timeToLiveSeconds = 2073600

      I have defined maxNodes in this region to be 4500.I am persisting cache in db using cache loader.
      In my application I am keeping data only on the leaf nodes.
      When I query my db for nodes with data, that number is very big than 4500. Currently, number of leaf nodes (with data) is 5672. This is the count only for leaf nodes. Actual number of nodes would be even more.
      As per my understanding, number of nodes in any region should not exceed the maxNodes. But I see different thing here.

      What is the relation between in-memory nodes and nodes in db? Does JBoss Cache maintains maxNodes in memory and if the number exceeds beyond this, it keeps all other nodes in db? So at a given point of time if there are 4500 nodes are there in memory, and the application tries to put 1000 more nodes in the same region, would these nodes be put in db. SO there would be 4500+1000 = 5500 nodes in db and only 4500 nodes in memory?

      Also I have a default cache region with 5000 maxNodes configured.
      May this happen, if in number of nodes in any of my cache region exceeds the maxNodes, any new node would be put in the _default_ region?

        • 1. Re: What is the relation between in-memory nodes and nodes i
          genman

           


          What is the relation between in-memory nodes and nodes in db? Does JBoss Cache maintains maxNodes in memory and if the number exceeds beyond this, it keeps all other nodes in db? So at a given point of time if there are 4500 nodes are there in memory, and the application tries to put 1000 more nodes in the same region, would these nodes be put in db. SO there would be 4500+1000 = 5500 nodes in db and only 4500 nodes in memory?


          The in-memory nodes are a subset of what's in the DB. Although, if you use activation/passivation then they are disjoint sets.

          The MaxNodes is for the in memory configuration.

          Yes to your last question.

          • 2. Re: What is the relation between in-memory nodes and nodes i
            sg283

            Please confirm if I understand this correctly:-
            1- Suppose I have defined maxNodes in region X to be 4500, and my application tries to put 1000 more nodes in region X then there would be 5500 nodes in total; 4500 in region X and 1000 nodes in region _default_. All 4500 nodes in region X would be evicted as per eviction defined in region X and all 1000 nodes in region _default_ would be evicted by the eviction time defined in region _default_.

            2- If I have tree cache nodes a,b, and c , a being the root node and c being the leaf node and b being the intemediate node, suppose for some reason, node a and c are in region X and node b is in region _default_.
            Eviction time in region X is 10 minutes and in _default_ is 5 minutes.
            If node b expires after 5 minutes, what would happen to node c? Would node c be lost?

            3- Is there any way to know which node in my cache is in which region at any givn point of time?

            • 3. Re: What is the relation between in-memory nodes and nodes i
              sg283

              Genman , Manik,

              Please reply.

              Thank you in advance.

              • 4. Re: What is the relation between in-memory nodes and nodes i
                genman

                Why don't you test and let me know. You hurt my head.

                • 5. Re: What is the relation between in-memory nodes and nodes i
                  manik

                   

                  "sg283" wrote:
                  Please confirm if I understand this correctly:-
                  1- Suppose I have defined maxNodes in region X to be 4500, and my application tries to put 1000 more nodes in region X then there would be 5500 nodes in total; 4500 in region X and 1000 nodes in region _default_. All 4500 nodes in region X would be evicted as per eviction defined in region X and all 1000 nodes in region _default_ would be evicted by the eviction time defined in region _default_.


                  This is wrong.

                  A region is just a subtree. So if you have a region defined as /a/b/c, anything you put under /a/b/c is counted towards the number of nodes in the region (e.g., /a/b/c/d or /a/b/c/e or even /a/b/c/d/e/f/g).

                  If you have > MaxNodes nodes in the region, they will still exist in the DB, just not in memory.

                  Your ideas around eviction are all wrong as well. Only nodes exceeding MaxNodes are evicted.

                  "sg283" wrote:

                  2- If I have tree cache nodes a,b, and c , a being the root node and c being the leaf node and b being the intemediate node, suppose for some reason, node a and c are in region X and node b is in region _default_.
                  Eviction time in region X is 10 minutes and in _default_ is 5 minutes.
                  If node b expires after 5 minutes, what would happen to node c? Would node c be lost?


                  No - eviction only REMOVES a node if it doesn't have any children. If a node has children it just empties all the data in the node, marks it as uninitialized, but keeps the node as it has a structural role to play.