|
|
|
@ -714,14 +714,8 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private class CracResourceAdapter implements org.crac.Resource { |
|
|
|
private class CracResourceAdapter implements org.crac.Resource { |
|
|
|
|
|
|
|
|
|
|
|
private CyclicBarrier stepToRestore = new CyclicBarrier(2); |
|
|
|
private final CyclicBarrier beforeCheckpointBarrier = new CyclicBarrier(2); |
|
|
|
private CyclicBarrier finishRestore = new CyclicBarrier(2); |
|
|
|
private final CyclicBarrier afterRestoreBarrier = new CyclicBarrier(2); |
|
|
|
|
|
|
|
|
|
|
|
private void preventShutdown() { |
|
|
|
|
|
|
|
waitBarrier(this.stepToRestore); |
|
|
|
|
|
|
|
// Checkpoint happens here
|
|
|
|
|
|
|
|
waitBarrier(this.finishRestore); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void beforeCheckpoint(org.crac.Context<? extends org.crac.Resource> context) { |
|
|
|
public void beforeCheckpoint(org.crac.Context<? extends org.crac.Resource> context) { |
|
|
|
@ -733,26 +727,22 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor |
|
|
|
stopForRestart(); |
|
|
|
stopForRestart(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void preventShutdown() { |
|
|
|
|
|
|
|
awaitBarrier(this.beforeCheckpointBarrier); |
|
|
|
|
|
|
|
// Checkpoint happens here
|
|
|
|
|
|
|
|
awaitBarrier(this.afterRestoreBarrier); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void afterRestore(org.crac.Context<? extends org.crac.Resource> context) { |
|
|
|
public void afterRestore(org.crac.Context<? extends org.crac.Resource> context) { |
|
|
|
// Unlock barrier for beforeCheckpoint
|
|
|
|
// Unlock barrier for beforeCheckpoint
|
|
|
|
try { |
|
|
|
awaitBarrier(this.beforeCheckpointBarrier); |
|
|
|
this.stepToRestore.await(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception ex) { |
|
|
|
|
|
|
|
logger.trace("Exception from stepToRestore barrier", ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.info("Restarting Spring-managed lifecycle beans after JVM restore"); |
|
|
|
logger.info("Restarting Spring-managed lifecycle beans after JVM restore"); |
|
|
|
restartAfterStop(); |
|
|
|
restartAfterStop(); |
|
|
|
|
|
|
|
|
|
|
|
// Unlock barrier for afterRestore to shutdown "prevent-shutdown" thread
|
|
|
|
// Unlock barrier for afterRestore to shutdown "prevent-shutdown" thread
|
|
|
|
try { |
|
|
|
awaitBarrier(this.afterRestoreBarrier); |
|
|
|
this.finishRestore.await(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception ex) { |
|
|
|
|
|
|
|
logger.trace("Exception from stepToRestore barrier", ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!checkpointOnRefresh) { |
|
|
|
if (!checkpointOnRefresh) { |
|
|
|
logger.info("Spring-managed lifecycle restart completed (restored JVM running for " + |
|
|
|
logger.info("Spring-managed lifecycle restart completed (restored JVM running for " + |
|
|
|
@ -760,12 +750,12 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void waitBarrier(CyclicBarrier barrier) { |
|
|
|
private void awaitBarrier(CyclicBarrier barrier) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
barrier.await(); |
|
|
|
barrier.await(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) { |
|
|
|
catch (Exception ex) { |
|
|
|
logger.trace("Exception from prevent-shutdown barrier", ex); |
|
|
|
logger.trace("Exception from barrier", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|