-
Notifications
You must be signed in to change notification settings - Fork 1k
Fabric8 leader election (CAN ONLY GO IN THE NEXT MAJOR RELEASE) #1658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wind57
wants to merge
290
commits into
spring-cloud:main
Choose a base branch
from
wind57:fabric8-leader-election
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
290 commits
Select commit
Hold shift + click to select a range
39ef510
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 d389953
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 b676bac
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 b1473c9
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 83ff113
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 33dfbb7
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 316af58
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 425d30b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 763280a
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 3afbaef
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 cb97ba1
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 b33edc8
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 7a1fdf1
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 a8beed9
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 2e445d9
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 5b51db1
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 b0ce76c
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 918bb7f
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 c629951
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 ccfc0bf
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 0f3fa24
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 b60a283
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 901cb66
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 251002b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 fedeb17
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 004f95b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 10168be
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 dc811cf
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 3dfe77d
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 619c8d0
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 12ca211
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 a91c1e1
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 be2e809
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 1c84e33
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 1319fe7
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 9424c2e
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 cddd550
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 f8d34f2
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 31d2fb8
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 fa9fd09
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 22f3f51
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 bb44f4b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 9714f2c
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 0f9cb3d
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 6e60174
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 78c5575
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 5eb5c51
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 48f7cb0
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 8a18085
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 e4cab39
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 ba4cab0
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 bbc6e30
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 0e9f1ad
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 8a5243c
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 cbf83c4
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 3dd0260
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 1408d44
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 2925ee1
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 af3a12b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 f5a27dc
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 494454a
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 add0f67
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 b6a4b45
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 00a559d
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 882f9c1
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 6c9071e
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 09c10bb
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 3615396
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 116c199
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 f1447cd
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 14b165b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 3ce8fac
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 41eaa8d
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 4f89298
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 ee1031d
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 f6707d5
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 9930c7d
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 0043006
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 4e292ec
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 3129276
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 1c90fc2
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 fa0888a
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 ab680d1
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 4023ca3
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 7ed7f5d
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 3be81b7
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 dd710ec
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 4fdd06a
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 bf61054
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 f059697
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 013cc6a
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 13ff3b3
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 88021bb
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 dcf4e62
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 a600c69
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 3f1a180
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 85ca441
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 65acfe6
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 5526b50
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 0c131b5
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 af8a8ee
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 9c74e14
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 a410606
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 8c38ece
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 dcb8fb4
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 73e9765
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 1a3a4d9
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 926d2b0
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 02737d4
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 24defb8
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 14c9780
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 719ccbc
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 5784dfa
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 ecf13b8
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 658a5f6
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 4eb0e3c
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 256332d
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 d64dd18
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 2861ea5
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 9fffd36
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 a84bef6
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 a7000eb
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 219289f
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 ab12e1d
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 b32e8a0
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 2ddaca9
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 8ee9390
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 ad54a3f
dirty
wind57 bdf347b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 70d6a7c
Merge branch 'main' into fabric8-leader-election
wind57 f42a5ca
more changes
wind57 2e88bc4
fix test
wind57 83e4453
add one more log statement
wind57 2e6cfb3
add one more log statement
wind57 9683fad
add one more log statement
wind57 61904dd
enable pod namespace
wind57 aeb5f93
checkstyle
wind57 6dc82b5
add catch block
wind57 e3e6334
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 e8653ad
Merge branch 'main' into fabric8-leader-election
wind57 acb8550
more log statements
wind57 152f6bf
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 a279c0c
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 f6e608e
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 6a51e1a
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 a02efb2
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 fa8ca61
Merge branch 'main' into fabric8-leader-election
wind57 24dd2e4
merge main + review comments
wind57 5864ab1
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 d34806d
Merge branch 'main' into fabric8-leader-election
wind57 8acf002
add documentation
wind57 2ac6bdd
typo
wind57 fdddf41
typo
wind57 d872393
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 e690faf
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 f73667f
Merge branch 'main' into fabric8-leader-election
wind57 97010ab
review comments
wind57 f38ec53
more review comments
wind57 b178548
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 750a4fe
Merge branch 'main' into fabric8-leader-election
wind57 713824a
merge main + added logs
wind57 56d4b40
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 c298dfe
Merge branch 'main' into fabric8-leader-election
wind57 aa47ab7
review comments
wind57 554112b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 44389b2
Merge branch 'main' into fabric8-leader-election
wind57 8116a39
checkstyle
wind57 90176ef
remove un-used code
wind57 ae40722
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 af673ba
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 e3ca2f8
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 f96a8fa
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 2847f75
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 462e568
Merge branch 'main' into fabric8-leader-election
wind57 0893cc0
placeholder commit
wind57 ed78705
fix some comments
wind57 7468875
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 4405694
Merge branch 'main' into fabric8-leader-election
wind57 2f76b5d
fix some comments
wind57 f45d763
checkstyle
wind57 af56e7c
test fix
wind57 2b42942
remove exception
wind57 c416eea
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 99a0b08
Merge branch 'main' into fabric8-leader-election
wind57 7c5a312
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 ed2080b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 b87c349
Merge branch 'main' into fabric8-leader-election
wind57 8fe3240
fix test
wind57 0355d7a
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 5e157bc
Merge branch 'main' into fabric8-leader-election
wind57 bf0cc39
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 193aa2b
Merge branch 'main' into fabric8-leader-election
wind57 f342faf
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 391dcf2
Merge branch 'main' into fabric8-leader-election
wind57 a0756c6
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 86c7ec9
Merge branch 'main' into fabric8-leader-election
wind57 ca8edc0
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 ec6c27a
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 82a3764
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 e6bd5f6
Merge branch 'main' into fabric8-leader-election
wind57 e298352
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 ad6fb23
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 d3f6f59
Merge branch 'main' into fabric8-leader-election
wind57 eeeb62c
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 a2bae5b
Merge branch 'main' into fabric8-leader-election
wind57 dd24a07
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 f9a678c
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 2a14aeb
Merge branch 'main' into fabric8-leader-election
wind57 8459a2f
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 e0fcc7b
Merge branch 'main' into fabric8-leader-election
wind57 9ea81df
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 af81fbc
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 208afcd
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 8793be8
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 2f73f97
Merge branch 'main' into fabric8-leader-election
wind57 633c679
fix
wind57 abf452a
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 2ee0f11
Merge branch 'main' into fabric8-leader-election
wind57 9fe0159
Merge branch '3.1.x' into fabric8-leader-election
wind57 515309b
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 52108e5
Merge branch 'main' into fabric8-leader-election
wind57 fb15e40
minor changes before integration tests
wind57 361a6c5
checkstyle
wind57 91b1375
polishing
wind57 2fbe330
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 c7a7328
Merge branch 'main' into fabric8-leader-election
wind57 ee348f4
add tests
wind57 29af71d
review comments
wind57 ae9e340
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 48a6f53
Merge branch 'main' into fabric8-leader-election
wind57 3c45232
checkstyle
wind57 ae428bd
latest version
wind57 1dbd368
review comments
wind57 a0f3fc9
javadoc
wind57 5654479
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 1ab8402
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 fa4fe63
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 c4509c8
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 eb5f90c
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 63877a3
Merge branch 'main' into fabric8-leader-election
wind57 c33f20c
fix main imports
wind57 3708301
add tests
wind57 38b7186
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 504edc0
add common leader callbacks
wind57 f810686
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 71b8259
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 15810f5
Merge branch 'main' into fabric8-leader-election
wind57 1413504
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 8042f2a
Merge branch 'main' of https://github.com/spring-cloud/spring-cloud-k…
wind57 9356526
Merge branch 'main' into fabric8-leader-election
wind57 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...c/main/java/org/springframework/cloud/kubernetes/commons/CachedSingleThreadScheduler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright 2013-2025 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.cloud.kubernetes.commons; | ||
|
||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.ScheduledThreadPoolExecutor; | ||
import java.util.concurrent.ThreadFactory; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.locks.ReentrantLock; | ||
|
||
/** | ||
* This is taken from fabric8 with some minor changes (we need it, so it could be placed | ||
* in the common package). | ||
* | ||
* @author wind57 | ||
*/ | ||
public final class CachedSingleThreadScheduler { | ||
|
||
private final ReentrantLock lock = new ReentrantLock(); | ||
|
||
private final long ttlMillis; | ||
|
||
private ScheduledThreadPoolExecutor executor; | ||
|
||
public CachedSingleThreadScheduler(long ttlMillis) { | ||
this.ttlMillis = ttlMillis; | ||
} | ||
|
||
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) { | ||
try { | ||
lock.lock(); | ||
this.startExecutor(); | ||
return this.executor.scheduleWithFixedDelay(command, initialDelay, delay, unit); | ||
} | ||
finally { | ||
lock.unlock(); | ||
} | ||
} | ||
|
||
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { | ||
try { | ||
lock.lock(); | ||
this.startExecutor(); | ||
return this.executor.schedule(command, delay, unit); | ||
} | ||
finally { | ||
lock.unlock(); | ||
} | ||
} | ||
|
||
private void startExecutor() { | ||
if (this.executor == null) { | ||
this.executor = new ScheduledThreadPoolExecutor(1, threadFactory()); | ||
this.executor.setRemoveOnCancelPolicy(true); | ||
this.executor.scheduleWithFixedDelay(this::shutdownCheck, this.ttlMillis, this.ttlMillis, | ||
TimeUnit.MILLISECONDS); | ||
} | ||
|
||
} | ||
|
||
private void shutdownCheck() { | ||
try { | ||
lock.lock(); | ||
if (this.executor.getQueue().isEmpty()) { | ||
this.executor.shutdownNow(); | ||
this.executor = null; | ||
} | ||
} | ||
finally { | ||
lock.unlock(); | ||
} | ||
|
||
} | ||
|
||
private ThreadFactory threadFactory() { | ||
return new ThreadFactory() { | ||
ThreadFactory threadFactory = Executors.defaultThreadFactory(); | ||
|
||
@Override | ||
public Thread newThread(Runnable runnable) { | ||
Thread ret = threadFactory.newThread(runnable); | ||
ret.setName("fabric8-leader-election" + "-" + ret.getName()); | ||
ret.setDaemon(true); | ||
return ret; | ||
} | ||
}; | ||
} | ||
|
||
} |
79 changes: 79 additions & 0 deletions
79
...bernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/PodReady.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright 2013-2025 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.cloud.kubernetes.commons; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
import java.util.function.BooleanSupplier; | ||
|
||
import org.springframework.core.log.LogAccessor; | ||
|
||
/** | ||
* @author wind57 | ||
*/ | ||
public final class PodReady { | ||
ryanjbaxter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private static final LogAccessor LOG = new LogAccessor(PodReady.class); | ||
|
||
private final AtomicReference<ScheduledFuture<?>> podReadyTask = new AtomicReference<>(); | ||
|
||
private final CachedSingleThreadScheduler podReadyScheduler = new CachedSingleThreadScheduler( | ||
TimeUnit.SECONDS.toMillis(10)); | ||
|
||
/** | ||
* The resulting CompletableFuture is completed when pod is ready according to the | ||
* BooleanSupplier. You are supposed to properly get rid of this task, but calling the | ||
* other public method getPodReadyTask and cancel it, this will take care to shutdown | ||
* the executor it was running in. | ||
*/ | ||
public CompletableFuture<Void> podReady(BooleanSupplier isPodReady, String holderIdentity, String podNamespace) { | ||
|
||
CompletableFuture<Void> podReadyFuture = new CompletableFuture<>(); | ||
|
||
podReadyTask.set(podReadyScheduler.scheduleWithFixedDelay(() -> { | ||
|
||
try { | ||
LOG.info(() -> "waiting for pod : " + holderIdentity + " in namespace : " + podNamespace | ||
+ " to be ready"); | ||
if (isPodReady.getAsBoolean()) { | ||
LOG.info(() -> "Pod : " + holderIdentity + " in namespace : " + podNamespace + " is ready"); | ||
podReadyFuture.complete(null); | ||
} | ||
else { | ||
LOG.debug(() -> "Pod : " + holderIdentity + " in namespace : " + podNamespace + " is not ready, " | ||
+ "will retry in one second"); | ||
} | ||
} | ||
catch (Exception e) { | ||
LOG.error(() -> "exception waiting for pod : " + e.getMessage()); | ||
LOG.error(() -> "leader election for " + holderIdentity + " was not successful"); | ||
podReadyFuture.completeExceptionally(e); | ||
} | ||
|
||
}, 1, 1, TimeUnit.SECONDS)); | ||
|
||
return podReadyFuture; | ||
|
||
} | ||
|
||
public AtomicReference<ScheduledFuture<?>> getPodReadyTask() { | ||
return podReadyTask; | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,21 +16,43 @@ | |
|
||
package org.springframework.cloud.kubernetes.commons.leader; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
import java.util.concurrent.locks.ReentrantLock; | ||
|
||
import org.springframework.cloud.kubernetes.commons.EnvReader; | ||
import org.springframework.core.log.LogAccessor; | ||
import org.springframework.util.StringUtils; | ||
|
||
import static org.springframework.cloud.kubernetes.commons.KubernetesClientProperties.SERVICE_ACCOUNT_NAMESPACE_PATH; | ||
|
||
/** | ||
* @author wind57 | ||
*/ | ||
public final class LeaderUtils { | ||
|
||
/** | ||
* Prefix for all properties related to leader election. | ||
*/ | ||
public static final String LEADER_ELECTION_PROPERTY_PREFIX = "spring.cloud.kubernetes.leader.election"; | ||
|
||
/** | ||
* Property that controls whether leader election is enabled. | ||
*/ | ||
public static final String LEADER_ELECTION_ENABLED_PROPERTY = LEADER_ELECTION_PROPERTY_PREFIX + ".enabled"; | ||
|
||
private static final LogAccessor LOG = new LogAccessor(LeaderUtils.class); | ||
|
||
// k8s environment variable responsible for host name | ||
private static final String HOSTNAME = "HOSTNAME"; | ||
|
||
private static final String POD_NAMESPACE = "POD_NAMESPACE"; | ||
|
||
private LeaderUtils() { | ||
|
||
} | ||
|
@@ -45,6 +67,27 @@ public static String hostName() throws UnknownHostException { | |
} | ||
} | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to know in which namespace the pod is running, so that I could query it for readiness. |
||
* ideally, should always be present. If not, downward api must enable this one. | ||
*/ | ||
public static Optional<String> podNamespace() { | ||
Path serviceAccountPath = new File(SERVICE_ACCOUNT_NAMESPACE_PATH).toPath(); | ||
boolean serviceAccountNamespaceExists = Files.isRegularFile(serviceAccountPath); | ||
if (serviceAccountNamespaceExists) { | ||
try { | ||
String namespace = new String(Files.readAllBytes(serviceAccountPath)).replace(System.lineSeparator(), | ||
""); | ||
LOG.info(() -> "read namespace : " + namespace + " from service account " + serviceAccountPath); | ||
return Optional.of(namespace); | ||
} | ||
catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
} | ||
return Optional.ofNullable(EnvReader.getEnv(POD_NAMESPACE)); | ||
} | ||
|
||
public static void guarded(ReentrantLock lock, Runnable runnable) { | ||
try { | ||
lock.lock(); | ||
|
43 changes: 43 additions & 0 deletions
43
...amework/cloud/kubernetes/commons/leader/election/ConditionalOnLeaderElectionDisabled.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2013-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.cloud.kubernetes.commons.leader.election; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
|
||
import static org.springframework.cloud.kubernetes.commons.leader.LeaderUtils.LEADER_ELECTION_ENABLED_PROPERTY; | ||
|
||
/** | ||
* Provides a more succinct conditional for: | ||
* <code>spring.cloud.kubernetes.leader.election.enabled</code>. | ||
* | ||
* @author wind57 | ||
*/ | ||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Inherited | ||
@ConditionalOnProperty(value = LEADER_ELECTION_ENABLED_PROPERTY, matchIfMissing = true, havingValue = "false") | ||
public @interface ConditionalOnLeaderElectionDisabled { | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.