From ff1e99092ecad49a21f654b345b130b3f4bc7718 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Miqu=C3=A9e?= Date: Mon, 1 Mar 2010 08:08:46 +0100 Subject: [PATCH] Modification of mapping algorithm identifier mechanisms. --- src/jaceP2P/JaceInterface.java | 8 +++- src/jaceP2P/JaceServer.java | 19 +++++++- src/jaceP2P/JaceSpawner.java | 66 +++++++++++++++------------ src/jaceP2P/JaceSpawnerInterface.java | 2 +- src/jaceP2P/JaceSpawnerServer.java | 10 ++-- 5 files changed, 67 insertions(+), 38 deletions(-) diff --git a/src/jaceP2P/JaceInterface.java b/src/jaceP2P/JaceInterface.java index 0ddebda..f49b598 100644 --- a/src/jaceP2P/JaceInterface.java +++ b/src/jaceP2P/JaceInterface.java @@ -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) diff --git a/src/jaceP2P/JaceServer.java b/src/jaceP2P/JaceServer.java index d63f6ee..b92c31e 100644 --- a/src/jaceP2P/JaceServer.java +++ b/src/jaceP2P/JaceServer.java @@ -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(); } diff --git a/src/jaceP2P/JaceSpawner.java b/src/jaceP2P/JaceSpawner.java index 85014e0..6976abb 100644 --- a/src/jaceP2P/JaceSpawner.java +++ b/src/jaceP2P/JaceSpawner.java @@ -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ébastien Miqué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ébastien Miqué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); } } diff --git a/src/jaceP2P/JaceSpawnerInterface.java b/src/jaceP2P/JaceSpawnerInterface.java index 0a769bf..434b125 100644 --- a/src/jaceP2P/JaceSpawnerInterface.java +++ b/src/jaceP2P/JaceSpawnerInterface.java @@ -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 ; } diff --git a/src/jaceP2P/JaceSpawnerServer.java b/src/jaceP2P/JaceSpawnerServer.java index d04069b..5515dc7 100644 --- a/src/jaceP2P/JaceSpawnerServer.java +++ b/src/jaceP2P/JaceSpawnerServer.java @@ -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 ) ; +// } } -- 2.20.1