简体   繁体   English

当 UID 不是整数时的领导者选举

[英]leader election when UID's are not integers

I'm new to distributed systems and I'm currently studying Nancy lynch's book for distributed algorithms.我是分布式系统的新手,目前正在研究 Nancy lynch 的分布式算法书。 Now After Finishing the section about leader elections problem and learning algorithms like LCR, HS,.. one problem come a cross my mind:现在在完成关于领导人选举问题和学习算法(如 LCR、HS 等)的部分之后,我想到了一个问题:
What if the UID's weren't positive integers?如果 UID 不是正整数怎么办?
basically in all of that section I read, UID's were positive integers.基本上在我阅读的所有部分中,UID 都是正整数。 How ever when I was thinking about coding this algorithms I thought about objects for comparison.当我考虑编码这个算法时,我想到了用于比较的对象。 For instance in programming we may have different objects(like apples and oranges!).例如在编程中我们可能有不同的对象(比如苹果和橘子!)。 So the problem would be something like:所以问题会是这样的:
If for instance A,B,C,... were the UID's of the nodes, how can I elect the leader?如果例如 A,B,C,... 是节点的 UID,我该如何选举领导者?


One of my big problems is that we can't simply compare objects!我的一大问题是我们不能简单地比较对象! like we can say A==A but there is no way no say A>B or A<B (its like saying apple is bigger than orange or not?)就像我们可以说A==A但没有办法说A>B or A<B (就像说苹果比橙色大或不?)

Thank in advance预先感谢

With objects you pick an arbitrary way to compare them.对于对象,您可以选择任意方式来比较它们。 There are many choices of comparison, but if everyone agrees on which one to use, then it works.有很多比较的选择,但如果每个人都同意使用哪个,那么它就有效。

For example you can decide to compare your fruits by weight.例如,您可以决定按重量比较您的水果。 And now any given apple can be fairly compared to any given orange.现在任何给定的苹果都可以与任何给定的橙子进行比较。 And the algorithm works.该算法有效。

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

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