GNU/EDMA Run-Time Class Install and Object Hot Swap

After a short pause this weekend I come back to GNU/EDMA. I'm working to produce a stable version and I will comment in this blog my unofficial progress. For official news check Savannah.

What I would like to show you is the object hot swap capabilities of the system. Such feature has been there for a while, but what is new, is that now the update scripts can be wrote in Python :). Check the image below

GNU/EDMA Hotwap with Python ScriptsGNU/EDMA Hotwap with Python Scripts

This is a brief description of what you can see in the image:

  • In the right console (the long one), a simple application that creates a HELLO_WORLD object and calls the say2 method for 5 times within a loop.
  • In the left side of the image you can see two instances of the GNU/EDMA Class Browser, showing the information related to version 1.0 (upper part) and version 2.0 (lower part) of class HELLO_WORLD. As you can see version 2.0 has two numeric properties, instead of 1 and the name of the string properties has been changed. This is a public interface change of the class.

If you check the console on the right, you'll notice that, in the middle of the execution the application output changes. That's the point when the new version of HELLO_WORLD has been installed using the standard command:

ines_class_register HELLO_WORLD_2_0.ines

where HELLO_WORLD_2_0.ines is the class deployment handler. For this example it looks like this:


The interesting part there is the UpdateScript field. This field informs the system about the update script to execute if any object in a given GNU/EDMA application needs to be hot swapped... and, in this case, we are using a Python script.

def update (a, b):
    print "----------------------------------------------------------";
    print "-- Pyhton Update Script-----------------------------------";
    print "-- HELLO_WORLD Class Version 2.0";
    print "-- Updating object ", a, "->", b;
    print "----------------------------------------------------------";
    num = edma.get_sint32 (b, "num");
    print "- Old Number value is ", num;
    num1 = num / 2;
    print "- New Number value is ", num1
    edma.set_sint32 (a, "num1", num1);
    edma.set_sint32 (a, "num2", num1);
    print "- Attaching '(Version 2.0' to string property"
    old_str = edma.get_strz (b, "str");
    old_str += " (Version 2.0)";
    edma.set_strz (a, "str_new", old_str);
    print "---[Object Updated] --------------------------------------";

The function receives two parameters, one is the reference to the object that has to be hot swapped and the other is a reference to the new object (the one using the new version). The script just takes the numeric value from the old object, divides it by 2 and stores that value in each of the two new numeric properties. For the other property, the string, the script just append "(Version 2.0)" to the old value and deals with the name change. Those operations are just examples to illustrate a possible data transformation. They are completely arbitrary.

By default, if no update script is provided by the INES deployment handler, the object states are just copied, but when there is a change in the public interface, as in the case described above, we have to tell the system about the equivalences between the old and the new properties.

Object hot swapping is still an experimental feature and some work is needed to make it fully functional in the general case. For now, the not-so-simple case case is working (the simplest case is changing the implementation of methods without impacting the objects properties).