Repository navigation
Commit 07fb4e3
feat: virtual thread support (#3664)
Add the useVirtualThreads flag (ConfigurationServiceOverrider.
withUseVirtualThreads, josdk.use-virtual-threads) that runs the
framework's concurrent work on virtual threads. It is off by default
and only supported on Java 25 or later (JEP 491); on an older JVM a
warning is logged and platform threads are used.
With the flag on:
- reconciliations and dependent workflows run on virtual threads, still
capped by concurrentReconciliationThreads and
concurrentWorkflowExecutorThreads
- the caching executor used for internal housekeeping uses a virtual
thread per task
- the Kubernetes client created by the framework runs its internal task
executor on virtual threads, a provided client is used as is
- scheduled tasks run on virtual threads through the new
VirtualThreadScheduledExecutor, a daemon timing thread firing each
task on a virtual thread, with the semantics of the platform default
(waiting and periodic tasks discarded on shutdown, running tasks let
finish, fixed rate tasks catch up after an overrun)
Scheduled work no longer relies on java.util.Timer:
- PollingEventSource and PerResourcePollingEventSource poll on an
executor of their own, provided through the configuration builder or
created, and shut down, by the event source, on virtual threads when
the flag is on. A provided executor is never shut down by the source.
They can be started again after a stop, and a poll in flight is not
interrupted by it.
- PerResourcePollingEventSource registers the resources of the primary
cache when it starts, drops the result of a poll of a previous run,
and forgets the registration of a resource that is gone from the
cache so that it is polled again if recreated
- TimerEventSource schedules on the retry and reschedule executor
managed by ExecutorServiceManager, see
ConfigurationService.getRetryAndRescheduleExecutorService and
concurrentRetryAndRescheduleThreads. Timers pending on an executor the
operator replaced are not scheduled again.
- the default pools use daemon threads, discard delayed tasks on
shutdown and let idle threads time out
Behavior and API changes, described in the v5.7 migration guide:
- an executor provided to PerResourcePollingConfigurationBuilder is not
shut down by the event source anymore, and the configuration returns
a null executor when none was provided
- PollingEventSource(Class, PollingConfiguration), the
TimerEventSource(String, boolean) constructor and
ExecutorServiceManager.scheduledExecutorService() are deprecated
- ConfigurationServiceOverrider rebuilds the default retry executor when
the flag or its thread count changes, a custom executor of the wrapped
configuration is then replaced, see the Javadoc
Also: configuration keys in ConfigLoader, documentation (Virtual
Threads, polling event source threading, migration guide), the webpage
and mysql-schema samples run with virtual threads, VirtualThreadsIT,
and a spotbugs exclusion for the scheduled executor handles.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>1 parent 6558161 commit 07fb4e3
41 files changed
Lines changed: 3411 additions & 101 deletions
File tree
- docs/content/en/docs
- documentation
- operations
- migration
- operator-framework-core/src
- main/java/io/javaoperatorsdk/operator
- api/config
- processing
- dependent/external
- event
- source
- polling
- timer
- test/java/io/javaoperatorsdk/operator
- api/config
- processing/event/source
- polling
- timer
- operator-framework/src
- main/java/io/javaoperatorsdk/operator/config/loader
- test/java/io/javaoperatorsdk/operator
- baseapi/virtualthreads
- config/loader
- dependent/multiplemanagedexternaldependenttype
- sample-operators
- mysql-schema/src
- main/java/io/javaoperatorsdk/operator/sample
- test/java/io/javaoperatorsdk/operator/sample
- webpage/src
- main/java/io/javaoperatorsdk/operator/sample
- test/java/io/javaoperatorsdk/operator/sample
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
225 | 256 | | |
226 | 257 | | |
227 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
26 | 80 | | |
27 | 81 | | |
28 | 82 | | |
| |||
285 | 339 | | |
286 | 340 | | |
287 | 341 | | |
| 342 | + | |
288 | 343 | | |
289 | 344 | | |
290 | 345 | | |
| |||
301 | 356 | | |
302 | 357 | | |
303 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
304 | 365 | | |
305 | 366 | | |
306 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments