The MPJ daemon must be installed on any machine that can host an
MPJ process. It will be realized as an instance of the class
MPJService. It is likely to be an activatable remote object registered
with a system rmid daemon.
The MPJ daemon executes the Jini discovery protocols and registers itself
with available Jini lookup services, which we assume are accessible as
part of the standard system environment (Figure 2).
Figure 2: Independent clients may find MPJService daemons
through the Jini lookup service. Each daemon may spawn several
slaves.
The API of MPJService includes a createSlave remote method call, along the lines:
class MPJService extends Remote { public MPJSlave createSlave(MPJClient client, ...) throws RemoteException {...} }
In normal operation, a call to createSlave will behave essentially as:
int slaveID = SlaveTable.allocateID() ; String cmd = "java MPJSlaveImpl " + slaveID + " " + registryPort ; Process child = Runtime.getRuntime().exec(cmd) ; ... fork a monitor thread SlaveTable.waitFor(slaveID) ; // Wait for call-back from slave. return SlaveTable.getSlaveObject(slaveID) ;
The data structure SlaveTable is a table of slave processes
currently managed by the daemon. The daemon passes the id of the new slave
into the java command that starts the slave running. We assume
the daemon is running an RMI registry, in which it publishes itself.
The port of this registry is passed to the slave as a second argument.
The first actions of the slave object are to look up its master in the
registry, then call back to the master and install a remote reference
to itself (the slave) in the master's slave table. The monitor thread
in the daemon behaves essentially as:
DataInputStream stdout = new DataInputStream(child.getInputStream()) ; // Forward standard output from child String line ; while ((line = stdout.readLine()) != null) client.println(line) ; child.waitFor() ;
Output is multiplexed to the client by calling a remote println method on the client.
The net effect is that the client receives a remote reference to a new slave object running in a private JVM. In practise a remote destroySlave method that invokes the Process.destroy method will probably be needed as well.