Class CuratorDruidLeaderSelector
java.lang.Object
org.apache.druid.curator.discovery.CuratorDruidLeaderSelector
- All Implemented Interfaces:
DruidLeaderSelector
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.druid.discovery.DruidLeaderSelector
DruidLeaderSelector.Listener -
Constructor Summary
ConstructorsConstructorDescriptionCuratorDruidLeaderSelector(org.apache.curator.framework.CuratorFramework curator, DruidNode self, String latchPath) -
Method Summary
Modifier and TypeMethodDescriptionGet ID of current Leader.booleanisLeader()Returns true if this node is elected leader from underlying system's point of view.intImplementation would increment it everytime it becomes leader.voidregisterListener(DruidLeaderSelector.Listener listener) Register the listener for watching leadership notifications.voidUnregisters the listener.
-
Constructor Details
-
CuratorDruidLeaderSelector
-
-
Method Details
-
getCurrentLeader
Description copied from interface:DruidLeaderSelectorGet 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:
getCurrentLeaderin interfaceDruidLeaderSelector
-
isLeader
public boolean isLeader()Description copied from interface:DruidLeaderSelectorReturns 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:
isLeaderin interfaceDruidLeaderSelector
-
localTerm
public int localTerm()Description copied from interface:DruidLeaderSelectorImplementation 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:
localTermin interfaceDruidLeaderSelector
-
registerListener
Description copied from interface:DruidLeaderSelectorRegister the listener for watching leadership notifications. It should only be called once.- Specified by:
registerListenerin interfaceDruidLeaderSelector
-
unregisterListener
public void unregisterListener()Description copied from interface:DruidLeaderSelectorUnregisters the listener.- Specified by:
unregisterListenerin interfaceDruidLeaderSelector
-