简体   繁体   English

如何在Java中实现多节点屏障?

[英]How can I implement multi-node barrier in Java?

I am building a multi-node (distributed) experiment setup in Java for academic project. 我正在使用Java为学术项目构建多节点(分布式)实验设置。 I use a script to start the application at all the nodes. 我使用脚本在所有节点上启动应用程序。 After the application starts and gets all the modules up, these nodes start some operations on shared data distributed over these nodes. 应用程序启动并启动所有模块后,这些节点将对分布在这些节点上的共享数据启动一些操作。 Currently I have put a delay between the instant all modules are up and the instant when the first operation is initiated at an individual node. 目前,我在所有模块启动和在单个节点上启动第一个操作的瞬间之间设置了延迟。 Though this seems to work, I would like to have a barrier such that all nodes start their modules and progress to the barrier. 尽管这似乎可行,但我希望有一个屏障,以便所有节点启动其模块并前进至该屏障。 Once all nodes have progressed to the barrier, then they can initiate operation on shared data. 一旦所有节点都已达到障碍,则它们可以启动对共享数据的操作。

It would be a great help, if someone can either explain how to do it or at least point me to a right documentation. 如果有人可以解释如何做或者至少为我指出正确的文档,那将是非常有用的帮助。 FYI, I would prefer to avoid semaphores if possible. 仅供参考,如果可能的话,我宁愿避免使用信号灯。 At the start I know the number of nodes participating in the experiment, so this information of #nodes can be used in setting up the barrier. 首先,我知道参与实验的节点数,因此#nodes的信息可用于设置障碍。

Thanks 谢谢
Sachin 萨钦

Have a look at Hazelcast. 看看Hazelcast。 There is a CyclicBarrier implementation available (I did not test it). 有一个CyclicBarrier实现可用(我没有测试过)。 You could also use a distributed version of a CountDownLatch . 您还可以使用CountDownLatch的分布式版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM