You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Torgeir Veimo <to...@gmail.com> on 2014/12/15 12:30:05 UTC

automatically create unique name among siblings with oak

With oak not supporting SNS anymore I'm looking for a utility method
that ensures unique names for siblings.

Just checking existing siblings and using an incrementing counter is
not sufficient since it wouldn't be cluster or concurrent session
safe, thus might cause an exception later when the session is
persisted. It's also not very performant with a linear search when
there's a large number of siblings.

I can probably get around the cluster issue using a lock, but that
would possibly be even slower.

One approach I'm considering is just using a name like prefix +
sessionId + counter, since I would have control of any writes in that
session.

There's a number of variations of that technique to avoid a linear
search for uniqueness with a large number of siblings: increment
exponentially, using a random number etc.

Does anyone have any existing code that does similar things? I'm
wondering if there's a very simple approach that I've overlooked?

-- 
-Tor