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

Chetan Mehrotra commented on OAK-4640:
--------------------------------------

Implementing this poses some challenges

# Reset of the attribute incase of retry of commit - DocumentNodeStore can 
perform multiple merge attempts in case of merge exception and as highlighted 
by Vikas we should reset the attributes upon such retry
# CommitInfo#EMPTY - This static instance is used widely. So we cannot just add 
a mutable state in CommitInfo directly. As it would then be accessed 
concurrently.  

Given above constraints/requirements I have done an initial implementation 
[patch|^OAK-4640-v1.patch] which takes following approach
# Introduces a new interface {{CommitAttributes}} which provide simple get and 
set for attributes
# {{CommitAttributes}} is then implemented by {{SimpleCommitAttributes}}. In 
addition a new {{ResetCommitAttributeHook}} is implemented which resets the 
attribute map at start 
# Modified {{MutableRoot}} to set a {{SimpleCommitAttributes}} instance as part 
of {{info}} map passed to {{CommitInfo}}. 

So with this setup {{CommitHook}} implementations need to check for the 
presence of {{CommitAttributes}} (which may be null). If present they make use 
of it otherwise they need to disable the logic which depends on attributes (or 
throw exception). This also ensures that attributes get reset without needing 
any change in NodeStore implementations

[~mduerig] [~catholicon] Please review! Few point to check

# Should we provide a direct accessor to {{CommitAttributes}} in {{CommitInfo}} 
like whats being done for {{path}}. This would be marked as nullable

Further if you can suggest a different approach I can try implementing that 
also. For now this is least obtrusive way I can think of


> Provide a way for commit hook to record meta data for a given commit
> --------------------------------------------------------------------
>
>                 Key: OAK-4640
>                 URL: https://issues.apache.org/jira/browse/OAK-4640
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core
>            Reporter: Chetan Mehrotra
>            Assignee: Chetan Mehrotra
>             Fix For: 1.6
>
>         Attachments: OAK-4640-v1.patch
>
>
> Currently as part of commit the caller can provide a CommitInfo instance 
> which captures some metadata related to commit being performed. Note that 
> CommitInfo instance passed to NodeStore is immutable.
> For some usecases we need a way to add some more metadata to on going
> commit from within the CommitHook
> * OAK-4586 - Here we need to record nodetypes of nodes which got modified as 
> part of current commit
> * OAK-4412 - Here we want to generate Documents for modified nodestate (per 
> index definition) and "attach" it to current commit
> This meta information would later be used by Observer.
> To enable such cases some mutable state needs to be exposed as part of 
> CommitInfo which can be used by CommitHooks.
> As per discussion of DL [1] this can be done by adding a new 
> {{CommitAttributes}} instance which can be accessed from {{CommitInfo}}
> [1] 
> http://mail-archives.apache.org/mod_mbox/jackrabbit-oak-dev/201608.mbox/%3CCAHCW-mk%3DTMQ_q20dPSmdr7Q%3DcR8OfMDdJceDTd-pGs0pk_cK0g%40mail.gmail.com%3E



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to