April 2008 Archives

Strong mobility

| | TrackBacks (0)
When designing a mobile agent runtime, one of the first decisions that must be made is whether to support strong mobility of weak mobility.  Strong mobility gives mobile agent developers the ability to migrate agents without needing to write any supporting logic for handling state changes after a migration occurs.  For example, with strong mobility one can retrieve a directory listing on a remote machine and print it on a local machine by creating a mobile agent with code like this:

var startingHost = getHost();
var destinationHost = getParam(1);
var fileList;
moveTo(destinationHost);
fileList = exec("ls -l");
moveTo(startingHost);
print(fileList);

As the runtime executes this code, the actual location of the agent is changing and the state of the agent is automatically transferred.

With weak mobility, the agent must reinterpret its state after every move.   In essence, the agent developer has to create a state machine.  Doing so places a burden on the agent developer because he or she must figure out how to handle state rather than focus on the original problem the agent is supposed to solve.  Lets look at an example of weak migration code, doing the same thing as the strong migration code above:

class Agent
{
     const int START_STATE = 1;
     const int AT_DEST_STATE = 2;
     const int DONE_STATE;

     int state = START_STATE;
     String startingHost;
     String destinationHost;
     String fileList;


     void init(String[] params)
     {
          destinationHost = params[0];
          startingHost = getHost();
     }

     void cleanup()
     {
     }

     void run()
     {
          switch(state)
          {
               case START_STATE:
                    state = AT_DEST_STATE;
                    moveTo(destinationhost);
                    break;
   
              case AT_DEST_STATE:
                   fileList = exec("ls -l");
                   state = DONE_STATE;
                   moveTo(startingHost);
                   break;

               case DONE_STATE:
                    print(fileList);
                    break;

               default:
                      throw new Error("Unknown state!");
         }
    }
}

As you can see, the weak migration code is more complicated and harder to understand in comparison to the linear execution of the strong migration code.

About this Archive

This page is an archive of entries from April 2008 listed from newest to oldest.

February 2008 is the previous archive.

May 2008 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.01