Class CuratorDruidLeaderSelector

java.lang.Object
org.apache.druid.curator.discovery.CuratorDruidLeaderSelector
All Implemented Interfaces:
DruidLeaderSelector

public class CuratorDruidLeaderSelector extends Object implements DruidLeaderSelector
  • Constructor Details

    • CuratorDruidLeaderSelector

      public CuratorDruidLeaderSelector(org.apache.curator.framework.CuratorFramework curator, DruidNode self, String latchPath)
  • Method Details

    • getCurrentLeader

      @Nullable public String getCurrentLeader()
      Description copied from interface: DruidLeaderSelector
      Get ID of current Leader. Returns NULL if it can't find the leader. Note that it is possible for leadership to change right after this call returns, so caller would get wrong leader. This is expected to work even if a listener is not registered.
      Specified by:
      getCurrentLeader in interface DruidLeaderSelector
    • isLeader

      public boolean isLeader()
      Description copied from interface: DruidLeaderSelector
      Returns true if this node is elected leader from underlying system's point of view. For example if curator is used to implement this then true would be returned when curator believes this node to be the leader. Note that it is possible for leadership to change right after this call returns, so caller would get wrong status.
      Specified by:
      isLeader in interface DruidLeaderSelector
    • localTerm

      public int localTerm()
      Description copied from interface: DruidLeaderSelector
      Implementation would increment it everytime it becomes leader. This allows users to start a long running task when they become leader and be able to intermittently check that they are still leader from same term when they started. DruidCoordinator class uses it to do intermittent checks and stop the activity as needed.
      Specified by:
      localTerm in interface DruidLeaderSelector
    • registerListener

      public void registerListener(DruidLeaderSelector.Listener listener)
      Description copied from interface: DruidLeaderSelector
      Register the listener for watching leadership notifications. It should only be called once.
      Specified by:
      registerListener in interface DruidLeaderSelector
    • unregisterListener

      public void unregisterListener()
      Description copied from interface: DruidLeaderSelector
      Unregisters the listener.
      Specified by:
      unregisterListener in interface DruidLeaderSelector