experimental java binding to criu currently using project panama.
public static void main(String[] args) throws IOException {
try(CRIUContext criu = CRIUContext.create()
.logFile("criu.log").logLevel(INFO).tcpEstablished(false).leaveRunning(false)) {
Path path = Paths.get("/tmp/freezer");
if(!Files.exists(path))
Files.createDirectory(path);
System.out.println("pre checkpoint pid: "+ProcessHandle.current().pid());
criu.checkpoint(path);
System.out.println("post checkpoint/restore pid: "+ProcessHandle.current().pid());
}
}
- run above program (currently requires root permissions, but will hopefully change with CAP_CHECKPOINT_RESTORE)
$ sudo jdk-19-panama+1-13/bin/java -XX:-UsePerfData -Xmx42m -XX:+UseSerialGC\
--enable-preview --add-modules jdk.incubator.foreign --enable-native-access=ALL-UNNAMED\
-cp test.jar:JCRIU-x.x-SNAPSHOT.jar foo.Test
WARNING: Using incubator modules: jdk.incubator.foreign
pre checkpoint pid: 8845
- restore from checkpoint
$ sudo criu restore --shell-job -D /tmp/freezer/
post checkpoint/restore pid: 8845
- run download-criu-header.sh once
- build project with 'mvn clean install' or your fav. IDE
- early access Java 19 panama build
- criu installed
- recent linux kernel (e.g 5.10+) (if you experience 100% CPU usage after restore, try a different kernel)
This project is distributed under the MIT License, see LICENSE file.