-
Notifications
You must be signed in to change notification settings - Fork 14
Pooled sequence generator #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that I understand the lock/unlock around Hash.get. What does that achieve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation.
} | ||
rwl.writeLock().unlock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it even possible for si to be null at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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