voldemort.server.gossip
Class Gossiper

java.lang.Object
  extended by voldemort.server.gossip.Gossiper
All Implemented Interfaces:
java.lang.Runnable

public class Gossiper
extends java.lang.Object
implements java.lang.Runnable

Implementation of a Gossip protocol for metadata. Periodically, choose a random peer and Gossip for all metadata keys specified in MetadataStore.GOSSIP_KEYS with that peer.

Gossip between nodes A and B for a metadata key K starts with node A retrieving the key K and its vector clock from node B. The retrieved vector clock is then compared with the local vector clock for K. If the value at node B is determined to have come after the value at node A, node A will accept the value at node B. If the value at node B is determined to have come before the value at node A, node A will do nothing and allow node B to initiate Gossip. If the two vector clocks are found to be concurrent i.e., causally unrelated, an error is logged.


Constructor Summary
Gossiper(MetadataStore metadataStore, AdminClient adminClient, int gossipInterval)
          Create a Gossiper object, which implements Runnable allowing it to be run as a thread or be submitted to an Executor.
 
Method Summary
protected  void gossipKey(Node node, java.lang.String key)
          Perform Gossip on a specified metadata key with a remote node.
 void run()
          Perform Gossip: until receiving a shutdown signal, pick a peer at random, Gossip all keys listed in MetadataStore.GOSSIP_KEYS with that peer and then sleep for a specified interval.
protected  Node selectPeer()
          Randomly select a distinct peer.
 void start()
          Allow Gossip to start if run() is invoked.
 void stop()
          After the current operation finishes, stop Gossip.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Gossiper

public Gossiper(MetadataStore metadataStore,
                AdminClient adminClient,
                int gossipInterval)
Create a Gossiper object, which implements Runnable allowing it to be run as a thread or be submitted to an Executor.

Parameters:
metadataStore - The instance of MetadataStore for the local node.
adminClient - Instance of AdminClient
gossipInterval - Interval in milliseconds at which we want to gossip.
Method Detail

start

public void start()
Allow Gossip to start if run() is invoked.


stop

public void stop()
After the current operation finishes, stop Gossip.


run

public void run()
Perform Gossip: until receiving a shutdown signal, pick a peer at random, Gossip all keys listed in MetadataStore.GOSSIP_KEYS with that peer and then sleep for a specified interval.

Specified by:
run in interface java.lang.Runnable

selectPeer

protected Node selectPeer()
Randomly select a distinct peer. Method is protected rather than private, so that it may be overridden if peer selection logic is to be changed e.g., to add datacenter/rack awareness.

Returns:
Peer for Gossip.

gossipKey

protected void gossipKey(Node node,
                         java.lang.String key)
Perform Gossip on a specified metadata key with a remote node. As metadata is data, vector clocks are used to determine causality.

Method is protected rather than private, so that it may be overridden if the behaviour for handling concurrent values of the same key was to be changed e.g., if two differently named stores were added during a network split, merge appropriate metadata to include both stores.

Parameters:
node - Node to Gossip with.
key - Metadata key to exchange by Gossip.


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu