es.udc.gii.common.eaf.algorithm.parallel.topology.evaluation
Class EvaluationTopology

java.lang.Object
  extended by es.udc.gii.common.eaf.algorithm.parallel.topology.Topology
      extended by es.udc.gii.common.eaf.algorithm.parallel.topology.evaluation.EvaluationTopology
All Implemented Interfaces:
Configurable, java.io.Serializable

public class EvaluationTopology
extends Topology
implements java.io.Serializable

A evaluation topology is used by a DistributedEvalutation and hides the details of the underlying distributed evironment.

This class provides methods for sending and receiving individuals (using EvaluationObject): see (send(es.udc.gii.common.eaf.algorithm.parallel.topology.evaluation.EvaluationObject) and receive()).

Author:
Rafael Tedin Alvarez
See Also:
Serialized Form

Field Summary
protected  boolean master
          true if this process is the master in this topology.
protected static int MASTER
          Rank of the default master process.
protected static int MSG_TAG
           
protected  int myMaster
          The rank of the master of this topology.
static int NONE
          Special return value for getMaster().
private  java.util.Map<mpi.Request,EvaluationObject[]> pendingSendRequest
           
 
Fields inherited from class es.udc.gii.common.eaf.algorithm.parallel.topology.Topology
communicator, receivers, senders, topologyRank
 
Constructor Summary
EvaluationTopology()
          Creates a new instance of EvaluationTopology.
EvaluationTopology(int races)
          Creates a new instance of EvaluationTopology.
 
Method Summary
private  void addSendRequest(mpi.Request request, EvaluationObject[] evalObj)
           
protected  void doConfigure()
          A subclass might need additional configuration.
protected  void doConfigure(org.apache.commons.configuration.Configuration conf)
          A subclass might need additional configuration.
protected  void doInitialize()
          Performs the initialization.
protected  EvaluationObject doReceive()
          Performs the receive operation.
protected  void doSend(EvaluationObject evalObj)
          Performs the send operation.
 boolean evaluationObjectReceived()
          Checks if some evaluation object has been received.
 void finish()
           
 int getMaster()
          Retuns the rank of the master of this topology.
 boolean isMaster()
          Returns true if the calling process is the master process of this topology.
 EvaluationObject receive()
          Receives a EvaluationObject from a slave or from a master.
 void send(EvaluationObject evalObj)
          Sends a EvaluationObject to a slave or to the master.
private  void testSendRequests()
           
 
Methods inherited from class es.udc.gii.common.eaf.algorithm.parallel.topology.Topology
configure, getCommunicator, getRaces, getReceivers, getSenders, getSize, getTopologyRank, initialize, isConnected, isInitialized, setInitialized, setRaces, synchronize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pendingSendRequest

private java.util.Map<mpi.Request,EvaluationObject[]> pendingSendRequest

MSG_TAG

protected static final int MSG_TAG
See Also:
Constant Field Values

MASTER

protected static final int MASTER
Rank of the default master process.

See Also:
Constant Field Values

master

protected boolean master
true if this process is the master in this topology.


NONE

public static final int NONE
Special return value for getMaster().

See Also:
Constant Field Values

myMaster

protected int myMaster
The rank of the master of this topology.

Constructor Detail

EvaluationTopology

public EvaluationTopology()
Creates a new instance of EvaluationTopology.


EvaluationTopology

public EvaluationTopology(int races)
Creates a new instance of EvaluationTopology.

Method Detail

doInitialize

protected void doInitialize()
Performs the initialization.

Specified by:
doInitialize in class Topology

doConfigure

protected void doConfigure()
Description copied from class: Topology
A subclass might need additional configuration.

Specified by:
doConfigure in class Topology

doConfigure

protected void doConfigure(org.apache.commons.configuration.Configuration conf)
Description copied from class: Topology
A subclass might need additional configuration.

Specified by:
doConfigure in class Topology

testSendRequests

private void testSendRequests()

addSendRequest

private void addSendRequest(mpi.Request request,
                            EvaluationObject[] evalObj)

doSend

protected void doSend(EvaluationObject evalObj)
Performs the send operation.


send

public void send(EvaluationObject evalObj)
Sends a EvaluationObject to a slave or to the master. The receiver is known by the method EvaluationObject.getDest() of evalObj. This method is implemented with the doSend(es.udc.gii.common.eaf.algorithm.parallel.topology.evaluation.EvaluationObject) method. It is a nonblocking send.


doReceive

protected EvaluationObject doReceive()
Performs the receive operation.


receive

public EvaluationObject receive()
Receives a EvaluationObject from a slave or from a master. For slaves it returns null when the evaluation process is finished. For all processes it returns null when an object is received that's not an instance of EvaluationObject.

This method is implemented with the doReceive() method. It is a blocking receive, so the caller waits until a message is arrived.


evaluationObjectReceived

public boolean evaluationObjectReceived()
Checks if some evaluation object has been received.

Returns:
true if an evaluation object has been received, false otherwise.

getMaster

public int getMaster()
Retuns the rank of the master of this topology. If there isn't any master it returns NONE.


isMaster

public boolean isMaster()
Returns true if the calling process is the master process of this topology. Returns false otherwise.


finish

public void finish()