Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Modification of mapping algorithm identifier mechanisms.
authorSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Mon, 1 Mar 2010 07:08:46 +0000 (08:08 +0100)
committerSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Mon, 1 Mar 2010 07:08:46 +0000 (08:08 +0100)
src/jaceP2P/JaceInterface.java
src/jaceP2P/JaceServer.java
src/jaceP2P/JaceSpawner.java
src/jaceP2P/JaceSpawnerInterface.java
src/jaceP2P/JaceSpawnerServer.java

index 0ddebda..f49b598 100644 (file)
@@ -58,10 +58,16 @@ public interface JaceInterface extends Remote {
 
        public void setScanning(boolean bool) throws RemoteException;
 
+//     public JaceSpawnerInterface transformIntoSpawner(String[] params,
+//                     String appliName, Register reg, int nbTasks,
+//                     JaceSuperNodeInterface snodeStub, int rank, int heartTime, int tag,
+//                     int nbdc, int nbsdc, int nbDaemonPerSpawner, int nbDaemonPerThread)
+//                     throws RemoteException;
+       
        public JaceSpawnerInterface transformIntoSpawner(String[] params,
                        String appliName, Register reg, int nbTasks,
                        JaceSuperNodeInterface snodeStub, int rank, int heartTime, int tag,
-                       int nbdc, int nbsdc, int nbDaemonPerSpawner, int nbDaemonPerThread)
+                       int nbdc, int nbsdc, int nbDaemonPerSpawner, int nbDaemonPerThread, String idAlgo)
                        throws RemoteException;
 
        public void setSpawner(JaceSpawnerInterface spawnerStub)
index d63f6ee..b92c31e 100644 (file)
@@ -28,15 +28,30 @@ public class JaceServer extends UnicastRemoteObject implements JaceInterface {
                Register.Instance().setSpawnerStub(spawnerStub);
        }
 
+//     public JaceSpawnerInterface transformIntoSpawner(String[] params,
+//                     String appliName, Register reg, int nbTasks,
+//                     JaceSuperNodeInterface snodeStub, int rank, int heartTime, int tag,
+//                     int nbdc, int nbsdc, int nbDaemonPerSpawner, int nbDaemonPerThread)
+//                     throws RemoteException {
+//             System.out.println("Beginning the transformation ...");
+//             new JaceSpawner(params, appliName, reg, nbTasks,
+//                             snodeStub, rank, heartTime, tag, nbdc, nbsdc,
+//                             nbDaemonPerSpawner, nbDaemonPerThread);
+//             HeartBeatThread.Instance().kill();
+//             return Register.Instance().getSpawnerStub();
+//     }
+       
+       
        public JaceSpawnerInterface transformIntoSpawner(String[] params,
                        String appliName, Register reg, int nbTasks,
                        JaceSuperNodeInterface snodeStub, int rank, int heartTime, int tag,
-                       int nbdc, int nbsdc, int nbDaemonPerSpawner, int nbDaemonPerThread)
+                       int nbdc, int nbsdc, int nbDaemonPerSpawner, int nbDaemonPerThread,
+                       String idAlgo)
                        throws RemoteException {
                System.out.println("Beginning the transformation ...");
                new JaceSpawner(params, appliName, reg, nbTasks,
                                snodeStub, rank, heartTime, tag, nbdc, nbsdc,
-                               nbDaemonPerSpawner, nbDaemonPerThread);
+                               nbDaemonPerSpawner, nbDaemonPerThread, idAlgo);
                HeartBeatThread.Instance().kill();
                return Register.Instance().getSpawnerStub();
        }
index 85014e0..6976abb 100644 (file)
@@ -1,7 +1,6 @@
 package jaceP2P;
 
 import java.rmi.Naming;
