-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
fix #1715 #1740
fix #1715 #1740
Conversation
*/ | ||
private Optional<TaskLock> tryLock(final Task task, final Interval interval, final Optional<String> preferredVersion) | ||
{ | ||
giant.lock(); | ||
|
||
try { | ||
if(!tasks.contains(task)){ |
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.
This has me a bit worried because then every task needs to implement equals and hash properly, which I'm not sure was enforced prior to this. Is there a reason it cannot be a set of the string TaskID?
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.
makes sense, will change it to store taskId.
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.
done.
3af08b1
to
20c8975
Compare
@@ -66,6 +66,9 @@ | |||
|
|||
private static final EmittingLogger log = new EmittingLogger(TaskLockbox.class); | |||
|
|||
// Stores List of Active Tasks. TaskLockbox will only grant locks to active activeTasks. | |||
private final Set<String> activeTasks = Sets.newHashSet(); |
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.
Does this need memory protection of the big lock to access or modify? If so it is probably worth calling out here.
20c8975
to
5f8cd37
Compare
*/ | ||
private Optional<TaskLock> tryLock(final Task task, final Interval interval, final Optional<String> preferredVersion) | ||
{ | ||
giant.lock(); | ||
|
||
try { | ||
if(!activeTasks.contains(task.getId())){ |
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.
Why throw ISE instead of returning absent?
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.
modified to return absent for invalid tasks.
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.
If it doesn't throw something then "lock" will spin forever.
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.
fixed.
5c21b80
to
c0da8dc
Compare
{ | ||
giant.lock(); | ||
try { | ||
return activeTasks.remove(task.getId()); |
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 think this method should be combined with unlock(Task)
, they're both called at the same time (by the queue, when a task finishes).
This method should also be signalling the lockReleaseCondition, since when a task is removed then we want to ISE out of any lock(task)
calls for that task.
c0da8dc
to
face055
Compare
@gianm have taken care of your comments. please have a look again |
} | ||
finally { | ||
activeTasks.remove(task.getId()); |
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.
unlock should have a finally block of its own, even if this remove is in its own try{}finally{} block.
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.
done
face055
to
4f0e65c
Compare
*/ | ||
private Optional<TaskLock> tryLock(final Task task, final Interval interval, final Optional<String> preferredVersion) | ||
{ | ||
giant.lock(); | ||
|
||
try { | ||
if(!activeTasks.contains(task.getId())){ | ||
throw new IllegalStateException(String.format("Unable to grant lock to inactive Task [%s]", task.getId())); |
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.
small comment, but why don't we use ISE here instead?
👍 |
4f0e65c
to
4da45a0
Compare
fixes apache#1715 - TaskLockBox has a set of active tasks - lock requests throws exception for if they are from a task not in active task set. - TaskQueue is responsible for updating the active task set on tasklockbox fix apache#1715 fixes apache#1715 - TaskLockBox has a set of active tasks - lock requests throws exception for if they are from a task not in active task set. - TaskQueue is responsible for updating the active task set on tasklockbox review comment remove duplicate line use ISE instead organise imports
4da45a0
to
b638400
Compare
fixes #1715
active task set.
tasklockbox