Thomas Huining Feng  

Contents

What's SVMDCP?

Demo 1: Rolling Back a Statechart Model

Demo 2: Rolling Back Ptolemy Simulation

Using SVMDCP

The Future


What's SVMDCP?

SVMDCP (SVM Distributed CheckPointing) is a library that uses aspect-oriented techniques to add distributed checkpointing and rollback support to existing Java sources. It is a sub-project of SVM (Statechart Virtual Machine), but it can also be used in other projects, especially projects of simulation environments, which usually require to roll back a simulation in case of time conflict or error.

Note that the checkpointing implemented in SVMDCP is incremental. This means nothing is done at the time of creating a checkpoint, except that a new checkpoint ID is allocated. Every subsequence change to the objects in the memory is recorded in a static list local to each class. When rollback is requested, the system undoes these changed by restoring the old value of all the affected attributes. Hence, checkpointing is cheap and a user can create a large number of checkpoints, while only roll back to some of them when necessary. This is most important for distributed simulation.

There is a subproject of SVMDCP: the Net Layers. This subproject implements asynchronous calls and synchronous calls on top of multiple network technologies. With these technologies, distributed checkpointing becomes highly flexible.

SVMDCP is not a stand-alone project. It might be used and shipped with any other project, such as SVM and SCC, and other Java-based simulation environments, on the basis that the GNU GPL (General Public License) Version 2 is satisfied.

A related sub-project of SVM and SCC is Timewarp. It deals with the global time management in distributed simulation, on the basis that a certain rollback mechanism is provided, such as SVMDCP or object serialization.

Demo 1: Rolling Back a Statechart Model

In fact, it's much easier to tell you "what SVMDCP is" by showing you a couple of life examples. In the following applet, you're invited to test the rollback support in a statechart model, automatically generated by SCC (StateChart Compiler).

This is an enhanced version of the online demo shown on the SCC homepage. The only difference is that rollback is supported in this model. You can take a number of checkpoints by clicking on the "check" button. Each time a new checkpoint ID will be allocated and added to the list above the button. Double-clicking on any one of the numbers will roll back the model to that previous checkpoint.

This is a plain text file describing all the requirements and how I build this applet with SVM and SVMDCP in steps.

Demo 2: Rolling Back Ptolemy Simulation

The reader might not have been convinced that SVMDCP is a general-purpose tool that adds rollback support to any Java source code. Here is another example. Simulation in Ptolemy II (a heterogeneous simulation environment developed by Edward A. Lee at EECS Berkeley) can be rolled back:

Expression simulation without DCP support

Expression simulation with DCP support
(words "checkpoint" and "rollback" are added by hand)

Note that the Ptolemy source is automatically parsed and aspects are generated for every attribute of the parsed classes. The code writer need not be aware of this. Nor does she need to tell the modifier, me, anything related to the code design. Everything is done automatically and magically.

Since everyone can do this with SVMDCP, the reader is invited to try out this approach. Let's roll back Ptolemy! (Just a joke.) The following is a general description, while detailed requirements and instructions are in this text file.

This work is done on the Expression demo that comes with Ptolemy II. To add aspects to it, the reader must first download the source-only version of Ptolemy II and compile it with JDK 1.4. (Refer to the installation manual.) If this step is not successful, there will be no hope of passing the compilation after adding aspects. (Unfortunately, due to some bugs in AspectJ 1.1, the contrary is not true.) After successful making, Ptolemy can be started with the "vergil" script in "ptII3.0.2/bin/".

Very few actors are involved in the Expression demo, but it's not trivial to find out all their dependencies. I.e., adding aspects to class A only will not sucessfully roll back an instance of A, because it inherits members from A's superclasses. Some other instance might directly change attributes of this one without calling its method. So the types of its fields must also be analyzed. And so on ... As a result, the files listed in aspects.new.lst are picked out, which the Expression demo depends on.

In the future, it is possible to have this job done automatically by a program.

