weka.experiment
Class RemoteEngine

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended byjava.rmi.server.UnicastRemoteObject
              extended byweka.experiment.RemoteEngine
All Implemented Interfaces:
Compute, java.rmi.Remote, java.io.Serializable

public class RemoteEngine
extends java.rmi.server.UnicastRemoteObject
implements Compute

A general purpose server for executing Task objects sent via RMI.

Version:
$Revision: 1.7 $
Author:
Mark Hall (mhall@cs.waikato.ac.nz)
See Also:
Serialized Form

Field Summary
private  java.lang.String m_HostName
          The name of the host that this engine is started on
private  Queue m_TaskIdQueue
          A queue of corresponding ID's for tasks
private  Queue m_TaskQueue
          A queue of waiting tasks
private  boolean m_TaskRunning
          Is there a task running
private  java.util.Hashtable m_TaskStatus
          A hashtable of experiment status
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
 
Fields inherited from class java.rmi.server.RemoteServer
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
RemoteEngine(java.lang.String hostName)
          Constructor
 
Method Summary
private  void addTaskToQueue(Task t, java.lang.String taskId)
          Adds a new task to the queue.
 java.lang.Object checkStatus(java.lang.Object taskId)
          Returns status information on a particular task
 java.lang.Object executeTask(Task t)
          Takes a task object and queues it for execution
static void main(java.lang.String[] args)
          Main method.
private  void purge()
          Checks the hash table for failed/finished tasks.
private  void purgeClasses()
          Attempts to purge class types from the virtual machine.
private  void startTask()
          Checks to see if there are any waiting tasks, and if no task is currently running starts a waiting task.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_HostName

private java.lang.String m_HostName
The name of the host that this engine is started on


m_TaskQueue

private Queue m_TaskQueue
A queue of waiting tasks


m_TaskIdQueue

private Queue m_TaskIdQueue
A queue of corresponding ID's for tasks


m_TaskStatus

private java.util.Hashtable m_TaskStatus
A hashtable of experiment status


m_TaskRunning

private boolean m_TaskRunning
Is there a task running

Constructor Detail

RemoteEngine

public RemoteEngine(java.lang.String hostName)
             throws java.rmi.RemoteException
Constructor

Parameters:
hostName - name of the host
Throws:
java.rmi.RemoteException - if something goes wrong
Method Detail

executeTask

public java.lang.Object executeTask(Task t)
                             throws java.rmi.RemoteException
Takes a task object and queues it for execution

Specified by:
executeTask in interface Compute
Parameters:
t - the Task object to execute
Returns:
an identifier for the Task that can be used when querying Task status
Throws:
java.rmi.RemoteException - if something goes wrong.

checkStatus

public java.lang.Object checkStatus(java.lang.Object taskId)
                             throws java.lang.Exception
Returns status information on a particular task

Specified by:
checkStatus in interface Compute
Parameters:
taskId - the ID of the task to check
Returns:
a TaskStatusInfo encapsulating task status info
Throws:
java.lang.Exception - if an error occurs

addTaskToQueue

private void addTaskToQueue(Task t,
                            java.lang.String taskId)
Adds a new task to the queue.

Parameters:
t - a Task value to be added
taskId - the id of the task to be added

startTask

private void startTask()
Checks to see if there are any waiting tasks, and if no task is currently running starts a waiting task.


purgeClasses

private void purgeClasses()
Attempts to purge class types from the virtual machine. May take some time as it relies on garbage collection


purge

private void purge()
Checks the hash table for failed/finished tasks. Any that have been around for an hour or more are removed. Clients are expected to check on the status of their remote tasks. Checking on the status of a finished/failed task will remove it from the hash table, therefore any failed/finished tasks left lying around for more than an hour suggest that their client has died..


main

public static void main(java.lang.String[] args)
Main method. Gets address of the local host, creates a remote engine object and binds it in the RMI registry. If there is no RMI registry, then it tries to create one with default port 1099.

Parameters:
args -