From: Sébastien Miquée Date: Fri, 19 Feb 2010 18:03:31 +0000 (+0100) Subject: Modifying functions manipulating Grid classes. X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/jaceP2P.git/commitdiff_plain/f9521b9e16870b08431c799673188c418d40e7dc?ds=sidebyside Modifying functions manipulating Grid classes. - Allowing to remove dead nodes from the Grid class in the Algo object. --- diff --git a/src/jaceP2P/JaceSuperNode.java b/src/jaceP2P/JaceSuperNode.java index c4238b7..4dcd3e9 100644 --- a/src/jaceP2P/JaceSuperNode.java +++ b/src/jaceP2P/JaceSuperNode.java @@ -1,8 +1,7 @@ package jaceP2P; import java.rmi.Naming; - -import and.Mapping.GNode; +import java.rmi.RemoteException; public class JaceSuperNode { final int NB_HEART_DECONNECT = 3; @@ -152,8 +151,13 @@ public class JaceSuperNode { index)).setNbOfNodes(Register.Instance().getSize()); SuperNodeListe.Instance().forwardCountNode(); - GNode deadGNode = snodeServer.delGNodeFromList( host, 0 ) ; - SuperNodeListe.Instance().removeGNode( deadGNode ) ; + try { + snodeServer.delGNodeFromList( host, 0 ) ; + } catch (RemoteException e) { + System.err.println( "Unable to remove the dead node from the list !" ) ; + e.printStackTrace(); + } +// SuperNodeListe.Instance().removeGNode( deadGNode ) ; // Register.Instance().viewAll(); // SuperNodeListe.Instance().viewAll(); diff --git a/src/jaceP2P/JaceSuperNodeInterface.java b/src/jaceP2P/JaceSuperNodeInterface.java index 3b1ef20..c5f2e3a 100644 --- a/src/jaceP2P/JaceSuperNodeInterface.java +++ b/src/jaceP2P/JaceSuperNodeInterface.java @@ -49,7 +49,9 @@ public interface JaceSuperNodeInterface extends Remote { /** ! **/ public void addGNode( GNode _g ) throws RemoteException ; - public void removeGNode( GNode _g ) throws RemoteException ; +// public void removeGNode( GNode _g ) throws RemoteException ; + + public GNode delGNodeFromList( Node _n, int _mode ) throws RemoteException ; public boolean blockForMapping() throws RemoteException ; diff --git a/src/jaceP2P/JaceSuperNodeServer.java b/src/jaceP2P/JaceSuperNodeServer.java index c954257..5e67a4c 100644 --- a/src/jaceP2P/JaceSuperNodeServer.java +++ b/src/jaceP2P/JaceSuperNodeServer.java @@ -77,7 +77,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements .setNbOfNodes(Register.Instance().getSize()); new ForwardCount().start(); } catch (Exception e) { - System.out.println("Error changing Server in SendSurplus : " + System.err.println("Error changing Server in SendSurplus : " + e); } } @@ -99,7 +99,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements System.out.println("Put token to true"); } catch (Exception e) { - System.out + System.err .println("Unable to heartBeat the next SuperNode with the new Token : " + e); } @@ -123,7 +123,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements public synchronized void workerRegistering(JaceInterface workerStub, String workerIP, String workerName, int port, GNode g) throws RemoteException { - System.out.println("CONNEXION of " + workerName); + System.out.println("CONNECTION of " + workerName); // Create the node Node noeud = new Node(workerStub); @@ -200,6 +200,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements /** Mapping !! Sébastien Miquée **/ /*********************************/ + @Override public Register getRegisterSpawner(String spawnerIP, int nbTasks, Task t, int nbNoeuds, int algo, double paramAlgo) throws RemoteException { @@ -299,7 +300,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements authorized = true ; - for (int i = 0; i < ag.size(); i++) { + for( int i = 0; i < ag.size(); i++ ) { reg.addNode((Node) ag.get(i).getNode()); delGNodeFromList( (Node) ag.get(i).getNode(), 0 ) ; // gnodes.remove(ag.get(i)); @@ -329,26 +330,20 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements } -// daemonListChange = false ; - - System.out.println( "Spawner returned reg: " + reg ) ; +// System.out.println( "Spawner returned reg: " + reg ) ; /** Mapping distribution over other Super Nodes */ SuperNodeListe.Instance().setMapping( al ) ; operating = false ; - /* Returning result */ + /** Returning result **/ return reg ; } - /*****************************************/ - /**** Sébastien Miquée ****/ - /** **/ - /** Recherche nouveau noeud **/ - /*****************************************/ - protected GNode delGNodeFromList( Node _n, int _mode ) + @Override + public GNode delGNodeFromList( Node _n, int _mode ) throws RemoteException { GNode removedGNode = null ; @@ -392,10 +387,10 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements } } - -// daemonListChange = true ; - - SuperNodeListe.Instance().removeGNode( removedGNode ) ; + /** Removing the dead node from the Grid **/ + al.getGrid().removeGNode( removedGNode ) ; + + SuperNodeListe.Instance().removeGNode( removedGNode, _mode ) ; if( free ) { @@ -439,7 +434,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements inDemand = false ; } - + @Override public Node getNewNode( String _spawnerIP, Node _deadNode ) throws RemoteException { Node node = null ; @@ -558,34 +553,34 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements } - @Override - public void removeGNode( GNode _g ) throws RemoteException - { - if( _g != null ) - { - boolean free = false ; - - if( ! operating ) - { - workingOnGnodes() ; - free = true ; - } - - for( int i = 0 ; i < gnodes.size() ; i++ ) - { - if( ((Node)gnodes.get(i).getNode()).getId() == ((Node)_g.getNode()).getId() ) - { - gnodes.remove( i ) ; - Register.Instance().removeNodeOfName( _g.getName() ) ; - break ; - } - } - - if( free ) - operating = false ; - } - - } +// @Override +// public void removeGNode( GNode _g ) throws RemoteException +// { +// if( _g != null ) +// { +// boolean free = false ; +// +// if( ! operating ) +// { +// workingOnGnodes() ; +// free = true ; +// } +// +// for( int i = 0 ; i < gnodes.size() ; i++ ) +// { +// if( ((Node)gnodes.get(i).getNode()).getId() == ((Node)_g.getNode()).getId() ) +// { +// gnodes.remove( i ) ; +// Register.Instance().removeNodeOfName( _g.getName() ) ; +// break ; +// } +// } +// +// if( free ) +// operating = false ; +// } +// +// } @Override diff --git a/src/jaceP2P/SuperNodeListe.java b/src/jaceP2P/SuperNodeListe.java index df26230..017128a 100644 --- a/src/jaceP2P/SuperNodeListe.java +++ b/src/jaceP2P/SuperNodeListe.java @@ -369,7 +369,7 @@ public class SuperNodeListe implements Cloneable { } } - public void removeGNode( GNode _g ) + public void removeGNode( GNode _g, int _mode ) { if( _g != null ) { @@ -385,7 +385,7 @@ public class SuperNodeListe implements Cloneable { // if not me, I inform the other super nodes remoteStub = d.getStub() ; try { - remoteStub.removeGNode( _g ) ; + remoteStub.delGNodeFromList( (Node)_g.getNode(), _mode ) ; } catch( Exception e ) { System.err.println( "Unable to remove GNode on SuperNode " + d.getIP() ) ; }