Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Correction of some bugs and performance enhancement.
[jaceP2P.git] / src / jaceP2P / JaceSuperNode.java
index c4238b7..f0e380d 100644 (file)
@@ -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;
@@ -30,6 +29,11 @@ public class JaceSuperNode {
                // create his list of SuperNode
                // containing the IPs and ports
                // but not already the stubs
+               if (System.getSecurityManager() == null) {
+            System.setSecurityManager(new SecurityManager());
+        }
+
+               
                SuperNodeListe.Instance().staticInitialization();
 
                HeartBeatSNode.Instance().setHeartTime(heartTime);
@@ -71,17 +75,17 @@ public class JaceSuperNode {
                        next = index + 1;
                HeartBeatSNode.Instance().setServer(
                                ((SuperNodeData) SuperNodeListe.Instance().getListe()
-                                               .elementAt(next)).getStub());
+                                               .get(next)).getStub());
                if (index == 0)
                        previous = SuperNodeListe.Instance().getListe().size() - 1;
                else
                        previous = index - 1;
                System.out.println(index + " " + next + " " + previous);
                try {
-                       ((SuperNodeData) SuperNodeListe.Instance().getListe().elementAt(
+                       ((SuperNodeData) SuperNodeListe.Instance().getListe().get(
                                        previous)).getStub().updateHeart(
                                        ((SuperNodeData) SuperNodeListe.Instance().getListe()
-                                                       .elementAt(index)).getStub());
+                                                       .get(index)).getStub());
                } catch (Exception e) {
 
                        System.err
@@ -152,8 +156,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();