16
16
17
17
package org .springframework .context .support ;
18
18
19
+ import java .time .Duration ;
19
20
import java .util .ArrayList ;
20
21
import java .util .Collections ;
21
22
import java .util .Comparator ;
54
55
* <p>Provides interaction with {@link Lifecycle} and {@link SmartLifecycle} beans in
55
56
* groups for specific phases, on startup/shutdown as well as for explicit start/stop
56
57
* interactions on a {@link org.springframework.context.ConfigurableApplicationContext}.
57
- * As of 6.1, this also includes support for JVM snapshot checkpoints (Project CRaC).
58
+ * As of 6.1, this also includes support for JVM checkpoint/restore (Project CRaC).
58
59
*
59
60
* @author Mark Fisher
60
61
* @author Juergen Hoeller
@@ -456,7 +457,7 @@ private record LifecycleGroupMember(String name, Lifecycle bean) {}
456
457
private class CracDelegate {
457
458
458
459
public Object registerResource () {
459
- logger .debug ("Registering JVM snapshot callback for Spring-managed lifecycle beans" );
460
+ logger .debug ("Registering JVM checkpoint/restore callback for Spring-managed lifecycle beans" );
460
461
CracResourceAdapter resourceAdapter = new CracResourceAdapter ();
461
462
org .crac .Core .getGlobalContext ().register (resourceAdapter );
462
463
return resourceAdapter ;
@@ -466,7 +467,7 @@ public Object registerResource() {
466
467
467
468
/**
468
469
* Resource adapter for Project CRaC, triggering a stop-and-restart cycle
469
- * for Spring-managed lifecycle beans around a JVM snapshot checkpoint.
470
+ * for Spring-managed lifecycle beans around a JVM checkpoint/restore .
470
471
* @since 6.1
471
472
* @see #stopForRestart()
472
473
* @see #restartAfterStop()
@@ -491,18 +492,21 @@ public void beforeCheckpoint(org.crac.Context<? extends org.crac.Resource> conte
491
492
thread .start ();
492
493
awaitPreventShutdownBarrier ();
493
494
494
- logger .debug ("Stopping Spring-managed lifecycle beans before JVM snapshot checkpoint" );
495
+ logger .debug ("Stopping Spring-managed lifecycle beans before JVM checkpoint" );
495
496
stopForRestart ();
496
497
}
497
498
498
499
@ Override
499
500
public void afterRestore (org .crac .Context <? extends org .crac .Resource > context ) {
500
- logger .debug ("Restarting Spring-managed lifecycle beans after JVM snapshot restore" );
501
+ long restartTime = System .nanoTime ();
502
+ logger .debug ("Restarting Spring-managed lifecycle beans after JVM restore" );
501
503
restartAfterStop ();
502
504
503
505
// Barrier for prevent-shutdown thread not needed anymore
504
- awaitPreventShutdownBarrier ();
505
506
this .barrier = null ;
507
+
508
+ Duration timeTakenToRestart = Duration .ofNanos (System .nanoTime () - restartTime );
509
+ logger .debug ("Restart complete in " + timeTakenToRestart .toMillis () + " ms" );
506
510
}
507
511
508
512
private void awaitPreventShutdownBarrier () {
0 commit comments