/* Sends a Gossip message to an unreachable member */ void doGossipToUnreachableMember(Message message) { double liveEndpoints = liveEndpoints_.size(); double unreachableEndpoints = unreachableEndpoints_.size(); if (unreachableEndpoints > 0) { /* based on some probability */ double prob = unreachableEndpoints / (liveEndpoints + 1); double randDbl = random_.nextDouble(); if (randDbl < prob) sendGossip(message, unreachableEndpoints_.keySet()); } }
/* Gossip to a seed for facilitating partition healing */ void doGossipToSeed(Message message) { int size = seeds_.size(); if (size > 0) { if (size == 1 && seeds_.contains(localEndpoint_)) { return; } if (liveEndpoints_.size() == 0) { sendGossip(message, seeds_); } else { /* Gossip with the seed with some probability. */ double probability = seeds_.size() / (double) (liveEndpoints_.size() + unreachableEndpoints_.size()); double randDbl = random_.nextDouble(); if (randDbl <= probability) sendGossip(message, seeds_); } } }
public int getPauseTime() { return (int) (Math.max(1000, 5000 * random.nextDouble())); }