With this list, the reader is thus able to process the relevant files with DCPGenerator, a tool of SVMDCP, which takes Java source file as input, and sends SVMDCPed Java source code as output.

The vergil interface must also be changed, otherwise the reader has no way to control checkpointing and rollback in Ptolemy. A slightly modified VergilApplication.java (in path "ptII3.0.2/ptolemy/vergil/") is available here. Now when vergil starts, the user can input their commands in the console after the "DCP >" prompt.

The only accepted commands are "cp", "rb [num]" and "exit". Use "cp" to checkpoint the current status. A number will be displayed in the next line, which is the allocated checkpoint ID (incremental integer). "rb [num]" rolls the model back to the checkpoint with the smallest ID which is equal to or larger than num. (As a special case, "rb 0" always rolls back to the first checkpoint.) "exit" forces Ptolemy to close. This is extremely useful for those who always like to open tons of windows and finally lose their the way out, such as me. :-)

Up to this point (to repeat, the listed files are processed by DCPGenerator and a new version of VergilApplication.java is copied to its place), another build will make the SVMDCPed Ptolemy. However, since the Java files are aspect-oriented, ajc (AspectJ Compiler) is required instead of the standard javac. One might make changes to the makefiles, but the easiest way is to locate the javac which makefiles are using, and simply replace it with a script that passes the input to ajc.

Now run vergil again and load the Expression demo ("Quick Tour" -> "Complete List", under SDF domain). Set "Animate Execution" in Debug menu to be 1. Start simulation but keep your eye on the console. When the line is being drawn, type "cp" and enter to the console. You will get 0, the first checkpoint ID. Later, use "rb 0" to roll the line back, and the part between the two points will be drawn again. This is how I get the above graph. (You can also make multiple checkpoints and roll back to any one of them.)

Another use is to roll back the parameters of actors. Close the plot window and checkpoint once. Now edit the attributes of some actors or change the notes to random text ... All will be restored to their old value if you roll back these changes. (As a side remark, the model designer herself is being modeled in this case.) However, no attempt has been made to checkpoint the relations. If you move the relations or add/remove some, you cannot roll them back to connect to the original ports. This is because relations are kept in LinkedList, a Java native class, which I am cannot add aspects to.

Using SVMDCP

SVMDCP can be downloaded from CVS. (Actually, this is the only form in which it is "officially" distributed.)

export CVS_RSH="ssh"                                             
cvs -z3 -d:ext:anoncvs@savannah.nongnu.org:/cvsroot/svm co svmdcp

Currently there are three tools to be used for aspect generation.

svmdcp.DescriptionGenerator.DescriptionGenerator, a tool to parse Java source files and find out all the classes and fields defined in it. An XML file is generated for each class, where the following things are recorded: the class name, the number of attributes and the name and type of each attribute. This file can be manually edited. One possible purpose to do this is to avoid checkpointing some attributes such as memory blocks and file handles.

svmdcp.AspectGenerator.AspectGenerator, a tool to add aspects to Java source code. It reads the XML files and determine aspect-oriented code for each class. This code automatically captures changes to the specified attributes, and inform the central checkpointing controller (svmdcp.Controller.dcp). It also roll backs all the modified attributes at a rollback. The output is new Java source code with these aspects added (one file for each class).

svmdcp.DCPGenerator.DCPGenerator, a tool to do the above tasks in one step. It takes Java source as input and generate new source file, with aspects added to it. Instead of generate separate Java files, it adds aspects to the end of the old ones.

The Future

This project can be used in a number of fields, including but not limited to software fault tolerance, modeling and simulation, and so on. Support for distributed checkpointing and rollback system will be added in the future, and class dependencies will be solved automatically with more tools. When this is done, the application of SVMDCP on an existing non-checkpointing project is 100% automatic and labor-free.

Suggestions and bug reports are sincerely welcomed! Please sent your comment to hfeng2@cs.mcgill.ca.


Maintained by Thomas Feng, Winter 2002