java.lang.Object
io.fabric8.kubernetes.client.extended.leaderelection.LeaderElector<C>

public class LeaderElector<C extends Namespaceable<C> & KubernetesClient>
extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • run

      public void run()
      Starts the leader election loop
    • isLeader

      protected final boolean isLeader​(LeaderElectionRecord leaderElectionRecord)
    • canBecomeLeader

      protected final boolean canBecomeLeader​(LeaderElectionRecord leaderElectionRecord)
    • loop

      protected static boolean loop​(Consumer<CountDownLatch> consumer, long periodInMillis)
      Periodically (every provided period) runs the provided Consumer in a separate thread causing the current thread to wait until the supplied CountDownLatch is decremented by 1 unit.
      Parameters:
      consumer - function to run in a separate thread
      periodInMillis - to schedule the run of the provided consumer
      Returns:
      true if the current thread was not interrupted, false otherwise
    • now

      protected static ZonedDateTime now()
    • jitter

      protected static Duration jitter​(Duration duration, double maxFactor)
      Returns a Duration between the provided duration and (duration + maxFactor*duration)
      Parameters:
      duration - to apply jitter to
      maxFactor - for jitter
      Returns:
      the jittered duration