@Override
- public GNode replaceNode(GNode replaced, ArrayList<GNode> _ag )
+ public GNode replaceNode(GNode _dead, ArrayList<GNode> _ag )
{
- // TODO
+ GNode ret = null ;
+
+ if( _dead != null )
+ {
+ int pos = 0 ;
+ pos = mp.getIdOfAssociation( _dead ) ;
+
+ if( pos == -1 )
+ {
+ System.err.println( "GNode "+_dead+" does not exist in the mapping!" ) ;
+ return null ;
+ }
+
+ if( _ag.size() > 0 )
+ {
+ ret = _ag.get( 0 ) ;
+
+
+ } else {
+ System.err.println( "Not enought available nodes in gnodes to replace one !" ) ;
+ return null ;
+ }
+ }
/** Update in cluster the status of nodes **/
updateGrid() ;
-
- return null ;
+ return ret ;
}
@Override
- public GNode getOtherGNode( ArrayList<GNode> _ag ) {
- // TODO Auto-generated method stub
- return null;
+ public GNode getOtherGNode( ArrayList<GNode> _ag )
+ {
+ /** Returning the first node in the list **/
+ if( _ag.size() > 0 )
+ {
+ return _ag.get( 1 ) ;
+ }
+
+ return null ;
}
}