Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Searching for a way to take a "snapshot" of a java application

Reply
Thread Tools

Searching for a way to take a "snapshot" of a java application

 
 
Jack
Guest
Posts: n/a
 
      06-18-2008
Hi,
is there any way (jdk tools or commercial product) to take a "snapshot"
of a running java application, which can be used to restart a new
instance of the application, resuming the execution with the snapshot ?

Of course, i'm thinking about debugging...
 
Reply With Quote
 
 
 
 
mike.mainguy@gmail.com
Guest
Posts: n/a
 
      06-19-2008
On Jun 18, 6:55*am, Jack <(E-Mail Removed)> wrote:
> Hi,
> is there any way (jdk tools or commercial product) to take a "snapshot"
> of a running java application, which can be used to restart a new
> instance of the application, resuming the execution with the snapshot ?
>
> Of course, i'm thinking about debugging...


Excellent question.
If you want a dump of all the current thread stacks and everything in
memory, yes, I know this can be done in IBM's J9 for sure, I'm not
sure about Sun or JRocket (although I suspect it can or can easily be
implemented).

If you want to load all that into another JVM and begin where you left
off.... that's a great idea, but I've never tried it or put much
thought into it. I can't think of any technical reasons why it can't
be done (certainly with virtualization software it's "easy") and
honestly I'm not sure why this isn't something people do on a
recurring basis. I may have to spend some time looking into this
because it seems plausible and I'm not sure why spending 15 minutes
building up a test scenario is acceptable if we could instantly
restart from a specific state in the JVM.

Of course if you have external dependencies (database, etc.) it might
make the problem more complicated than it seems on the surface.
s
 
Reply With Quote
 
 
 
 
Jack
Guest
Posts: n/a
 
      06-19-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) a écrit :
> On Jun 18, 6:55 am, Jack <(E-Mail Removed)> wrote:
>> Hi,
>> is there any way (jdk tools or commercial product) to take a "snapshot"
>> of a running java application, which can be used to restart a new
>> instance of the application, resuming the execution with the snapshot ?
>>
>> Of course, i'm thinking about debugging...

>
> Excellent question.
> If you want a dump of all the current thread stacks and everything in
> memory, yes, I know this can be done in IBM's J9 for sure, I'm not
> sure about Sun or JRocket (although I suspect it can or can easily be
> implemented).


J9 seems to be only for pda.

