JavaPorts
Javaports: A Component-based Framework for Network Computing

Generic Java code template for use in implementing Tasks T3 and T4 of the task graph


public class MandelbrotWorker extends Thread {

  private Port[] port_;
  private String AppName_;
  private String TaskVarName_;
                 
  // User application variables will be inserted here
                 
  public MandelbrotWorker(String AppName, String TaskVarName) {

    super();
    AppName_ = AppName;
    TaskVarName_ = TaskVarName;
  }
                 
  public synchronized void run () {

    try {
	
      // register ports
      PortManager portmanager = new PortManager();
      port_ = portmanager.configure(AppName_, TaskVarName_);
                 
      // user code goes here
                 
      // distributed termination
      portmanager.release();
    } catch(Throwable e) {
      e.printStackTrace();
      System.exit(-1);
    }
  }
                 
  public static void main (String args[]) {

    MandelbrotWorker MandelbrotWorkerThread = new MandelbrotWorker(args[0]);
    MandelbrotWorkerThread.start();
	
    try {
      MandelbrotWorkerThread.join();
    } catch(Throwable e) {
      e.printStackTrace();
      System.exit(-1);
    }

    System.exit(0);
  }
}

Note that:

  • The code for a template does not depend in any way on the machine to which the task is allocated
  • Ports registration and initialization is handled by JavaPorts (PortManager.configure()) and hidden from the user
  • Distributed termination of tasks is handled by JavaPorts (PortManager.release()) and hidden from the user


Generic Matlab code template for use in implementing Task T5 of the task graph

function MMWorker(AppName, TaskVarName) 

  % register ports
  portmanager = PortManager;
  port = portmanager.configure(AppName, TaskVarName);


  % use code will go here



  % distributed termination
  portmanager.release;

quit;

Note that:

  • Although Matlab syntax is different from Java, template structure is similar
  • Port registration and distributed termination are handled in the same way for Matlab and Java tasks

:: Last update: 03/14/2010 ::