Distributed System

坚强是说给别人听的谎言 提交于 2019-12-01 12:23:21
  • Q. How do I differentiate between a client connection and worker connection?
  • A. Use two ports, one to listen to connections from workers and one from clients.
  • Q. How do I keep track of the number of workers currently connected?
  • A. Have a registration mechanism (maybe in a list of workers) to register/deregister each time a worker connects/disconnects.

Q: The manager can accept multiple connections, each connection is run as a thread but how do I differentiate between a client connection and worker connection?

I guess you can define some protocol, by which I mean the format/semantic of messages, msg type may help. Also, as for distributed system, the FIFO can not be vaulted, I guess you should use some mechanism as sequence num, logic clock to take care of the match between request and response.

Q:How do I keep track of the number of workers currently connected?

First, login and logout can be taken into account, however, not always possible, especially logout; second, connect error using timeout, as to crash after sending, there can be some threshold, or "getResult" message; third, as to a DS, I think you had better apply some election algorithm to make sure there is always worker.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!