edu.rice.cs.util.newjvm
Class AbstractMasterJVM

java.lang.Object
  |
  +--edu.rice.cs.util.newjvm.AbstractMasterJVM
All Implemented Interfaces:
MasterRemote, Remote
Direct Known Subclasses:
IntegratedMasterSlaveTest.MasterImpl

public abstract class AbstractMasterJVM
extends Object
implements MasterRemote

An abstract class implementing the logic to invoke and control, via RMI, a second Java virtual machine. This class is used by subclassing it. (See package documentation for more details.)

Version:
$Id: AbstractMasterJVM.java,v 1.5 2002/04/19 05:17:33 brianstoler Exp $

Field Summary
private  boolean _quitOnStartup
          This flag is set when a quit request is issued before the slave has even finished starting up.
private  SlaveRemote _slave
          The slave JVM remote stub, if it's connected, or null if not.
private  String _slaveClassName
          The fully-qualified name of the slave JVM class.
private  boolean _startupInProgress
          Is slave JVM in the progress of starting up?
private  Remote _stub
          The current remote stub for this main JVM object.
private  File _stubFile
          The file containing the serialized remote stub.
private static String RUNNER
           
 
Constructor Summary
protected AbstractMasterJVM(String slaveClassName)
          Sets up the master JVM object, but does not actually invoke the slave JVM.
 
Method Summary
 void checkStillAlive()
          No-op to prove that the master is still alive.
protected  SlaveRemote getSlave()
          Returns slave remote instance, or null if not connected.
protected abstract  void handleSlaveConnected()
          Callback for when the slave JVM has connected, and the bidirectional communications link has been established.
protected abstract  void handleSlaveQuit(int status)
          Callback for when the slave JVM has quit.
protected  void invokeSlave()
          Invokes slave JVM.
protected  boolean isStartupInProgress()
          Returns true if the slave is in the process of starting.
protected  void quitSlave()
          Quits slave JVM.
 void registerSlave(SlaveRemote slave)
          Registers a slave JVM.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

RUNNER

private static final String RUNNER

_slave

private SlaveRemote _slave
The slave JVM remote stub, if it's connected, or null if not.

_startupInProgress

private boolean _startupInProgress
Is slave JVM in the progress of starting up?

_quitOnStartup

private boolean _quitOnStartup
This flag is set when a quit request is issued before the slave has even finished starting up. In that case, immediately after starting up, we quit it.

_stub

private Remote _stub
The current remote stub for this main JVM object. This field is null except between the time the slave JVM is first invoked and the time the slave registers itself.

_stubFile

private File _stubFile
The file containing the serialized remote stub. This field is null except between the time the slave JVM is first invoked and the time the slave registers itself.

_slaveClassName

private final String _slaveClassName
The fully-qualified name of the slave JVM class.
Constructor Detail

AbstractMasterJVM

protected AbstractMasterJVM(String slaveClassName)
Sets up the master JVM object, but does not actually invoke the slave JVM.
Parameters:
slaveClassName - The fully-qualified class name of the class to start up in the second JVM. This class must implement the interface specified by this class's type parameter, which must be a subclass of SlaveRemote.
Method Detail

handleSlaveConnected

protected abstract void handleSlaveConnected()
Callback for when the slave JVM has connected, and the bidirectional communications link has been established. During this call, getSlave() is guaranteed to not return null.

handleSlaveQuit

protected abstract void handleSlaveQuit(int status)
Callback for when the slave JVM has quit. During this call, getSlave() is guaranteed to return null.
Parameters:
status - The exit code returned by the slave JVM.

invokeSlave

protected final void invokeSlave()
                          throws IOException,
                                 RemoteException
Invokes slave JVM.
Throws:
IllegalStateException - if slave JVM already connected or startup is in progress.

checkStillAlive

public void checkStillAlive()
No-op to prove that the master is still alive.
Specified by:
checkStillAlive in interface MasterRemote

registerSlave

public void registerSlave(SlaveRemote slave)
                   throws RemoteException
Description copied from interface: MasterRemote
Registers a slave JVM. This method is called by the slave JVM after a connection is made.
Specified by:
registerSlave in interface MasterRemote

quitSlave

protected final void quitSlave()
                        throws RemoteException
Quits slave JVM.
Throws:
IllegalStateException - if no slave JVM is connected

getSlave

protected final SlaveRemote getSlave()
Returns slave remote instance, or null if not connected.

isStartupInProgress

protected boolean isStartupInProgress()
Returns true if the slave is in the process of starting.