3 import java.io.Serializable;
4 import java.util.ArrayList;
8 * Abstract class defining the structure for mapping algorithms
9 * @author Sébastien Miquée
11 public abstract class Algo implements Serializable
13 private static final long serialVersionUID = 1L;
18 protected Mapping mp ;
19 protected String ids ;
23 * Default constructor.
36 * @param _gr Tasks graph to be mapped
37 * @param _gl Grid graph
39 public Algo( Graph _gr, Grid _gl )
51 public abstract void map() ;
55 * Replace a fallen node by a new one, according to the mapping policy.
56 * @param _dead The fallen node to be replaced
57 * @param _ag The list of all available computing nodes
58 * @return The new node
60 public abstract GNode replaceNode( GNode _dead, ArrayList<GNode> _ag ) ;
64 * Find a new node, which may not takes part into the computation process.
65 * Typically such kind of node is used to create a new spawner or a new super-node,
66 * in order to bring fault tolerance.
67 * @return Another node which will not compute
69 public abstract GNode getOtherGNode( ArrayList<GNode> _ag ) ;
73 * Return mapping done.
74 * @return The mapping done
76 public Mapping getMapping()
83 * Return the grid used in the algorithm.
93 * Return the graph used in the algorithm.
96 public Graph getGraph()
103 * Set the string identifier for the algorithm.
104 * @param _s The algorithm's identifier
106 public void setIdS( String _s )
113 * Return the string identifier of the algorithm.
114 * @return The algorithm's identifier
116 public String getIdS()
123 * Update the grid status after having done the mapping.
125 public void updateGrid()
127 if( mp.getMappedGNodes().size() > 0 )
129 ArrayList<GNode> temp = mp.getMappedGNodes() ;
130 for( int i = 0 ; i < temp.size() ; i++ )
132 gl.getClusterOfNode( temp.get( i ) ).setGNodeStatus( temp.get( i ), true ) ;
134 gl.setMappedStatus( temp.get( i ), true ) ;
140 /** La programmation est un art, respectons ceux qui la pratiquent !! **/