JobLockService 使用什么策略来强制同步?

发布于 2024-11-28 04:22:58 字数 568 浏览 2 评论 0原文

JobLockService 使用什么策略来强制同步?它会锁定整个存储库吗?或者还有另一种技术?

当我编写这样的代码时:

String lockString = jobLockService.getLock(QName.createQName(Prefix,LocalName, Resolver));
LockToken lockToken = new LockToken();
lockToken.set(lockString);
// Something going here such as create a node or update or delete
// another somethign processes here
jobLockService.releaseLock(lockString);

正如您可以从该代码中注意到的那样,我使用 JobLockService 获取锁后会发生什么?它是否完全锁定存储库并阻止任何其他进程访问该存储库?

我问的是用于强制同步的实际技术。

另外,这里的 LockToken 是什么?这样做有什么好处?

预先感谢,非常感谢您的回复。

What is the strategy used by JobLockService to enforce the synchronization ? Does it lock the whole Repository? or there is another technique?

When i write a code such that :

String lockString = jobLockService.getLock(QName.createQName(Prefix,LocalName, Resolver));
LockToken lockToken = new LockToken();
lockToken.set(lockString);
// Something going here such as create a node or update or delete
// another somethign processes here
jobLockService.releaseLock(lockString);

As you can notice from that code i use JobLockService What is happening once the lock is acquired ? Does it lock the repository at all and prevents any other prcoesses from accessing the repository ?

I'm asking about actual techniques used to enforece the synchronization.

Also, What is about LockToken here ? what is the benefit from it ?

Thanks in advance, you replies are very highly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深者入戏 2024-12-05 04:22:58

JobLockService 确实不会对存储到存储库中的实际内容设置任何锁定,更不用说锁定整个存储库了。成功调用 JobLockService.getLock 后,任何线程都可以自由更新它想要编辑的任何节点。您的代码必须确保必须以受控并发执行的块首先尝试获取相同的锁。

您创建的 LockToken 对象似乎没有用,可以删除。

JobLockService does not put any lock on actual content stored into the repository, let alone lock the whole repository. After you successfully called JobLockService.getLock, any thread is free to update whichever node it wants to edit. It is your code that must ensure that blocks that have to execute with a controlled concurrency are first trying to obtain the same lock.

That LockToken object you create seems of no use and can be dropped.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文