Skip to content

Instantly share code, notes, and snippets.

@Swarnim-singhal
Last active September 2, 2020 14:48
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/c7db4b50d2ab5e1fb361a281c019ef41 to your computer and use it in GitHub Desktop.
Save Swarnim-singhal/c7db4b50d2ab5e1fb361a281c019ef41 to your computer and use it in GitHub Desktop.
public class GossipDigestAck {
final List<GossipDigest> gDigestList;
final Map<InetAddressAndPort, EndpointState> epStateMap;
GossipDigestAck(List<GossipDigest> gDigestList, Map<InetAddressAndPort, EndpointState> epStateMap{
this.gDigestList = gDigestList;
this.epStateMap = epStateMap;
}
}
public class GossipDigestAckVerbHandler extends GossipVerbHandler<GossipDigestAck> {
public static final GossipDigestAckVerbHandler instance = new GossipDigestAckVerbHandler();
public void doVerb(Message<GossipDigestAck> message) {
InetAddressAndPort from = message.from();
GossipDigestAck gDigestAckMessage = message.payload;
List<GossipDigest> gDigestList = gDigestAckMessage.getGossipDigestList();
Map<InetAddressAndPort, EndpointState> epStateMap = gDigestAckMessage.getEndpointStateMap();
Map<InetAddressAndPort, EndpointState> deltaEpStateMap = new HashMap<InetAddressAndPort, EndpointState>();
for (GossipDigest gDigest : gDigestList)
{
InetAddressAndPort addr = gDigest.getEndpoint();
EndpointState localEpStatePtr = Gossiper.instance.getStateForVersionBiggerThan(addr, gDigest.getMaxVersion());
if (localEpStatePtr != null)
deltaEpStateMap.put(addr, localEpStatePtr);
}
// construct GossipDigestAck2Message and send it
Message<GossipDigestAck2> gDigestAck2Message = Message.out(GOSSIP_DIGEST_ACK2, new GossipDigestAck2(deltaEpStateMap));
MessagingService.instance().send(gDigestAck2Message, from);
super.doVerb(message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment