Skip to content

Instantly share code, notes, and snippets.

@Swarnim-singhal
Created September 1, 2020 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Swarnim-singhal/c7921424f48b6edfca0b15c85db2c985 to your computer and use it in GitHub Desktop.
Save Swarnim-singhal/c7921424f48b6edfca0b15c85db2c985 to your computer and use it in GitHub Desktop.
public class GossipDigest implements Comparable<GossipDigest> {
final InetAddressAndPort endpoint;
final int generation; // generation stays the same when server is running and grows every time the node is started
final int maxVersion; // maximum version number is the biggest version number in EndPointState for this endpoint
GossipDigest(InetAddressAndPort ep, int gen, int version){
endpoint = ep;
generation = gen;
maxVersion = version;
}
public int compareTo(GossipDigest gDigest){
if (generation != gDigest.generation)
return (generation - gDigest.generation);
return (maxVersion - gDigest.maxVersion);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment