Can someone confirm if the atomic counter support code is suitable for sequences?
https://jackrabbit.apache.org/oak/docs/apidocs/org/apache/jackrabbit/oak/plugins/atomic/AtomicCounterEditor.html If my reading of the spec is correct, separate sessions will see their results from the increment immediately and isolated from other sessions incrementing the same counter, so using the results from an increment can safely be used as a sequence number as long as the counter is ever incremented in any code? On 13 November 2015 at 14:40, Torgeir Veimo <[email protected]> wrote: > Am trying to use the new atomicSupport feature, and am wondering if I'm > using it the correct way; > > My counter is initialised with > > Node counter = JcrUtils.getOrCreateByPath("/testCounter", > "oak:Unstructured", session); > if (counter.isNew()) { > counter.addMixin("mix:atomicCounter"); > session.save(); > } > > then when fetching a new value > > counter.setProperty("oak:increment", 1); > session.save(); > long value = counter.getProperty("oak:counter").getLong(); > > What happens if the same code is called from a different thread / session > after the session.save() but before the getProperty() call? Will the value > remain unchanged in this thread / session? > > -- > -Tor > -- -Tor
