muskel
Class DiscoveryService

java.lang.Object
  extended by muskel.DiscoveryService

public class DiscoveryService
extends java.lang.Object

This class is used to maintain a list of available (discovered, actually) processing resources, that is processing elements in the portion of network accessible via multicast messages that currently run a muskel RemoteWorker RMI object.
The class uses a DiscoveryThread thread to actually perform remote processing elements discovery.
The list of workers maintained by this class is a simple Vector. New workers requested by the Eval thread are provided from the start position.
New workers discovered are added at the end.
A list of already given worker (to the Eval thread) is also maintained.
In case a number nw of processing elements is requested, which is not currently available, the calling thread is actually blocked (wait()) and it is eventually unblocked by the DiscoveryThread communicating that a new resource is available.


Constructor Summary
DiscoveryService()
          standard constructor initializes the vectors and starts the discovery thread
 
Method Summary
 void addWorker(java.lang.String w)
          used by the DiscoveryThread to place the name of a fresh host discovered in the discvored hosts vector.
 java.lang.String getNewWorker()
          used from the StandardEval thread to get a fresh host to run a worker
 java.lang.String[] getNWorkers(int nw)
          used from within the Standard eval to get a set of workers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiscoveryService

public DiscoveryService()
standard constructor initializes the vectors and starts the discovery thread

Parameters:
lf - the log file handle
Method Detail

getNewWorker

public java.lang.String getNewWorker()
used from the StandardEval thread to get a fresh host to run a worker

Returns:
the name of the fresh host discovered

getNWorkers

public java.lang.String[] getNWorkers(int nw)
used from within the Standard eval to get a set of workers

Parameters:
nw - the number of workers reuquired
Returns:
the vector with the worker (this actually can be smaller than the requested size in case there are not enough workers)

addWorker

public void addWorker(java.lang.String w)
used by the DiscoveryThread to place the name of a fresh host discovered in the discvored hosts vector. Checks for presence of that host in both the fresh and the given vector before adding as the Discovery thread does not hold the state of already discovered hosts.

Parameters:
w - the name of the host to be added