You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-cloud-kubernetes-leader/src/main/java/org/springframework/cloud/kubernetes/leader/LeadershipController.java
+34-4Lines changed: 34 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,21 @@ public LeadershipController(LeaderProperties leaderProperties, KubernetesHelper
47
47
this.leaderEventPublisher = leaderEventPublisher;
48
48
}
49
49
50
+
/**
51
+
* Acquire leadership for the requested candidate, if there is no existing leader or existing leader is not valid.
52
+
* <p>
53
+
* If leadership is successfully acquired {@code true} will be returned, {@link Candidate#onGranted(Context)}
54
+
* invoked and {@link LeaderEventPublisher#publishOnGranted(Object, Context, String)} event emitted.
55
+
* <p>
56
+
* If requested candidate is already a leader, simply {@code true} will be returned.
57
+
* <p>
58
+
* If for some reason leadership cannot be acquired (communication failure or there is another leader),
59
+
* {@code false} will be returned and {@link LeaderEventPublisher#publishOnFailedToAcquire(Object, Context, String)}
60
+
* event will be emitted.
61
+
*
62
+
* @param candidate
63
+
* @return {@code true} if at the end of execution candidate is a leader and {@code false} if it isn't.
Copy file name to clipboardExpand all lines: spring-cloud-kubernetes-leader/src/test/java/org/springframework/cloud/kubernetes/leader/LeadershipControllerTest.java
0 commit comments