Say I have one Java program running on machine A, now I want to interrupt it, save its context and resume its execution on machine B. Is it possible to do that? How?
-
1Just copy the class file to another machine. – Sudhanshu Umalkar Apr 09 '13 at 04:22
-
2what exactly do yo umean by "migrate" - do you just want to copy the apllication (you might need to shut it down) and start the copy up on a different machine, or are you talking about something like vmware vmotion ? – radai Apr 09 '13 at 04:24
-
Hi @radai , sorry about making it confusing in the first place. Yes, I mean some thing like VMWare VMotion. – Shen Li Apr 09 '13 at 04:33
-
1@Sudhanshu Will that save state? – user93353 Apr 09 '13 at 04:33
-
Hi @user93353, thx, I am reading that post. – Shen Li Apr 09 '13 at 04:35
2 Answers
no, there's no good way to "freeze" a process and "revive" it on a separate machine, the process might be holding all sorts of state (open files/sockets etc) that you cant move with it.
if its an application youre writing its better to make it clusterable and then just start up another node on the target machine, wait for those 2 nodes to sync and shut fown your original node.
if its not an application youre writing or the above is too much, run your application inside a VM and use the VM's capabilities to migrate the entire VM with the running app in it (so, just use vmotion).

- 23,949
- 10
- 71
- 115
You might try something like this - the point at which you interrupt your program, just serialize all its properties / objects and also set a flag to indicate the point from where it can re-start executing. Now copy the serialized stuff to the other machine and start the program. Your code should be able to handle the conditions to correctly store (serialize) the state of your program and continue from that point whenever the class is started on another machine.

- 4,174
- 1
- 23
- 33