You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Michael Dürig (JIRA)" <ji...@apache.org> on 2014/10/20 17:22:34 UTC

[jira] [Commented] (OAK-2220) Support for atomic counters

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

Michael Dürig commented on OAK-2220:
------------------------------------

[Here|https://github.com/mduerig/jackrabbit-oak/commit/4d4e464949c03e317704f77ae30e44f1510475b5] is a POC I came up with, which uses Oak commit hooks for the aggregating individual counter properties into a single count property. 

Each update of a counter needs to happen through adding a property whose name starts with "delta-" and is suffixed with an [unique id | https://github.com/mduerig/jackrabbit-oak/blob/4d4e464949c03e317704f77ae30e44f1510475b5/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CounterTest.java#L79]. On commit a hook takes care of aggregating those values into an indexable [count property | https://github.com/mduerig/jackrabbit-oak/blob/4d4e464949c03e317704f77ae30e44f1510475b5/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/AggregatingEditor.java#L61]. There is a [test case | https://github.com/mduerig/jackrabbit-oak/blob/4d4e464949c03e317704f77ae30e44f1510475b5/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CounterTest.java#L56] with 100 concurrent threads updating the same counter, which shows this in action.

This is all very raw and bare bones and there is lots of room for adjustments. I hope to bring the main point across of using commit hooks for doing the aggregation instead of observation or queries.  

> Support for atomic counters
> ---------------------------
>
>                 Key: OAK-2220
>                 URL: https://issues.apache.org/jira/browse/OAK-2220
>             Project: Jackrabbit Oak
>          Issue Type: New Feature
>          Components: core
>            Reporter: Michael Dürig
>            Assignee: Michael Dürig
>             Fix For: 1.1.2
>
>
> For several use cases (think +1/-1 votes on forum posts) it would be good to have some basic support for atomic counters in Oak. Such counters must:
> # correctly reflect increments/decrements by integral parts across threads / cluster nodes,
> # exhibit some well defined consistency characteristics amongst each other, 
> # not require cluster wide coordination.
> 1. is required so in the forum post example the correct number of votes is recorded for each post. 
> 2. is important so in the forum post example sorting by votes results in the correct order.
> 3. is important as global cluster synchronisation run contrary to out overall scalability goals. 
> Additionally such counters should allow the user to trade off the consistency characteristics from 2 for availability. I.e. scarifying some availability results in hight consistency. 



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