4 Replies Latest reply on Aug 7, 2015 4:51 AM by Sébastien Berthezene

    shareable nodes with Modeshape

    Sébastien Berthezene Newbie

      Hi,

       

      i am new to JCR and Modeshape. I need to manage nodes with multiple parents. From what i have understood with JCR 2.0, there are 2 solutions : using references or shared nodes. I tried references and it is working fine and fast, i can get all parent using single API call or SQL. My problem is that solution using references only works with direct reference but cannot manage ancestors. I cannot have referenced nodes if i only have my ancestors of final parent.

      Then i would like to use shareable nodes but i have questions :

      - is it correctly implemented in Modeshape or is it a minimal implementation ?

      - what is the performance impact of such solution ? Is there any side effects ?

      - if i use permissions based on path, is it correctly managed ?

      - when nodes are shared, are they duplicated or is it only working with references ? For example if i have many properties on my shared node, are they duplicated and use more space ?

       

      Do you think about other alternative way to manage multiple parent ? I only started to work with Modeshape since one week but for now i am very happy with this JCR engine, in memory cache is very fast and it seems to be more consistent than Jackrabbit..

       

      Regards

        • 1. Re: shareable nodes with Modeshape
          Horia Chiorean Master

          - is it correctly implemented in Modeshape or is it a minimal implementation ?

          not sure what you mean by "minimal implementation". ModeShape supports shared nodes as defined by the JSR 283 spec. However, since using shareable nodes is more complicated than using regular nodes, I don't think people in the community are using this extensively so there may be bugs lurking around.

          - what is the performance impact of such solution ? Is there any side effects ?

          using shareable nodes requires additional checks and constraints plus a slightly bigger node footprint because it stores multiple parents. So in theory the performance should not be as good as when you're using regular nodes. That being said, depending on your use case, it may not be a noticeable performance degradation. It's something you should try and compare based on your context.

          - if i use permissions based on path, is it correctly managed ?

          depends on what you mean by "correctly managed". What part of the spec are you concerned about ?

          - when nodes are shared, are they duplicated or is it only working with references ? For example if i have many properties on my shared node, are they duplicated and use more space ?

          when you create a shared node via workspace.clone, ModeShape essentially links the same node with a different name under the new parent. In other words, in simply refers the original node, it doesn't duplicate its content.

           

          Do you think about other alternative way to manage multiple parent ?

          IMO it depends on how you view/interpret the parent-child relationship: if it's something that has only semantical meaning to your context, then you can probably implement a generic "parent-child" relationship via your node types using stuff like references, or storing identifier properties. Using this approach you can essentially create any type of "connection" between nodes (you can, for example, create bi-directional relationships by using ModeShape's simple references and storing those properties both on the parent and the child nodes. See [MODE-1969] Add support for unidirectional references based on identifiers - JBoss Issue Tracker)

           

          If, on the other hand, you want to be able to have multiple paths (in the JCR sense) for the same node(s), then shareable nodes is the way to go. In this case you need to be aware of the different constraints involved in using shareable nodes (see Chapter 14 of the JSR 283 spec).

          1 of 1 people found this helpful
          • 2. Re: shareable nodes with Modeshape
            Sébastien Berthezene Newbie

            Thanks for your answer.

             

            ModeShape supports shared nodes as defined by the JSR 283 spec. However, since using shareable nodes is more complicated than using regular nodes, I don't think people in the community are using this extensively so there may be bugs lurking around.

             

            I understand ModeShape supports JSR 283 but as you describe some features are more complicated than others and sometimes they are very poorly implemented only to say that JSR is completely supported. I only wanted to know if we already have some feedbacks regarding these feature but from what you said it seems that it is not often used.

             

            using shareable nodes requires additional checks and constraints plus a slightly bigger node footprint because it stores multiple parents. So in theory the performance should not be as good as when you're using regular nodes. That being said, depending on your use case, it may not be a noticeable performance degradation. It's something you should try and compare based on your context.

             

            It is what i suspected but i can deal with performance degradation on write. I will verify impact for read.

             

            depends on what you mean by "correctly managed". What part of the spec are you concerned about ?

            Just wondering what is the impact on ACL computation result because in that case you have more than one ACL applied on your node (one for each path). I suppose the result is a merge of all ACL and we keep only higher permissions. I will verify.

             

            when you create a shared node via workspace.clone, ModeShape essentially  links the same node with a different name under the new parent. In other words, in simply refers the original node, it doesn't duplicate its  content.

            Great !

             

            IMO it depends on how you view/interpret the parent-child relationship: if it's something that has only semantical meaning to your context, then you can probably implement a generic "parent-child" relationship via your node types using stuff like references, or storing identifier properties. Using this approach you can essentially create any type of "connection" between nodes (you can, for example, create bi-directional relationships by using ModeShape's simple references and storing those properties both on the parent and the child nodes. See [MODE-1969] Add support for unidirectional references based on identifiers - JBoss Issue Tracker)

             

            I have already tested with "parent-child" using a weak references property, it is working fine and surprisingly very fast when i search for all node referencing another one. The only problem here is that kind of implementation can only work for one node and i cannot use a "path" representation. I mean, from a specific node, i cannot know all documents linked to my children and descendant nodes with a simple JCR SQL or API. I need to scan all descendants one by one and get relations for each nodes. If i use a shareable nodes logic i will be able to use XPath or JCR SQL condition based on path.

             

            If, on the other hand, you want to be able to have multiple paths (in the JCR sense) for the same node(s), then shareable nodes is the way to go. In this case you need to be aware of the different constraints involved in using shareable nodes (see Chapter 14 of the JSR 283 spec).

            Thanks for the help, i am really new in ModeShape/JCR world, sorry for dumb questions. I will investigate more and test both cases with a full data load.

            • 3. Re: shareable nodes with Modeshape
              Horia Chiorean Master
              Just wondering what is the impact on ACL computation result because in that case you have more than one ACL applied on your node (one for each path). I suppose the result is a merge of all ACL and we keep only higher permissions. I will verify.

              that's a very good question and I doubt anyone has tried this (setting ACLs on a shareable node). Since ACLs are stored on a node level and shareable nodes are linked, not duplicated, I suspect you can only have 1 set of ACLs for any shareable node. So setting different ACLs from different paths pointing towards the same node, will probably override one another.

               

              One other relevant thing regarding ModeShape's implementation of shareable nodes is around querying. As per the JCR spec:

              14.16 Query

              If a query matches two or more nodes in a shared set, whether all of these nodes or just one is returned in the query result is an implementation issue.

              In this case ModeShape always returns just one node, not all the nodes in a shared set.

              • 4. Re: shareable nodes with Modeshape
                Sébastien Berthezene Newbie
                One other relevant thing regarding ModeShape's implementation of shareable nodes is around querying. As per the JCR spec:

                14.16 Query

                If a query matches two or more nodes in a shared set, whether all of these nodes or just one is returned in the query result is an implementation issue.

                In this case ModeShape always returns just one node, not all the nodes in a shared set.

                 

                Thanks for this highlight, it changes everything...  Basically i wanted to use share nodes in order to benefit from such query. Then, there is no benefit for shared nodes. I suppose i will need to change the way i will implement and use references or path like properties on the target.