jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Klimetschek (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (JCR-3534) Efficient copying of binaries across repositories with the same data store
Date Mon, 06 May 2013 18:36:17 GMT

    [ https://issues.apache.org/jira/browse/JCR-3534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13649962#comment-13649962
] 

Alexander Klimetschek commented on JCR-3534:
--------------------------------------------

@Tommaso: There are 2 things:

a) api or not for creating the binary: since the requirement here is an application level
protocol, there must be an API, otherwise it could not know if it should resend the full binary
or not. The application level protocol currently cannot and should not know if the datastores
are shared or not. AFAICS, the discussion so far did not result in avoiding an API, just to
make sure it's a _secure_ API.

In my above comments I missed the proposed trick to use "createValue(java.lang.String value,
PropertyType.BINARY)" - but I don't see that in the patch either. This would look something
like this IIUC, instead of the getBinaryFromSecureID() in my above snippet:

Node node = ... // current node written 
Binary binary; 
if (messageData.hasBinaryStream()) { 
    binary = getBinaryFromStream(messageData, session); 
} else { 
    String message = messageData.getBinaryMessage(); // get from custom protocol 
    try {
        binary = session.getValueFactory().createValue(message, PropertyType.BINARY); 
    } catch (ValueFormatException e) {
        // not supported / wrong secret / referenced binary not found
        return ASK_FOR_BINARY_STREAM; 
    } 
} 
node.setProperty("jcr:data", binary); 


It is important however that createValue() will only return a binary if the message is right;
if it creates a binary of the string contents (not sure if that is currently the case if you
call createValue() this way, then this trick cannot work and we do need another API.

b) reading the binary: could you show me the application code reading such a binary just using
the JCR API how it gets the actual data? This is completely missing yet (the test in the patch
uses DataStore.getRecord(), but that is Jackrabbit internal).
                
> Efficient copying of binaries across repositories with the same data store
> --------------------------------------------------------------------------
>
>                 Key: JCR-3534
>                 URL: https://issues.apache.org/jira/browse/JCR-3534
>             Project: Jackrabbit Content Repository
>          Issue Type: New Feature
>          Components: jackrabbit-api, jackrabbit-core
>    Affects Versions: 2.6
>            Reporter: Felix Meschberger
>            Assignee: Tommaso Teofili
>         Attachments: JCR-3534.2.patch, JCR-3534.patch, JCR-3534.patch
>
>
> we have a couple of use cases, where we would like to leverage the global data store
to prevent sending around and copying around large binary data unnecessarily: We have two
separate Jackrabbit instances configured to use the same DataStore (for the sake of this discussion
assume we have the problems of concurrent access and garbage collection under control). When
sending content from one instance to the other instance we don't want to send potentially
large binary data (e.g. video files) if not needed.
> The idea is for the sender to just send the content identity from JackrabbitValue.getContentIdentity().
The receiver would then check whether the such content already exists and would reuse if so:
> String ci = contentIdentity_from_sender;
> try {
>     Value v = session.getValueByContentIdentity(ci);
>     Property p = targetNode.setProperty(propName, v);
> } catch (ItemNotFoundException ie) {
>     // unknown or invalid content Identity
> } catch (RepositoryException re) {
>     // some other exception
> }
> Thus the proposed JackrabbitSession.getValueByContentIdentity(String) method would allow
for round tripping the JackrabbitValue.getContentIdentity() preventing superfluous binary
data copying and moving. 
> See also the dev@ thread http://jackrabbit.markmail.org/thread/gedk5jsrp6offkhi

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message