RMI 客户端跟踪

发布于 2024-10-23 18:28:05 字数 347 浏览 5 评论 0原文

我正在构建一个具有一些非常具体需求的客户端/服务器应用程序。有两种服务器:第一种提供大部分远程程序,客户端直接连接到这些程序,而第二种是单个服务器,应跟踪哪些用户处于活动状态(客户端)以及第一种服务器有多少个kind 在调用方法时处于活动状态。

最主要的是监视器应该只连接到服务器而不是直接连接到客户端。我的第一个想法是在客户端连接/断开连接时实现一个简单的登录/注销 rmi 方法,并跟踪列表中的那些方法,但主要问题是当客户端或服务器异常结束时。

例如,如果客户端突然离线,则应以某种方式通知服务器并相应地更新列表,而如果服务器退出,则应将与其连接的所有客户端标记为在控制服务器中不活动。

任何有关如何实现此功能的想法将不胜感激。

I'm building a Client / Server app that has some very specific needs. There are 2 kinds of servers: the first kind provide most of the remote procedures and clients connect to these directly, while the second kind is a single server that should keep track of what users are active (clients) and how many servers of the first kind are active when a method is called.

The main thing is that the monitor should ONLY connect to the servers and not the clients directly. My first idea was to implement a simple login/logout rmi method when a client connects/ disconnects and keep track of those in a list but the main problem is when a client or server end abnormally.

For example, if a client goes offline abruptly the server should somehow be notified and update the list accordingly, while if a server goes out all of the clients connected to it should be marked as not active in the control server.

Any ideas of how to implement this functionality would be appreciated.

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

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

发布评论

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

评论(2

三生一梦 2024-10-30 18:28:05

我建议采用“会话”方法来解决问题,其中服务器和客户端每隔几分钟(可能是几秒或几小时,具体取决于您的需要)向监控服务器发送一次“心跳”方法调用。如果监控服务器在一定时间内没有收到来自服务器或客户端的“心跳”,那么您就认为它们已经消失(异常终止)并相应地发出通知。

I would suggest implementing a "session" approach to the problem, where the servers and the clients are sending a "heartbeat" method call to the monitoring server every several minutes(may seconds or hours depending on your needs). If the monitoring server doesn't receive a "heartbeat" from the servers or clients in a certain amount of time, then you consider them gone (terminated abnormally) and notify accordingly.

暖心男生 2024-10-30 18:28:05

Zookeeper 可能值得一看。让每个客户端服务器为自己以及连接到它的每个客户端注册一个临时节点。当客户端服务器宕机时,临时节点就会死亡。监控服务器只需要监视zookeeper即可查看谁已启动并已连接。

为了检测客户端关闭,您将需要某种类型的心跳,以便客户端服务器可以检测客户端何时死亡。如果客户端可以直接与zookeeper通信,那么只需让客户端在zookeeper中注册一个临时节点,客户端服务器就可以监视客户端的临时节点,并知道客户端何时关闭。

Zookeeper may be something to look at. Have each clientserver register an ephemeral node for itself, and for each client that is connected to it. When the clientserver goes down, the ephemeral nodes will die. The monitor server just needs to watch zookeeper to see who is up and connected.

For detecting clients going down, you will need some kind of hearbeating so that the clientserver can detect when a client dies. If the client can talk to zookeeper directly, then simply have the client register an ephemeral node in zookeeper as well, and the clientserver can watch the clients ephemeral node, and know when the client is down.

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