Skip to content

Commit b7e0d5d

Browse files
authored
Merge pull request #2315 from srvaroa/master
leader elector: improve javadocs
2 parents 333482a + 41de870 commit b7e0d5d

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

extended/src/main/java/io/kubernetes/client/extended/leaderelection/LeaderElector.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,22 @@ public LeaderElector(LeaderElectionConfig config, Consumer<Throwable> exceptionH
107107
}
108108

109109
/**
110-
* Runs the leader election in foreground.
110+
* Runs the leader election in foreground. The process will enter an
111+
* acquisition loop trying to get a lease of the lock object set in
112+
* configuration. The acquisition loop stops in either of these
113+
* scenarios:
114+
*
115+
* 1) An error occurs that prevents us from aquiring a lease.
116+
*
117+
* 2) The LeaderElector successfully acquires leadership. At this
118+
* point, we will enter a renewal loop where we will continuously
119+
* renew the lease following the provided configuration.
120+
*
121+
* Note that in both cases the LeaderElector will NOT return to the
122+
* acquisition loop. This is most relevant when a leader instance
123+
* loses leadership as the LeaderElector will not try to re-acquire
124+
* leadership. To do this, the caller is responsible for explicitly
125+
* invoking the "run" method again.
111126
*
112127
* @param startLeadingHook called when a LeaderElector client starts leading
113128
* @param stopLeadingHook called when a LeaderElector client stops leading
@@ -117,7 +132,22 @@ public void run(Runnable startLeadingHook, Runnable stopLeadingHook) {
117132
}
118133

119134
/**
120-
* Runs the leader election in foreground.
135+
* Runs the leader election in foreground. The process will enter an
136+
* acquisition loop trying to get a lease of the lock object set in
137+
* configuration. The acquisition loop stops in either of these
138+
* scenarios:
139+
*
140+
* 1) An error occurs that prevents us from aquiring a lease.
141+
*
142+
* 2) The LeaderElector successfully acquires leadership. At this
143+
* point, we will enter a renewal loop where we will continuously
144+
* renew the lease following the provided configuration.
145+
*
146+
* Note that in both cases the LeaderElector will NOT return to the
147+
* acquisition loop. This is most relevant when a leader instance
148+
* loses leadership as the LeaderElector will not try to re-acquire
149+
* leadership. To do this, the caller is responsible for explicitly
150+
* invoking the "run" method again.
121151
*
122152
* @param startLeadingHook called when a LeaderElector client starts leading
123153
* @param stopLeadingHook called when a LeaderElector client stops leading

0 commit comments

Comments
 (0)