A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
mapping.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Improvement of the Maheve algorithm.
[mapping.git]
/
src
/
and
/
Mapping
/
Maheve.java
diff --git
a/src/and/Mapping/Maheve.java
b/src/and/Mapping/Maheve.java
index
a8f0472
..
c22bfc9
100644
(file)
--- a/
src/and/Mapping/Maheve.java
+++ b/
src/and/Mapping/Maheve.java
@@
-8,8
+8,8
@@
public class Maheve extends Algo
{
private static final long serialVersionUID = 1L;
- private static
final int minNode = 5
;
- private static
final int nbSave = 2
;
+ private static
int minNode
;
+ private static
int nbSave
;
private double hd ;
private ArrayList<Cluster> sortedCluster = null ;
@@
-23,6
+23,8
@@
public class Maheve extends Algo
{
super() ;
name = "MAHEVE_2" ;
+ minNode = 5 ;
+ nbSave = 2 ;
sortedCluster = new ArrayList<Cluster>() ;
}
@@
-46,6
+48,57
@@
public class Maheve extends Algo
}
+ /**
+ * Setter for the amount of nodes to preserve on each cluster
+ * for the fault tolerance (should be 0 in an environment without fault).
+ * @param _nbSave The amount of nodes to preserve
+ */
+ public void setNbSave( int _nbSave )
+ {
+ if( _nbSave >= 0 )
+ {
+ nbSave = _nbSave ;
+ }
+ }
+
+
+ /**
+ * Getter to retrieving the amount of nodes preserved for fault tolerance.
+ * @return The amount of preserved nodes
+ */
+ public int getNbSave()
+ {
+ return nbSave ;
+ }
+
+
+ /**
+ * Setter for the minimum amount of nodes which should be present in
+ * a cluster to consider this latter in the mapping process.
+ * @param _minNode The minimum amount of nodes a cluster should have to be
+ * considered
+ */
+ public void setMinNode( int _minNode )
+ {
+ if( _minNode >= 0 )
+ {
+ minNode = _minNode ;
+ }
+ }
+
+
+ /**
+ * Getter to retrieve the minimum amount of nodes a cluster should have
+ * to be considered in the mapping process.
+ * @return The minimum amount of nodes a cluster should have to be
+ * considered
+ */
+ public int getMinNode()
+ {
+ return minNode ;
+ }
+
+
@Override
public void map() {
/** If the mapping is possible ... **/
@@
-257,31
+310,49
@@
public class Maheve extends Algo
int nbFound = 0 ;
int max = 0 ;
GNode g = null ;
+ boolean changeParameter = false ;
-
for( int i = 0 ; i < sortedCluster.size() ; i++
)
+
while( nbFound < _nbTask
)
{
- /** If there is enough nodes ... **/
- if( sortedCluster.get( i ).getNbFreeNodes() >= minNode )
+ int i = 0 ;
+
+ for( i = 0 ; i < sortedCluster.size() ; i++ )
{
- max = 0 ;
- sortedCluster.get( i ).initMoreGNode() ;
+ /** If there is enough nodes ... **/
+ if( sortedCluster.get( i ).getNbFreeNodes() >= minNode )
+ {
+ max = 0 ;
+ sortedCluster.get( i ).initMoreGNode() ;
- max = sortedCluster.get( i ).getNbFreeNodes() - nbSave ;
+
max = sortedCluster.get( i ).getNbFreeNodes() - nbSave ;
- for( int j = 0 ; j < max ; j++ )
- {
- g = sortedCluster.get( i ).moreGNode() ;
- ret.add( g ) ;
+
for( int j = 0 ; j < max ; j++ )
+
{
+
g = sortedCluster.get( i ).moreGNode() ;
+
ret.add( g ) ;
- nbFound ++ ;
+
nbFound ++ ;
- if( nbFound >= _nbTask )
- break ;
+ if( nbFound >= _nbTask )
+ break ;
+ }
}
+
+ if( nbFound >= _nbTask )
+ break ;
}
- if( nbFound >= _nbTask )
- break ;
+ if( i == sortedCluster.size() && nbFound < _nbTask )
+ {
+ changeParameter = true ;
+ minNode-- ;
+ }
+ }
+
+ if( changeParameter )
+ {
+ System.err.println( "The parameter \"minNode\" has been reduced " +
+ "to allow the mapping process to be done." ) ;
}
}