/**
* Update the grid status after having done the mapping.
*/
- protected void updateGrid()
+ public void updateGrid()
{
- if( mp.getMappedGNodes().size() >= 0 )
+ if( mp.getMappedGNodes().size() > 0 )
{
ArrayList<GNode> temp = mp.getMappedGNodes() ;
for( int i = 0 ; i < temp.size() ; i++ )
{
gl.getClusterOfNode( temp.get( i ) ).setGNodeStatus( temp.get( i ), true ) ;
+
+ gl.setMappedStatus( temp.get( i ), true ) ;
}
}
}
// }
if( freenodes.size() > 0 )
{
- ret = freenodes.remove( 0 ) ;
+ ret = freenodes.get( 0 ) ;
}
return ret ;
{
return freenodes.size() ;
}
+
+
+ /**
+ * Initialization of computing nodes in this cluster. Set all
+ * of these nodes to be not mapped on.
+ */
+ public void initGNodes()
+ {
+ /** Initialization of local nodes **/
+ /** and reconstruction of the freenodes list **/
+ freenodes = null ;
+ freenodes = new ArrayList<GNode>() ;
+
+ for( int i = 0 ; i < nodes.size() ; i++ )
+ {
+ nodes.get( i ).setMapped( false ) ;
+
+ freenodes.add( nodes.get( i ) ) ;
+ }
+ }
}
if( _ag.size() > 0 )
{
ret = _ag.get( 0 ) ;
+
+
} else {
System.err.println( "Not enought available nodes in gnodes to replace one !" ) ;
return null ;
return hd ;
}
+ /**
+ * Initialization of computing nodes in the grid. Set all
+ * of these nodes to be not mapped on, and do the same thing in each
+ * of its clusters.
+ */
+ public void initGNodes()
+ {
+ /** Initialization of the local nodes **/
+ for( int i = 0 ; i < gnodesList.size() ; i++ )
+ {
+ gnodesList.get( i ).setMapped( false ) ;
+ }
+
+ /** Initialization in clusters **/
+ for( int i = 0 ; i < clusters.size() ; i++ )
+ {
+ clusters.get( i ).initGNodes() ;
+ }
+ }
+
+
+
+ /**
+ * Initialization of a set of computing nodes in the grid. Set all
+ * of these given nodes to be not mapped on, and propagates in each
+ * of its clusters.
+ * @param _ag The nodes' list to initialize
+ */
+ public void initGNodes( ArrayList<GNode> _ag )
+ {
+ if( _ag != null && _ag.size() > 0 )
+ {
+ /** Initialization of the local and clusters nodes **/
+ for( int i = 0 ; i < _ag.size() ; i++ )
+ {
+ setMappedStatus( _ag.get( i ), false ) ;
+
+ getClusterOfNode( _ag.get( i ) ).setGNodeStatus( _ag.get( i ), false ) ;
+ }
+ }
+ }
+
+
/**
* Print a comprehensible text version of the grid.
@Override
public GNode replaceNode( GNode _dead, ArrayList<GNode> _ag )
{
+ GNode ret = null ;
+
+ /** Updating the grid if there is any modification **/
+ if( _ag != null && _ag.size() != 0 )
+ {
+ gl.updateGrid( _ag ) ;
+ }
+
+ /** If something has to be done **/
+ if( _dead != null )
+ {
+ ArrayList<GNode> ac = new ArrayList<GNode>() ;
+
+ for( int i = 0 ; i < gl.getNbCluster() ; i++ )
+ {
+ if( gl.getClusters().get( i ).getNbFreeNodes() > 0 )
+ {
+ ac.add( gl.getClusters().get( i ).nextGNode() ) ;
+ }
+ }
+ }
+
/** Update in cluster the status of nodes **/
updateGrid() ;
- return null;
+ return ret ;
}
@Override
- public GNode getOtherGNode( ArrayList<GNode> _ag ) {
- // TODO Auto-generated method stub
+ public GNode getOtherGNode( ArrayList<GNode> _ag )
+ {
+
return null;
}
}
/** For the usage of algorithms which map groups of tasks on cluster **/
+ GNode tmp = null ;
for( int i = 0 ; i < at.size() ; i++ )
{
- insertMapping( new Association( c.nextGNode(), at.get( i ) ) ) ;
+ tmp = c.nextGNode() ;
+ if( tmp != null )
+ {
+ insertMapping( new Association( tmp, at.get( i ) ) ) ;
+ } else {
+ System.err.println( "Error during reception of the next GNode !" ) ;
+ break ;
+ }
}
}