edu.rice.cs.util.newjvm
Class AbstractSlaveJVM

java.lang.Object
  extended by edu.rice.cs.util.newjvm.AbstractSlaveJVM
All Implemented Interfaces:
SlaveRemote, Remote
Direct Known Subclasses:
IntegratedMasterSlaveTest.CounterSlave, InterpreterJVM

public abstract class AbstractSlaveJVM
extends Object
implements SlaveRemote

A partial implementation of a SlaveRemote that provides the quit functionality and that also periodically checks if the master is still alive and automatically quits if not.

Version:
$Id: AbstractSlaveJVM.java 5445 2011-08-17 20:32:57Z rcartwright $

Field Summary
private  String _pollMasterThreadName
          Name of the thread to periodically poll the master.
private  String _quitSlaveThreadName
          Name of the thread to quit the slave.
private  boolean _started
           
static int CHECK_MAIN_VM_ALIVE_SECONDS
           
 
Constructor Summary
AbstractSlaveJVM()
           
AbstractSlaveJVM(String quitSlaveThreadName, String pollMasterThreadName)
           
 
Method Summary
protected  void beforeQuit()
          This method is called just before the JVM is quit.
protected abstract  void handleStart(MasterRemote master)
          Called when the slave JVM has started running.
 void quit()
          Quits the slave JVM, calling beforeQuit() before it does.
 void start(MasterRemote master)
          Initializes the Slave JVM including starting background thread to periodically poll the master JVM and automatically quit if it's dead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHECK_MAIN_VM_ALIVE_SECONDS

public static final int CHECK_MAIN_VM_ALIVE_SECONDS
See Also:
Constant Field Values

_quitSlaveThreadName

private final String _quitSlaveThreadName
Name of the thread to quit the slave.


_pollMasterThreadName

private final String _pollMasterThreadName
Name of the thread to periodically poll the master.


_started

private boolean _started
Constructor Detail

AbstractSlaveJVM

public AbstractSlaveJVM()

AbstractSlaveJVM

public AbstractSlaveJVM(String quitSlaveThreadName,
                        String pollMasterThreadName)
Method Detail

quit

public final void quit()
Quits the slave JVM, calling beforeQuit() before it does.

Specified by:
quit in interface SlaveRemote

start

public final void start(MasterRemote master)
                 throws RemoteException
Initializes the Slave JVM including starting background thread to periodically poll the master JVM and automatically quit if it's dead. Synchronized to prevent other method invocations from proceeding before startup is complete.

Specified by:
start in interface SlaveRemote
Parameters:
master - The remote link to the master JVM. Note that the implementation of the slave class will have to downcast this reference to the correct master remote interface.
Throws:
RemoteException

beforeQuit

protected void beforeQuit()
This method is called just before the JVM is quit. It can be overridden to provide cleanup code, etc.


handleStart

protected abstract void handleStart(MasterRemote master)
Called when the slave JVM has started running. Subclasses must implement this method.