Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New development version.
[jaceP2P.git] / src / jaceP2P / SuperNodeListe.java
index b207bba..8d9484f 100644 (file)
@@ -62,7 +62,7 @@ public class SuperNodeListe implements Cloneable {
                        BufferedReader br = new BufferedReader(ipsr);
 
                        while ((adr = br.readLine()) != null) {
-                               liste.add(new SuperNodeData(adr, 1098));
+                               liste.add(new SuperNodeData(adr, 1099));
                        }
 
                        br.close();
@@ -81,9 +81,9 @@ public class SuperNodeListe implements Cloneable {
 
                // String adr3="193.52.61.140";
                // System.out.println("adr3 = " + adr3);
-               // liste.add(new SuperNodeData(adr1, 1098));
-               // liste.add(new SuperNodeData(adr2, 1098));
-               // liste.add(new SuperNodeData(adr3, 1098));
+               // liste.add(new SuperNodeData(adr1, 1099));
+               // liste.add(new SuperNodeData(adr2, 1099));
+               // liste.add(new SuperNodeData(adr3, 1099));
        }
 
        public void fileInitialization(String fileName) {
@@ -344,7 +344,7 @@ public class SuperNodeListe implements Cloneable {
        /*********** Sébastien Miquée ***********/
        /****************************************/
        
-       public void addGNode( GNode _g )
+       public synchronized void addGNode( GNode _g )
        {
                if( _g != null )
                {
@@ -369,7 +369,7 @@ public class SuperNodeListe implements Cloneable {
                }
        }
 
-       public void removeGNode( GNode _g, int _mode, String _spawnerIP  )
+       public synchronized void removeGNode( GNode _g, int _mode, String _spawnerIP  )
        {
                if( _g != null )
                {
@@ -394,6 +394,56 @@ public class SuperNodeListe implements Cloneable {
                }
        }
        
+       public synchronized void removeGNode( GNode _g, int _mode  )
+       {
+               if( _g != null )
+               {
+                       
+                       SuperNodeData d = null ;
+                       JaceSuperNodeInterface remoteStub = null ;
+
+                       for( int i = 0 ; i < liste.size() ; i++ ) 
+                       {
+                               d = (SuperNodeData) liste.elementAt( i ) ;
+                               if( ! d.getIP().equals(LocalHost.Instance().getIP() ) ) 
+                               {
+                                       // if not me, I inform the other super nodes
+                                       remoteStub = d.getStub() ;
+                                       try {
+                                               remoteStub.removeMappedGNode( _g, _mode ) ;
+                                       } catch( Exception e ) {
+                                               System.err.println( "Unable to remove GNode on SuperNode " + d.getIP() ) ;
+                                       }
+                               }
+                       }
+               }
+       }
+       
+       public synchronized void setMappedGNode( GNode _g, int _mode )
+       {
+               if( _g != null )
+               {
+                       
+                       SuperNodeData d = null ;
+                       JaceSuperNodeInterface remoteStub = null ;
+
+                       for( int i = 0 ; i < liste.size() ; i++ ) 
+                       {
+                               d = (SuperNodeData) liste.elementAt( i ) ;
+                               if( ! d.getIP().equals(LocalHost.Instance().getIP() ) ) 
+                               {
+                                       // if not me, I inform the other super nodes
+                                       remoteStub = d.getStub() ;
+                                       try {
+                                               remoteStub.setMapped( _g, _mode ) ; 
+                                       } catch( Exception e ) {
+                                               System.err.println( "Unable to set mapped GNode on SuperNode " + d.getIP() ) ;
+                                       }
+                               }
+                       }
+               }
+       }
+       
        
        protected boolean workingOnGnodes()
        {
@@ -444,7 +494,7 @@ public class SuperNodeListe implements Cloneable {
                }
        }
 
-       public void propagateReplaceNode( GNode _dead, GNode _remp, String _spawnerIP ) 
+       public synchronized void propagateReplaceNode( GNode _dead, GNode _remp, String _spawnerIP ) 
        {
                if( _dead != null && _remp != null )
                {