ec.eval
Class MasterProblemServer

java.lang.Object
  extended by ec.eval.MasterProblemServer
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable

public class MasterProblemServer
extends java.lang.Object
implements java.lang.Runnable, java.io.Serializable

MasterProblemServer.java

The server awaits for incoming slaves to connect. Upon one such connection is established, the server creates and starts a worker thread to manage all the incoming communication from this slave.

Parameters

eval.master.port
int
(the port where the slaves will connect)
eval.compression
boolean
(whether the communication with the slaves should be compressed or not)
eval.masterproblem.max-jobs-per-slave
int
(the maximum load (number of jobs) per slave at any point in time)

See Also:
Serialized Form

Field Summary
static java.lang.String P_EVALCOMPRESSION
           
static java.lang.String P_EVALMASTERPORT
           
static java.lang.String P_MAXIMUMNUMBEROFCONCURRENTJOBSPERSLAVE
           
 java.net.ServerSocket servSock
          The socket where slaves connect.
 SlaveMonitor slaveMonitor
           
 EvolutionState state
           
 boolean useCompression
          Indicates whether compression is used over the socket IO streams.
 
Constructor Summary
MasterProblemServer(boolean showDebugInfo)
           
 
Method Summary
 void run()
          The run method waits for incoming slaves, and launches new worker threads (one per incoming slave) to handle the communication with the slave.
 void setupServerFromDatabase(EvolutionState state)
          After the MasterProblemServer is created, it needs to be told to initialize itself from information in the parameter database.
 void shutdown()
          Indicates that the background thread is to shut down and closes the server socket.
 java.lang.Thread spawnThread()
          Creates and starts a background thread for this server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

P_EVALMASTERPORT

public static final java.lang.String P_EVALMASTERPORT
See Also:
Constant Field Values

P_EVALCOMPRESSION

public static final java.lang.String P_EVALCOMPRESSION
See Also:
Constant Field Values

P_MAXIMUMNUMBEROFCONCURRENTJOBSPERSLAVE

public static final java.lang.String P_MAXIMUMNUMBEROFCONCURRENTJOBSPERSLAVE
See Also:
Constant Field Values

slaveMonitor

public SlaveMonitor slaveMonitor

servSock

public java.net.ServerSocket servSock
The socket where slaves connect.


useCompression

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


state

public EvolutionState state
Constructor Detail

MasterProblemServer

public MasterProblemServer(boolean showDebugInfo)
Method Detail

setupServerFromDatabase

public void setupServerFromDatabase(EvolutionState state)
After the MasterProblemServer is created, it needs to be told to initialize itself from information in the parameter database. It distinguishes between starting fresh and restoring from a checkpoint by the state of the randomStates and slaves arrays.

Parameters:
state - the evolution state

shutdown

public void shutdown()
Indicates that the background thread is to shut down and closes the server socket. (should probably be synchronized).


run

public void run()
The run method waits for incoming slaves, and launches new worker threads (one per incoming slave) to handle the communication with the slave.

Specified by:
run in interface java.lang.Runnable

spawnThread

public java.lang.Thread spawnThread()
Creates and starts a background thread for this server.

Returns:
the background thread