简体   繁体   中英

How do I save the state of a java program and pick it up later?

I am trying to run a java program that uses WEKA libraries on a cluster .

This cluster times out submitted jobs after 12 hours, and I can't change this fact because I am a student and not in charge of the cluster.

What I want to do is save the state of my JVM, and reload it. Basically close the program for a time, and pick up where I left off.

Is this possible?

I don't think I can (easily at least) output the state of the variables in the WEKA objects themselves to a file with OOS and reload them because I'm using the WEKA libraries, and it would be extremely complicated to rewrite the code for these machine learning programs. (though that might be what I have to do)

I tried using a library called javaflow that I thought from reading around might accomplish this, but I cannot get it to work. When try to do its counting example I am met with this error:

Apr 20, 2016 9:15:12 PM org.apache.commons.javaflow.bytecode.StackRecorder execute
SEVERE: stack corruption. Is class test_javaflow.MyRunnable instrumented for javaflow?
java.lang.IllegalStateException: stack corruption. Is class test_javaflow.MyRunnable instrumented for javaflow?
    at org.apache.commons.javaflow.bytecode.StackRecorder.execute(StackRecorder.java:102)
    at org.apache.commons.javaflow.Continuation.continueWith(Continuation.java:170)
    at org.apache.commons.javaflow.Continuation.startWith(Continuation.java:129)
    at org.apache.commons.javaflow.Continuation.startWith(Continuation.java:102)
    at test_javaflow.Test_Javaflow.main(Test_Javaflow.java:16)

Googling this error come up with a few pages relating to something called JasperSoft, which I'm fairly certain isn't what I'm looking for.

Have a look at docker's checkpoint command. It provides the ability to save the current state of a docker container and then resume it. I've been using it for a similar use - a JVM based system. In my case I use it because initialization takes a long time. By using a checkpoint I can restart the container at a known state multiple times.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM