collisions can be resolved by normal Address ordering


Ciao,

Roland

On 16 jan 2013, at 07:40, Patrik Nordwall <notifications@github.com> wrote:

> In akka-cluster/src/main/scala/akka/cluster/ClusterHeartbeat.scala:
> 
> > + * INTERNAL API
> > + *
> > + * Data structure for picking heartbeat receivers and keep track of what nodes
> > + * that are expected to send heartbeat messages to a node. The node ring is
> > + * shuffled by deterministic hashing to avoid picking physically co-located
> > + * neighbors.
> > + *
> > + * It is immutable, i.e. the methods return new instances.
> > + */
> > +private[cluster] case class HeartbeatNodeRing(selfAddress: Address, nodes: Set[Address], monitoredByNrOfMembers: Int) {
> > +
> > +  require(nodes contains selfAddress, s"nodes [${nodes.mkString(", ")}] must contain selfAddress [${selfAddress}]")
> > +
> > +  private val (hashToIndex: Map[Int, Int], nodeRing: Vector[Address]) = {
> > +    val nodesByHash: immutable.SortedMap[Int, Address] = immutable.SortedMap.empty[Int, Address] ++
> > +      nodes.map(node ⇒ hashFor(node) -> node)
> This shuffle by using hashing doesn't work when there are collisions, some will be lost when producing senders.
> We should use a simple deterministic sort (shuffle) algorithm instead.
> 
> —
> Reply to this email directly or view it on GitHub.
>