-import java.rmi.RemoteException;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 import java.util.Vector;
@@ -98,7 +97,7 @@ public class JaceSpawner {
        public JaceSpawner(String[] params, String appliName, Register reg,
                        int nbTasks, JaceSuperNodeInterface snodeStub, int rank,
                        int heartTime, int tag, int nbdc, int nbsdc,
-                       int nbDaemonPerSpawner, int nbDaemonPerThread) {
+                       int nbDaemonPerSpawner, int nbDaemonPerThread, String _idAlgo) {
                try {
                        nbOfDaemonsPerSpawner = nbDaemonPerSpawner;
                        nbOfDeamonsPerThread = nbDaemonPerThread;
@@ -113,6 +112,8 @@ public class JaceSpawner {
                } catch (Exception e) {
                        System.err.println("Error in copying the parameters: " + e ) ;
                }
+               
+               idAlgo = _idAlgo ;
                // System.out.println("xxxxxxxxxxxxxxx reg size="+reg.getSize()+" xxxxxxxxxxxxxx");
                this.appliName = appliName;
 
@@ -396,14 +397,14 @@ public class JaceSpawner {
        //private synchronized Node foundToReplaceThisNode(int theRank, String nom) {
        private synchronized Node foundToReplaceThisNode(int theRank, String nom, Node _n) {
                // int i = 0;
-               boolean found = false;
-               Node node = null;
+               boolean found = false ;
+               Node node = null ;
 
-               while (found == false) {
+               while( found == false ) {
                        try {
 
                                //node = centralServer.getNewNode(LocalHost.Instance().getIP());
-                               node = centralServer.getNewNode(LocalHost.Instance().getIP(), _n);
+                               node = centralServer.getNewNode( idAlgo, _n);
                                
                                if( node != null )
                                {
@@ -510,7 +511,7 @@ public class JaceSpawner {
                        if (centralServer == null) {
                                System.err.println("Central Server not localized !");
                        }
-                       node = centralServer.getNewNode( LocalHost.Instance().getIP(), null ) ;
+                       node = centralServer.getNewNode( idAlgo, null ) ;
                        RunningApplication.Instance()
                                        .incrementNumberOfSpawnerDisconnections();
                        //found = true;
@@ -554,8 +555,13 @@ public class JaceSpawner {
                                                                        .getNumberOfDisconnections(),
                                                        RunningApplication.Instance()
                                                                        .getNumberOfSpawnerDisconnections(),
-                                                       nbOfDaemonsPerSpawner, nbOfDeamonsPerThread);
+                                                       nbOfDaemonsPerSpawner, nbOfDeamonsPerThread
+                                                       , idAlgo);
                                        spawnersList.setElementAt(spawnerStub, index);
+                                       
+//                                     spawnerStub.setIdAlgo( idAlgo ) ;
+                                       
+                                       
                                        new StartProcessThread(index).start();
                                        // spawnerStub.startProcess( spawnersList);
                                } catch (Exception e) {
@@ -945,7 +951,7 @@ public class JaceSpawner {
                        }
                }
                
-               idAlgo = LocalHost.Instance().getIP() ;
+               idAlgo = LocalHost.Instance().getIP() + ":" + LocalHost.Instance().getPort() ;
                
                if (registerSpawner.getSize() != (nbTasks + nbExtraSpawners)) {
                        System.err.println("I did not recieve enough nodes from superNode!!!! \n killing application !!!!");
@@ -999,16 +1005,17 @@ public class JaceSpawner {
        }
        
        
-       /**
-        * Set the identifier of the mapping algorithm used.
-        * @param _s The mapping identifier
-        * 
-        * @author S&eacute;bastien Miqu&eacute;e
-        */
-       public void setIdAlgo( String _s ) throws RemoteException
-       {
-               idAlgo = _s ;
-       }
+//     /**
+//      * Set the identifier of the mapping algorithm used.
+//      * @param _s The mapping identifier
+//      * 
+//      * @author S&eacute;bastien Miqu&eacute;e
+//      */
+//     public void setIdAlgo( String _s ) throws RemoteException
+//     {
+//             System.err.println("############# SET ID ALGO ################# "+_s);
+//             idAlgo = _s ;
+//     }
 
        public class TransformThread extends Thread {
                int i;
@@ -1027,7 +1034,7 @@ public class JaceSpawner {
                                spawnersList.setElementAt(n.getStub().transformIntoSpawner(
                                                params, appliName, Register.Instance(), nbTasks,
                                                centralServer, i, heartTime, 0, 0, 0,
-                                               nbOfDaemonsPerSpawner, nbOfDeamonsPerThread), i);
+                                               nbOfDaemonsPerSpawner, nbOfDeamonsPerThread, idAlgo), i);
                        } catch (Exception e) {
                                System.err.println("Error while contacting newly acquired spawner ("
                                                + n.getName() + "): " + e);
@@ -1111,15 +1118,16 @@ public class JaceSpawner {
                                } catch (Exception e) {
                                }
                        }
-                       
-                       try {
-                               ((JaceSpawnerInterface)spawnersList.elementAt( i )).setIdAlgo( idAlgo ) ;
-                       } catch (RemoteException e) {
-                               System.err.println( "Unable to set Mapping Algorithm identifier" ) ;
-                               e.printStackTrace();
-                       }
-                               
                }
+               
+//             for (int k = 0; k < spawnersList.size(); k++)
+//             {
+//                     try {
+//                             ((JaceSpawnerInterface) spawnersList.get( k )).setIdAlgo( idAlgo ) ;
+//                     } catch (Exception e) {
+//                             System.err.println("Unable to propagate the mapping algorithm identifier:" + e) ;
+//                     }
+//             }
 
                System.out.println("End Transformation of all spawners. Beginning the computing processes");
                
@@ -1535,7 +1543,7 @@ class StartScanThread extends Thread {
                                // System.out.println("modify scanning to "+name);
 
                        } catch (Exception e) {
-                               System.out.println("unable to modify scanning to " + name + ":"
+                               System.err.println("Unable to modify scanning to " + name + ":"
                                                + e);
                        }
                }
index 0a769bf..434b125 100644 (file)
@@ -39,5 +39,5 @@ public interface JaceSpawnerInterface extends Remote {
 
        public boolean ping() throws RemoteException;
        
-       public void setIdAlgo( String _s ) throws RemoteException ;
+//     public void setIdAlgo( String _s ) throws RemoteException ;
 }
index d04069b..5515dc7 100644 (file)
@@ -143,9 +143,9 @@ public class JaceSpawnerServer extends UnicastRemoteObject implements
                // Register.Instance().getListeOfTasks().viewAll();
        }
 
-       @Override
-       public void setIdAlgo( String _s ) throws RemoteException 
-       {
-               JaceSpawner.Instance().setIdAlgo( _s ) ;
-       }
+//     @Override
+//     public void setIdAlgo( String _s ) throws RemoteException 
+//     {
+//             JaceSpawner.Instance().setIdAlgo( _s ) ;
+//     }
 }