public class SlaveMonitor extends Object
The SlaveMonitor manages slave connections to each remote slave, and provides synchronization facilities for the slave connections and for various other objects waiting to be notified when new slaves are available, space is available in a slave's job queue, an individual has been completed, etc.
The monitor provides functions to create and delete slaves (registerSlave(), unregisterSlave()), schedule a job for evaluation (scheduleJobForEvaluation(...)), block until all jobs have completed (waitForAllSlavesToFinishEvaluating(...)), test if any individual in a job has been finished (evaluatedIndividualAvailable()), and block until an individual in a job is available and returned (waitForindividual()).
Generally speaking, the SlaveMonitor owns the SlaveConnections -- no one else should speak to them. Also generally speaking, only MasterProblems create and speak to the SlaveMonitor.
| Modifier and Type | Field and Description |
|---|---|
(package private) LinkedList |
allSlaves |
(package private) LinkedList |
availableSlaves |
(package private) LinkedList |
evaluatedIndividuals |
(package private) int |
maxJobsPerSlave |
static String |
P_EVALCOMPRESSION |
static String |
P_EVALMASTERPORT |
static String |
P_MAXIMUMNUMBEROFCONCURRENTJOBSPERSLAVE |
static String |
P_RESCHEDULELOSTJOBS |
(package private) ThreadPool |
pool |
(package private) int |
randomSeed |
(package private) boolean |
rescheduleLostJobs |
static int |
SEED_INCREMENT |
ServerSocket |
servSock
The socket where slaves connect.
|
(package private) boolean |
showDebugInfo |
(package private) boolean |
shutdownInProgress |
(package private) Object[] |
shutdownInProgressLock |
(package private) int |
slaveNum
A counter used to give slaves unique numbers so they can construct
useful unique names for themselves.
|
EvolutionState |
state |
(package private) Thread |
thread |
boolean |
useCompression
Indicates whether compression is used over the socket IO streams.
|
| Constructor and Description |
|---|
SlaveMonitor(EvolutionState state,
boolean showDebugInfo,
MasterProblem problemPrototype)
Simple constructor that initializes the data structures for keeping track of the state of each slave.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
debug(String s) |
boolean |
evaluatedIndividualAvailable() |
(package private) boolean |
isShutdownInProgress() |
void |
notifyMonitor(Object monitor) |
(package private) void |
notifySlaveAvailability(SlaveConnection slave,
Job job,
EvolutionState state)
Notifies the monitor that the particular slave has finished performing a job, and it (probably) is
available for other jobs.
|
(package private) int |
numAvailableSlaves()
Returns the number of available slave (not busy)
|
(package private) void |
readObject(ObjectInputStream in) |
boolean |
registerSlave(EvolutionState state,
String name,
Socket socket,
DataOutputStream out,
DataInputStream in)
Registers a new slave with the monitor.
|
void |
scheduleJobForEvaluation(EvolutionState state,
Job job)
Schedules a job for execution on one of the available slaves.
|
(package private) void |
setShutdownInProgress(boolean val) |
void |
shutdown()
Shuts down the slave monitor (also shuts down all slaves).
|
void |
unregisterSlave(SlaveConnection slave)
Unregisters a dead slave from the monitor.
|
void |
waitForAllSlavesToFinishEvaluating(EvolutionState state)
This method returns only when all slaves have finished the jobs that they were assigned.
|
QueueIndividual |
waitForIndividual()
Blocks until an individual comes available
|
boolean |
waitOnMonitor(Object monitor) |
(package private) void |
writeObject(ObjectOutputStream out) |
public static final String P_EVALMASTERPORT
public static final String P_EVALCOMPRESSION
public static final String P_MAXIMUMNUMBEROFCONCURRENTJOBSPERSLAVE
public static final String P_RESCHEDULELOSTJOBS
public static final int SEED_INCREMENT
public EvolutionState state
boolean rescheduleLostJobs
ThreadPool pool
int slaveNum
public ServerSocket servSock
public boolean useCompression
boolean shutdownInProgress
Object[] shutdownInProgressLock
int randomSeed
Thread thread
LinkedList allSlaves
LinkedList availableSlaves
int maxJobsPerSlave
boolean showDebugInfo
LinkedList evaluatedIndividuals
public SlaveMonitor(EvolutionState state, boolean showDebugInfo, MasterProblem problemPrototype)
final boolean isShutdownInProgress()
final void setShutdownInProgress(boolean val)
public boolean waitOnMonitor(Object monitor)
public void notifyMonitor(Object monitor)
final void debug(String s)
public boolean registerSlave(EvolutionState state, String name, Socket socket, DataOutputStream out, DataInputStream in)
public void unregisterSlave(SlaveConnection slave)
public void shutdown()
public void scheduleJobForEvaluation(EvolutionState state, Job job)
public void waitForAllSlavesToFinishEvaluating(EvolutionState state)
void notifySlaveAvailability(SlaveConnection slave, Job job, EvolutionState state)
public boolean evaluatedIndividualAvailable()
public QueueIndividual waitForIndividual()
int numAvailableSlaves()
void writeObject(ObjectOutputStream out) throws IOException
s - checkpoint file output streamIOExceptionvoid readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
s - checkpoint file input stream.IOExceptionClassNotFoundExceptionCopyright © 2014 Evolutionary Computation Laboratory at George Mason University. All rights reserved.