Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e85d04f3bfeaf896a40f1c0cf7bd63bebdd7b570
[mapping.git] / src / and / Mapping / Algo.java
1 package and.Mapping ;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5
6
7 /**
8  * Abstract class defining the structure for mapping algorithms
9  * @author Sébastien Miquée
10  */
11 public abstract class Algo implements Serializable
12 {
13         private static final long serialVersionUID = 1L;
14
15         /* Variables */
16         protected Graph gr ;
17         protected Grid gl ;
18         protected Mapping mp ;
19         
20         
21         /**
22          * Default constructor.
23          */
24         public Algo() 
25         {
26                 gr = new Graph() ;
27                 gl = new Grid() ;
28                 mp = new Mapping() ;
29         }
30         
31         
32         /**
33          * Constructor.
34          * @param _gr Tasks graph to be mapped
35          * @param _gl Grid graph
36          */
37         public Algo( Graph _gr, Grid _gl )
38         {
39                 gr =  _gr ;
40                 gl = _gl ;
41                 mp = new Mapping() ;
42         }
43         
44         
45         /**
46          * Mapping function.
47          */
48         public abstract void map() ;
49         
50         
51         /**
52          * Replace a fallen node by a new one, according to the mapping policy.
53          * @param _dead The fallen node to be replaced
54          * @param _ag The list of all available computing nodes
55          * @return The new node
56          */
57         public abstract GNode replaceNode( GNode _dead, ArrayList<GNode> _ag ) ;
58         
59         
60         /**
61          * Find a new node, which may not takes part into the computation process.
62          * Typically such kind of node is used to create a new spawner or a new super-node,
63          * in order to bring fault tolerance. 
64          * @return Another node which will not compute
65          */
66         public abstract GNode getOtherGNode( ArrayList<GNode> _ag ) ;
67         
68         
69         /**
70          * Return mapping done.
71          * @return The mapping done
72          */
73         public Mapping getMapping()
74         {
75                 return mp ;
76         }       
77         
78         
79         /**
80          * Return the grid used in the algorithm.
81          * @return The Grid
82          */
83         public Grid getGrid()
84         {
85                 return gl ;
86         }
87         
88         
89         /**
90          * Return the graph used in the algorithm.
91          * @return The Graph
92          */
93         public Graph getGraph()
94         {
95                 return gr ;
96         }
97 }
98
99 /** La programmation est un art, respectons ceux qui la pratiquent !! **/