+
+ /**
+ * Search and return a new node when one failed or when JaceP2P needs another
+ * one. For the first case, the given failed node should not be null, and
+ * null in the other case.
+ * @param _spawnerIP IP of the requester
+ * @param _rank The task number number of the dead node
+ *
+ * @author Sébastien Miquée
+ */
+ @Override
+ public synchronized Node getNewNode( String _spawnerIP, int _rank ) throws RemoteException
+ {
+ int idNode = -1 ;
+ int idAlgo = searchAlgo( _spawnerIP ) ;
+
+ if( idAlgo == -1 )
+ {
+ System.err.println( "No algorithm found for this Spawner!" ) ;
+ return null ;
+ }
+
+ /** We have to replace a Spawner **/
+ if( _rank == -2 )
+ {
+ idNode = -2 ;
+ } else {
+ /** We have to replace a computing node **/
+ idNode = algos.get( idAlgo ).getMapping().getIdOfAssociation( _rank ) ;
+ }
+
+ if( idNode == -1 )
+ {
+ System.err.println( "No tasks corresponds to rank "+_rank+"!" ) ;
+ return null ;
+ }
+
+ GNode dead = null ;
+
+ if( idNode >= 0 )
+ {
+ dead = algos.get( idAlgo ).getMapping().getAssociation( idNode ).getGNode() ;
+ }
+
+ if( dead == null && idNode >= 0 )
+ {
+ System.err.println( "The GNode corresponding to the task "+_rank+" is null!" ) ;
+ System.err.println( "Trying to find a new node for this task (not optimal)..." ) ;
+ }