-
1. Re: Custom CNDs and Indexes
hchiorean Mar 24, 2017 2:41 AM (in response to dharrison)If you're planning on clustering, ModeShape 5 only works with a shared database model. In other words, all repository cluster nodes must share the same database. This also means that as long as CNDs have been stored into the database they should be visible across all nodes. JGroups is only used to invalidate the local cluster node in-memory caches when each node performs session.save() operations.
Regarding CNDs and index definitions, as you point out, the prerequisite for index definitions to work is that the data types for which they are defined are stored in the repository first.
The options I can think of are:
a) if you know all your CNDs up front (which normally should be the case once your model is "stable") then you can configure the repository to load the CND file up front (via the configuration) and also define all the index definitions in the repository configuration file. In other words, you define everything up front.
b) if you need the ability to add/change CNDs at runtime, then you must do the same with the index definitions. This means currently (see the next point) that you write some code against a repository instance and use the org.modeshape.jcr.api.index.IndexManager API (from the modeshape-api package) to do this. You can add the CNDs either via the REST API or directly using the org.modeshape.jcr.api.nodetype.NodeTypeManager API, but you only have 1 way atm to dynamically register indexes
c) enhance the ModeShape REST API (or have your own custom REST Service on top of a ModeShape repository) to be able to register indexes using the above mentioned API.
-
2. Re: Custom CNDs and Indexes
dharrison Mar 30, 2017 12:09 AM (in response to hchiorean)hchiorean If I were to enhance the ModeShape REST API, I adhered to the coding standards of the ModeShape community, etc, is this a enhancement you would include in the modeshape codebase?
I'm thinking I need
- POST - Register/Create an Index, reusing the same JSON format as used in defining an index in the respository configuration JSON.
- GET - Get definition of one or more indices
- DELETE - Remove an index
Possibly
- PUT - Replace definition of an index, which would most likely just unregister the index and register it again under the new definition
Thanks very much!
David
-
3. Re: Custom CNDs and Indexes
hchiorean Mar 30, 2017 3:02 AM (in response to dharrison)1 of 1 people found this helpfulhchiorean If I were to enhance the ModeShape REST API, I adhered to the coding standards of the ModeShape community, etc, is this a enhancement you would include in the modeshape codebase?
Of course, we're more than happy to include such an enhancement, especially since I think it would make a nice addition to the REST service.
Regarding the implementation:
- I would probably name the method "indexes" or something similar and URL segment /repositoryName/indexes
- I can think of 2 GET methods: GET repository/indexes which returns all configured indexes (from the repo config) and GET /repository/indexes/<indexName> which returns an array for all the indexes named <indexName> (note that it's possible for the same index name to be used across multiple providers)
- POST/ DELETE /repositoryName/indexes/<indexName> would take the body as a JSON resembling the "index" section from the repository configuration and would create or delete an index for a particular provider (based on the provider attribute from the JSON body)
- PUT is a bit tricky since there's no direct API support for updating an index definition. So if you want to implement this you would have to do a unregister/register combination behind the scenes
These are just ideas, you're free to implement these in whichever way is most useful for your use case. If you're interested in contributing this feature, please log a JIRA so we can track it. Thanks.
-
-
5. Re: Custom CNDs and Indexes
dharrison Apr 26, 2017 10:22 AM (in response to dharrison)While my employer has a legal policy discussion on open source contributions, I'm trying the route of loading all CND and indexes from files , at startup time. If that doesn't suffice, I'll proceed with the rest enhancement and hope for go ahead to contribute