Package ec.eval

# Class SlaveMonitor

java.lang.Object
ec.eval.SlaveMonitor

public class SlaveMonitor extends Object
SlaveMonitor.java

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.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `P_EVALCOMPRESSION`
  `static final String`
  `P_EVALMASTERPORT`
  `static final String`
  `P_EVALNODELAY`
  `static final String`
  `P_EVALRECVBUFFER`
  `static final String`
  `P_EVALSENDBUFER`
  `static final String`
  `P_MAXIMUMNUMBEROFCONCURRENTJOBSPERSLAVE`
  `static final String`
  `P_RESCHEDULELOSTJOBS`
  `static final int`
  `SEED_INCREMENT`
  `ServerSocket`
  `servSock`
  The socket where slaves connect.
  `EvolutionState`
  `state`
  `boolean`
  `useCompression`
  Indicates whether compression is used over the socket IO streams.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SlaveMonitor(EvolutionState state, boolean showDebugInfo, MasterProblem problemPrototype)`
  Simple constructor that initializes the data structures for keeping track of the state of each slave.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `evaluatedIndividualAvailable()`
  `void`
  `notifyMonitor(Object monitor)`
  `Object`
  `registerSlave(EvolutionState state, Socket socket, Problem problemPrototype, boolean useCompression, int noDelay, int sendBuffer, int recvBuffer)`
  Registers a new slave with the monitor.
  `void`
  `scheduleJobForEvaluation(EvolutionState state, Job job)`
  Schedules a job for execution on one of the available slaves.
  `void`
  `shutdown()`
  Shuts down the slave monitor (also shuts down all slaves).
  `void`
  `unregisterSlave(ec.eval.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)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### P_EVALNODELAY

    public static final String P_EVALNODELAY
    See Also:
      - Constant Field Values

  - ### P_EVALSENDBUFER

    public static final String P_EVALSENDBUFER
    See Also:
      - Constant Field Values

  - ### P_EVALRECVBUFFER

    public static final String P_EVALRECVBUFFER
    See Also:
      - Constant Field Values

  - ### P_EVALMASTERPORT

    public static final String P_EVALMASTERPORT
    See Also:
      - Constant Field Values

  - ### P_EVALCOMPRESSION

    public static final String P_EVALCOMPRESSION
    See Also:
      - Constant Field Values

  - ### P_MAXIMUMNUMBEROFCONCURRENTJOBSPERSLAVE

    public static final String P_MAXIMUMNUMBEROFCONCURRENTJOBSPERSLAVE
    See Also:
      - Constant Field Values

  - ### P_RESCHEDULELOSTJOBS

    public static final String P_RESCHEDULELOSTJOBS
    See Also:
      - Constant Field Values

  - ### SEED_INCREMENT

    public static final int SEED_INCREMENT
    See Also:
      - Constant Field Values

  - ### state

    public EvolutionState state

  - ### servSock

    public ServerSocket servSock
    The socket where slaves connect.

  - ### useCompression

    public boolean useCompression
    Indicates whether compression is used over the socket IO streams.

- ## Constructor Details

  - ### SlaveMonitor

    public SlaveMonitor(EvolutionState state, boolean showDebugInfo, MasterProblem problemPrototype)
    Simple constructor that initializes the data structures for keeping track of the state of each slave. The constructor receives two parameters: a boolean flag indicating whether the system should display information that is useful for debugging, and the maximum load per slave (the maximum number of jobs that a slave can be entrusted with at each time).

- ## Method Details

  - ### waitOnMonitor

    public boolean waitOnMonitor(Object monitor)

  - ### notifyMonitor

    public void notifyMonitor(Object monitor)

  - ### registerSlave

    public Object registerSlave(EvolutionState state, Socket socket, Problem problemPrototype, boolean useCompression, int noDelay, int sendBuffer, int recvBuffer)
    Registers a new slave with the monitor. Upon registration, a slave is marked as available for jobs.

  - ### unregisterSlave

    public void unregisterSlave(ec.eval.SlaveConnection slave)
    Unregisters a dead slave from the monitor.

  - ### shutdown

    public void shutdown()
    Shuts down the slave monitor (also shuts down all slaves).

  - ### scheduleJobForEvaluation

    public void scheduleJobForEvaluation(EvolutionState state, Job job)
    Schedules a job for execution on one of the available slaves. The monitor waits until at least one slave is available to perform the job.

  - ### waitForAllSlavesToFinishEvaluating

    public void waitForAllSlavesToFinishEvaluating(EvolutionState state)
    This method returns only when all slaves have finished the jobs that they were assigned. While this method waits, new jobs can be assigned to the slaves. This method is usually invoked from MasterProblem.finishEvaluating. You should not abuse using this method: if there are two evaluation threads, where one of them waits until all jobs are finished, while the second evaluation thread keeps posting jobs to the slaves, the first thread might have to wait until the second thread has had all its jobs finished.

  - ### evaluatedIndividualAvailable

    public boolean evaluatedIndividualAvailable()

  - ### waitForIndividual

    public QueueIndividual waitForIndividual()
    Blocks until an individual comes available