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

feat(lock): support basic distributed lock api #178

Merged
merged 22 commits into from
Sep 3, 2024
Merged

feat(lock): support basic distributed lock api #178

merged 22 commits into from
Sep 3, 2024

Conversation

mattisonchao
Copy link
Member

@mattisonchao mattisonchao commented Sep 1, 2024

Motivation

Support basic APIs for distributed lock implementation. because it's still in experiment level, we can only use it by factory mode.

    final LockManager lm = LockManagers.createLockManager(client);
    final AsyncLock lock = lm.getLightWeightLock(lockKey);
    lock.lock().join();
    lock.tryLock().join();
    lock.unlock().join();

public CompletableFuture<Void> tryLock(
long time, TimeUnit unit, ExecutorService callbackService) {
return lock(callbackService)
.orTimeout(time, unit)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When lock with retry, and put the retry task into taskService queue and wait for the next time schedule, but the tryLock timeout condition hit. It will fail this trylock operation, but the next retry won't cancel and it may succeed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a good point. let me fix it then. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted the tryLock with time now. and will support safe cancel future in the next PR.

@mattisonchao mattisonchao merged commit 3961ef4 into main Sep 3, 2024
1 check passed
@mattisonchao mattisonchao deleted the lock branch September 3, 2024 12:10
mattisonchao added a commit that referenced this pull request Sep 9, 2024
mattisonchao added a commit that referenced this pull request Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants