{
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 ;
{
super() ;
name = "MAHEVE_2" ;
+ minNode = 5 ;
+ nbSave = 2 ;
sortedCluster = new ArrayList<Cluster>() ;
}
}
+ /**
+ * 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 ... **/
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." ) ;
}
}