- Download a JDK with support for CRaC e.g.
- Unpack the tar.gz file and copy the JDK in a folder
sudo tar zxvf zulu21.30.19-ca-crac-jdk21.0.1-linux_x64.tar.gz
mv zulu21.30.19-ca-crac-jdk21.0.1-linux_x64 zulu-21.jdk
sudo mv zulu-21.jdk /usr/lib/jvm
- Set the $JAVA_HOME environment variable to the JDK with CRaC support e.g.
export JAVA_HOME=/usr/lib/jvm/zulu-21.jdk
- Make sure you have the permissions to run CRIU
sudo chown root:root $JAVA_HOME/lib/criu
sudo chmod u+s $JAVA_HOME/lib/criu
- Make sure you have the dependency to org.crac added to your build file
- gradle:
implementation 'org.crac:crac:1.4.0'
- maven :
<dependency>
<groupId>org.crac</groupId>
<artifactId>crac</artifactId>
<version>1.4.0</version>
</dependency>
- Open the project folder
- run
gradlew clean build
- Now you should find the the jar at
build/libs/spring-petclinic-3.2.0.jar
- Create a folder named
tmp_auto_checkpoint
in the project folder (besides thesrc
folder) - Create a folder named
tmp_manual_checkpoint
in the project folder (besides thesrc
folder)
- Start the application normally
bash start.sh
A checkpoint can also be compressed (only in Azul Zulu) on the hard drive by executing
export CRAC_CRIU_OPTS=--compress
It is already in the two shell scripts for starting up the app with the different options
- start-auto-crac.sh
- start-manual-crac.sh So you simply have to un-comment it in these shell scripts. Be aware that the compression at checkpoint and decompression at restoring will take longer. Meaning to say the restore will be slower when using a compressed checkpoint (on my machine used here it takes around 150ms to de-compress the checkpoint)
- Make sure the folder
tmp_auto_checkpoint
exists - Remove all files from the folder
tmp_auto_checkpoint
withrm ./tmp_auto_checkpoint/*.*
- Start the application and automatically create a checkpoint
bash start-auto-crac.sh
- Restore the application from the stored checkpoint
bash restore-auto-crac.sh
- Make sure the folder
tmp_manual_checkpoint
exists - Remove all files from the folder
tmp_manual_checkpoint
withrm ./tmp_manual_checkpoint/*.*
- Start the application
bash start-manual-crac.sh
There are two ways of creating the checkpoint manually, calling the application jar or the pid
- Calling the application jar
jcmd spring-petclinic-3.2.0.jar JDK.checkpoint
or
-
Executing the
create-manual-checkpoint.sh
script with the PID (can be found in the output in the 1st shell window)bash create-manual-checkpoint.sh PID
-
Check if the checkpoint files have been stored in
./tmp_manual_checkpoint
- Restore the application from the stored checkpoint by executing
bash restore-manual-crac.sh