Pooled sequence generator#367
Conversation
|
What is a "pooled sequence generator"? |
|
Generates a pool of ids from the DB, serves the ids from the pool until all
the ids in the pool are consumed, then generates another pool of ids.
Lowers traffic on the sequence generation collection by 1/n, n being
poolsize.
…On Fri, Jun 16, 2017 at 9:01 AM, Dennis Crissman ***@***.***> wrote:
What is a "pooled sequence generator"?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#367 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADgDDTXTaAs--odSNdKOY_Lux5yPRarnks5sEpiugaJpZM4N8h9z>
.
|
| String fullName=coll.getFullName()+"."+name; | ||
| rwl.readLock().lock(); | ||
| SequenceInfo si=sequenceInfo.get(fullName); | ||
| rwl.readLock().unlock(); |
There was a problem hiding this comment.
I am not sure that I understand the lock/unlock around Hash.get. What does that achieve?
There was a problem hiding this comment.
Readers of the hashmap use readLock, writers use writeLock. So, many can read, only one can write. Readers will block when someone is writing, but readers won't block each other. Better than synchronized.
| si=new SequenceInfo(fullName); | ||
| sequenceInfo.put(fullName,si); | ||
| } | ||
| rwl.writeLock().unlock(); |
There was a problem hiding this comment.
Looks more or less like a lazy instantiation. Would a synchronised method that returns a ReentrantReadWriteLock help clear some of this up?
There was a problem hiding this comment.
It is lazy initialization of a pool for the first time in the hashmap. To write into the hashmap, we need a writeLock. I don't understand your comment about the synchronized method.
There was a problem hiding this comment.
Disregard then, based on other conversation thread.
|
|
||
| try { | ||
| // If there are ids in the pool, use one | ||
| if(si!=null) { |
There was a problem hiding this comment.
Is it even possible for si to be null at this point?
There was a problem hiding this comment.
it is not, at this point, i'll clean that up
…current Additional unit test for concurrent update logic
This reverts commit dfd4ef3.
…re.version property
… they are not strings
|
This is now ready for review-merge |
… tests