> If you want to load all that into another JVM and begin where you left
> off.... that's a great idea, but I've never tried it or put much
> thought into it. I can't think of any technical reasons why it can't
> be done (certainly with virtualization software it's "easy") and
> honestly I'm not sure why this isn't something people do on a
> recurring basis. I may have to spend some time looking into this
> because it seems plausible and I'm not sure why spending 15 minutes
> building up a test scenario is acceptable if we could instantly
> restart from a specific state in the JVM.


I agree. And it can be done in C with core dumps and gdb i think, so why
not Java ?
 
Reply With Quote
 
Jack
Guest
Posts: n/a
 
      06-19-2008
(E-Mail Removed) a écrit :
> On Jun 18, 6:55 am, Jack <(E-Mail Removed)> wrote:
>> Hi,
>> is there any way (jdk tools or commercial product) to take a "snapshot"
>> of a running java application, which can be used to restart a new
>> instance of the application, resuming the execution with the snapshot ?
>>
>> Of course, i'm thinking about debugging...

>
> Excellent question.
> If you want a dump of all the current thread stacks and everything in
> memory, yes, I know this can be done in IBM's J9 for sure, I'm not
> sure about Sun or JRocket (although I suspect it can or can easily be
> implemented).


from JRockit docs:
http://edocs.bea.com/jrockit/jrdocs/refman/intro.html

There is no way to save the runtime state of a running java application.
 
Reply With Quote
 
Owen Jacobson
Guest
Posts: n/a
 
      06-19-2008
On Jun 18, 7:55*am, Jack <(E-Mail Removed)> wrote:
> Hi,
> is there any way (jdk tools or commercial product) to take a "snapshot"
> of a running java application, which can be used to restart a new
> instance of the application, resuming the execution with the snapshot ?
>
> Of course, i'm thinking about debugging...


Snapshotting and resurrecting a process is theoretically possible, but
it's fraught with peril. An application restored from a snapshot
would discover that all of its file handles, native GUI objects,
network connections, transactional state, and any other external state
it had established had suddenly disappeared. In theory this can
happen during normal operation, but in practice it's very rare for a
program to be prepared for it.

-o
 
Reply With Quote
 
Jack
Guest
Posts: n/a
 
      06-20-2008
Tim Smith a écrit :
> In article <485a1374$0$855$(E-Mail Removed)>,
> Jack <(E-Mail Removed)> wrote:
>>> If you want to load all that into another JVM and begin where you left
>>> off.... that's a great idea, but I've never tried it or put much
>>> thought into it. I can't think of any technical reasons why it can't
>>> be done (certainly with virtualization software it's "easy") and
>>> honestly I'm not sure why this isn't something people do on a
>>> recurring basis. I may have to spend some time looking into this
>>> because it seems plausible and I'm not sure why spending 15 minutes
>>> building up a test scenario is acceptable if we could instantly
>>> restart from a specific state in the JVM.

>> I agree. And it can be done in C with core dumps and gdb i think, so why
>> not Java ?

>
> What about state that isn't stored in the program, such as what your
> input and output streams are connected to? Say I run a Java program:
>
> java MyProgram > output.txt
>
> If that is reloaded from a snapshot, how will the reloader know to
> connect the output back up to output.txt?
>
> Even trickier...suppose I'm using Java to write a console application
> that plays around with terminal modes. It has just moved the cursor to
> a specific line in the middle of the screen, and output the sequence
> that switches the terminal to inverse video. A snapshot is taken.
>
> When it is reloaded, how will the reloader know how to restore the
> terminal state?
>
> These are the things that make this kind of thing hard in general. You
> have to (if you want to do a thorough job) have some OS-specific code
> that can go and enumerate all the files and devices the program has
> open, and record their current state, and the snapshot loader has to be
> able to restore things from that, if possible.
>
> If you were asking about a more general purpose language, like C or
> Perl, rather than Java, then I'd also be pointing out things like
> semaphores. If the program has a semaphore, and has used it to acquire
> ownership of a resource, the snapshot loader had better be able to
> acquire ownership of that resource before resuming the program. (This
> is probably not a problem in Java, because Java programs tend to only
> worry about synchronization issues with other code running in the JVM,
> so tend to not have native system semaphores to worry about. However,
> if I'm wrong about that, and there is a way to access native semaphores
> reasonably in Java, then this would be an issue for a Java snapshot
> system).
>
> I almost forgot databases. What if the program has an open connection
> to a database, and is in the middle of a transaction. The snapshot
> taker will have to roll back the transaction (well, that will probably
> happen automatically if the connection is closed after the snapshot is
> taken). The snapshot loader would need to reconnect to the database,
> begin the transaction, and issue the statements that are supposed to
> have already been issued up to that point in the transaction.


Databases was mentioned before, but you are right. You think about a
generic snapshot tools wich would do all the work alone, but it can't be
done. Of course, the application would need to be designed to support
that feature. If you have tried to close some threads of ICQ (IIRC),
they are re-created, so some application are designed to be robusts.

But anyway it doesn't exist yet...

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      06-20-2008
On Wed, 18 Jun 2008 13:55:04 +0200, Jack <(E-Mail Removed)> wrote,
quoted or indirectly quoted someone who said :

>is there any way (jdk tools or commercial product) to take a "snapshot"
>of a running java application, which can be used to restart a new
>instance of the application, resuming the execution with the snapshot ?


this is what I call "gespenstering" I implemented it for BBL Forth
and Abundance.

Basically you create a ram image. The catch is how to create the
relocatable tables so that if the program is reloaded somewhere else,
it will be appropriately adjusted.

To implement it in Java would require the careful co-operation of the
writers of the JVM.

see http://mindprod.com/jgloss/gespenstering.html

I did this back in the DOS days when TSRs made your load address
unstable. You might implement it today by just giving up if the load
address changes.

Saving the RAW ram image could be done with a bit of JNI and some
knowledge of the inner workings so you know what sections of RAM to
save. You then have to build an exe header.

I also implemented Jaunting (where I take stack snapshots). By
restoring the stack state, I can make a program jump backward in time
and pick up where it left off at some previous snapshot.

You would need in intimate knowledge of the JVM to pull this off.

However the difficult part implementing it for the JVM would be
reopening files that were open at the time of the snapshot, including
restoring the state (possibly even including OS buffers).

You might do gesperstering where it is not totally transparent to the
app. You leave it up to the app to close all files on snap and
reopen/restore them on restart.

I called for this as a way of creating instant start apps for Java.
See http://mindprod.com/project/gespenster.html

The closest I have seen was a now defunct Lotus project called Ensuite
that used serialisation to snap/restore system state.

The JET people are sneaking up on this. The latest release 6.4 in a
way simulates restoring a snapshot of the app just after it has
started. This allows programs to start as quickly as C++ programs.
see http://mindprod.com/jgloss/jet.html


--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
ldv@mail.com
Guest
Posts: n/a
 
      06-26-2008
On Jun 18, 6:55 pm, Jack <(E-Mail Removed)> wrote:
> Hi,
> is there any way (jdk tools or commercial product) to take a "snapshot"
> of a runningjavaapplication, which can be used to restart a new
> instance of the application, resuming the execution with the snapshot ?
>
> Of course, i'm thinking about debugging...


This is not possible in the general case, because the application may
depend on external resources (files, network connections) that may
become unavailable or change state upon resume, and events (user
input, network traffic). Say, you have a real-time network traffic
analyzer and took a snapshot of you app before it crashed. Unless you
can replay the network traffic, you may be unable to reproduce the
crash.

Otherwise, have a look at Replay Solutions (http://
www.replaysolutions.com/)

HTH,

LDV
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a way to take a picture on my smartphone via the WEB application. Mr. X. HTML 0 01-11-2013 11:48 AM
Google search result to be URL-limited when searching site, but notwhen searching Web stumblng.tumblr Javascript 1 02-04-2008 09:01 AM
Do I have to take 292 & 296 can I take the 4 cores instead? =?Utf-8?B?SmltIEhvbGxvd2F5?= Microsoft Certification 6 06-02-2007 02:12 AM
Take a slow ride....take it eeee-zy ellis_jay Computer Support 0 08-25-2005 01:31 AM
Re: Doesn't Take Much To Take Over A Group Soapy Digital Photography 59 09-13-2004 05:55 AM



Advertisments