ModeShape/modeshape — pull request #593 by rhauch (2012-11-08 22:56:30+00:00)
Title: Federation - Improved Connector SPI and file system connector 

The Connector SPI was improved, particularly the DocumentReader and DocumentWriter interfaces and implementations. (That implementations now reuse logic from DocumentTranslator, since the impls logic was non-trivial and contained several errors and bugs.) The JavaDoc of the Connector methods was changed to define the acceptable runtime exceptions. And the FileSystemConnector was improved to better support reads and writes.

There still are several issues, however.

First, the getName() and getPath() of the JCR nodes representing external nodes return the wrong information. Since both name and path are based upon the path of the node, I believe there is an error within the parent logic for external nodes. However, I didn't have time to track this down.

Secondly, the mechanism by which changes to nodes are sent to the connector (ultimately thru the 'update' SPI method) is not ideal. For example, consider that a external node has lots of properties ( including one or more very large BINARY value). When a client adds a single property to this node via the JCR API, ModeShape reads the entire node document from the connector (with all of the large properties), changes the node's document, and the pushes the entire (changed) node document down to the connector. The connector then has to write out the full state of the node, including all of the large properties.

Normally, with Infinispan for storage, we do want/need to persist the whole (changed) node document. However, for connectors we likely will want to know which parts of the node document have changed so that the connector can just update what's been changed (e.g., in the example, the connector should really just have to add the new property to its storage system).

The DocumentStore is obtaining an editor for the document, so it's possible that the FederatedDocumentStore needs to return a fully-functional editor so that it can record what is changed and submit that to the connector via the 'update' method.

Note that this second issue is purely related to performance and cost of connector operations. So for the time being it might be fine. However, I think we should consider changing the connector.update(...) signature to perhaps *also* pass a parameter that describes what's changed (e.g., a "delta" representation).