Skip to content
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

Lock.tryLock with lease time #1564

Closed
gurbuzali opened this issue Jan 15, 2014 · 12 comments

Comments

Projects
None yet
@gurbuzali
Copy link
Member

commented Jan 15, 2014

Hazelcast has lock with lease time feature but does not support tryLock with lease time

@pmanvi

This comment has been minimized.

Copy link

commented May 14, 2014

+1

@sancar sancar removed their assignment Jun 4, 2014

@drewstewart

This comment has been minimized.

Copy link

commented Aug 6, 2014

+1

@logemann

This comment has been minimized.

Copy link

commented Oct 12, 2014

+1

@ajermakovics ajermakovics added Team: Core and removed Team: Core labels Oct 14, 2014

@tcollinsworth

This comment has been minimized.

Copy link

commented Feb 3, 2015

Is tryLock with lease time now supported? I see this was closed, but don't see that it was resolved.

@gurbuzali

This comment has been minimized.

Copy link
Member Author

commented Feb 4, 2015

this is an open issue, we've not yet solved it.
the closed one was only a duplicate. Please see #3692

@logemann

This comment has been minimized.

Copy link

commented Mar 22, 2015

is this so hard to implement? I mean... one year and counting.... looks like copy/paste to me from the normal "lock" feature.

@noctarius

This comment has been minimized.

Copy link
Contributor

commented Mar 23, 2015

Hey @logemann, yeah I guess you're kinda right.
Would you like to give it a try and going to implement it? We would appreciate your help.

@mattk42

This comment has been minimized.

Copy link

commented Jun 3, 2015

I have taken a stab at this and it seems to be working. Going to spend some time on unit tests and should have a pull request soon.

@palevi67

This comment has been minimized.

Copy link

commented Jun 21, 2015

+1

@gurbuzali gurbuzali modified the milestones: 3.6, Backlog Jun 21, 2015

@gurbuzali

This comment has been minimized.

Copy link
Member Author

commented Jul 14, 2015

fixed via #5658

@gurbuzali gurbuzali closed this Jul 14, 2015

@nick7ikin

This comment has been minimized.

Copy link

commented Jul 14, 2015

can I use this combination as workaround to specify lease time?

if (lock.tryLock(1, TimeUnit.SECONDS) {
   lock.lock(2, TimeUnit.SECONDS);
   ....
   lock.unlock();
}
@gurbuzali

This comment has been minimized.

Copy link
Member Author

commented Jul 15, 2015

no need for a workaround for 3.6, we've implemented tryLock with lease time.
please take a look at https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/java/com/hazelcast/core/ILock.java#L90

for the previous versions, yes it works but you need to unlock twice since you've locked it twice:
one with tryLock and one with lock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.