package jaceP2P;
import java.rmi.Naming;
+import java.rmi.RemoteException;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Vector;
// Variables for Mapping
private int algo;
private double paramAlgo ;
+ private String idAlgo ;
public JaceSpawner(String superNode, int port, String comProtocol,
String[] args, int nbDaemonPerSpawner, int nbDaemonPerThread,
}
// /System.out.println("is running = false");
if (!JaceDaemon.Instance().isRunning())
- System.exit(0);
+ System.exit( 1 ) ;
}
public synchronized void signalDeadNode(JaceInterface host, int rankOfDead) {
ListeTask t = Register.Instance().getListeOfTasks();
ScanThreadSpawner.Instance().kill();
HeartBeatSpawner.Instance().kill();
+
for (int i = 0; i < s + 1; i++) {
new KillThread(i, debut, nbOfDaemonsPerSpawner,
int nbsdc = RunningApplication.Instance()
.getNumberOfSpawnerDisconnections();
+
System.out.println("Application finished successfully !");
// System.out.println("Application finished successfully !!!!!!");
// System.out.println("Application finished successfully !!!!!!");
RunningApplication.Instance().purge();
// System.exit(1);
}
+
+ /** Suprresion of the mapping algorithm on the SuperNode **/
+ centralServer.removeAlgo( idAlgo, 0 ) ;
}
- } catch (Exception e) {
- System.out
- .println("w aiiiiiiiiiiiiiirrrr" + e + " index=" + index);
+ } catch( Exception e ) {
+ System.err.println( "Error the application nodes scan!\n " + e ) ;
z = index;
}
/*
.println("JaceP2P_Error in JaceSpawner.exportObject() when creating the local JaceSpawnerServer "
+ e);
// System.err.println("exit ds JaceSpawner.exportObject");
- System.exit(0);
+ System.exit( 1 ) ;
}
}
connectSuperNode();
}
}
+
+ idAlgo = LocalHost.Instance().getIP() ;
+
if (registerSpawner.getSize() != (nbTasks + nbExtraSpawners)) {
System.err.println("I did not recieve enough nodes from superNode!!!! \n killing application !!!!");
for (int i = 0; i < registerSpawner.getSize(); i++) {
System.err.println("The reserved node was unable to reconnect to the super node");
}
}
- System.exit(0);
+ System.exit( 1 ) ;
}
spawnersList = new Vector<Object>();
System.exit(0);
}
}
+
+
+ /**
+ * 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 ;
+ }
public class TransformThread extends Thread {
int i;
System.out.println("waiting till transform of spawner " + j
+ " is finished");
while ((spawnersList.elementAt(j) instanceof Node))
+ {
try {
Thread.sleep(20);
} catch (Exception e) {
}
+ }
+
+ try {
+ ((JaceSpawnerInterface)spawnersList.elementAt( i )).setIdAlgo( idAlgo ) ;
+ } catch (RemoteException e) {
+ System.err.println( "Unable to set Mapping Algorithm identifier" ) ;
+ e.printStackTrace();
+ }
+
}
System.out.println("End Transformation of all spawners. Beginning the computing processes");
// Attributes
private int beat;
private ArrayList<GNode> gnodes = null;
- private Algo al = null ;
+ private ArrayList<Algo> algos = null ;
private int count = 0 ;
private boolean inDemand = false, operating = false, authorized = false ;
// private boolean daemonListChange ;
super() ;
beat = timeBeat ;
gnodes = new ArrayList<GNode>() ;
+ algos = new ArrayList<Algo>() ;
// daemonListChange = true ;
}
int nbNoeuds, int algo, double paramAlgo) throws RemoteException {
// Have we the correct application ?
- if (t == null) {
- System.err.println( "Problem of class transmission !" ) ;
+ if( t == null ) {
+ System.err.println( "Problem of class transmission!" ) ;
return null ;
}
if( t.getDependencies( 0 ) == null )
{
- System.err.println( "No redifinition of getDependencies() functions !" ) ;
+ System.err.println( "No redifinition of getDependencies() function!" ) ;
return null ;
}
Grid grid = Utils.createGridG5k(gnodes);
// grid.initClusters();
+
+ /** Informing about the grid heterogeneity **/
+ System.out.println( "\nHeterogeneity of the grid : " + grid.getHeterogenityDegre() + "\n" ) ;
+
/** Creation of tasks GTask **/
ArrayList<GTask> ts = new ArrayList<GTask>();
- for (int i = 0; i < nbTasks; i++) {
- ts.add(new GTask( i ) ) ;
+ for( int i = 0; i < nbTasks; i++ ) {
+ ts.add( new GTask( i ) ) ;
}
/** Research of dependencies **/
- for (int i = 0; i < nbTasks; i++) {
- int dep[] = null;
- dep = t.getDependencies(i);
+ for( int i = 0; i < nbTasks; i++ ) {
+ int dep[] = null ;
+ dep = t.getDependencies( i ) ;
/** Adding dependencies to tasks **/
- for (int j = 0; j < dep.length; j++) {
- if (dep[j] != -1) {
- ts.get(i).addDependance(ts.get(dep[j]));
+ for( int j = 0; j < dep.length; j++ ) {
+ if( dep[j] != -1 ) {
+ ts.get( i ).addDependance( ts.get( dep[ j ] ) ) ;
} else {
- break;
+ break ;
}
}
}
-
+ /** Creation of the application interaction graph **/
Graph graph = new Graph();
for( int i = 0 ; i < ts.size() ; i++)
// } catch( Exception e ) {}
/** Selection of the mapping algorithm **/
- al = null ;
+ Algo al = null ;
- switch (algo) {
+ switch( algo ) {
case 0:
al = new Simple(graph, grid);
break;
al = new DefaultMapping( graph, grid, gnodes ) ;
}
- if (al != null) {
+ if (al != null)
+ {
/** Launching the Mapping **/
al.map();
for( int i = 0; i < ag.size(); i++ ) {
reg.addNode((Node) ag.get(i).getNode());
- delGNodeFromList( (Node) ag.get(i).getNode(), 2 ) ;
+ delGNodeFromList( (Node) ag.get(i).getNode(), 2, spawnerIP ) ;
// gnodes.remove(ag.get(i));
// Register.Instance().removeNode((Node) ag.get(i).getNode());
}
{
sup = al.getOtherGNode( gnodes ) ;
reg.addNodeBeg( (Node) sup.getNode() ) ;
- delGNodeFromList( (Node) sup.getNode(), 2 ) ;
+ delGNodeFromList( (Node) sup.getNode(), 2, spawnerIP ) ;
}
}
if (ag.size() != 0) {
SuperNodeListe.Instance().forwardCountNode();
}
+
+ /** Setting the algorithm's identifier **/
+ al.setIdS( spawnerIP ) ;
+
+ /** Adding the algorithm in the list **/
+ algos.add( al ) ;
}
* @author Sébastien Miquée
*/
@Override
- public GNode delGNodeFromList( Node _n, int _mode ) throws RemoteException
+ public GNode delGNodeFromList( Node _n, int _mode, String _spawnerIp ) throws RemoteException
{
GNode removedGNode = null ;
/** The dead node is in the mapping **/
if( _mode == 1 )
{
- ArrayList<GNode> temp = al.getMapping().getMappedGNodes() ;
+ /** Searching the algorithm **/
+ int idAlgo = searchAlgo( _spawnerIp ) ;
+
+ if( idAlgo == -1 )
+ {
+ System.err.println( "No algorithm found for this Spawner!" ) ;
+ return null ;
+ }
+
+ ArrayList<GNode> temp = algos.get( idAlgo ).getMapping().getMappedGNodes() ;
for( int i = 0 ; i < temp.size() ; i++ )
{
/** Removing the dead node from the Grid **/
if( _mode == 0 || _mode == 1 ) {
- al.getGrid().removeGNode( removedGNode ) ;
+ int idAlgo = searchAlgo( _spawnerIp ) ;
+
+ if( idAlgo != -1 && _mode == 1 )
+ {
+ algos.get( idAlgo ).getGrid().removeGNode( removedGNode ) ;
+ }
}
/** Propagation of the deletion **/
- SuperNodeListe.Instance().removeGNode( removedGNode, _mode ) ;
+ SuperNodeListe.Instance().removeGNode( removedGNode, _mode, _spawnerIp ) ;
if( free )
{
}
+ /**
+ * Search the position of the mapping algorithm in the list.
+ * @param _id Identifier of the algorithm
+ * @return The position in the list
+ */
+ private int searchAlgo( String _id )
+ {
+ int id = -1 ;
+
+ for( int i = 0 ; i < algos.size() ; i++ )
+ {
+ if( algos.get( i ).getIdS().equals( _id ) )
+ {
+ id = i ;
+ break ;
+ }
+ }
+
+ return id ;
+ }
+
/**
* Determine if this SuperNode can operate on the gnodes list.
* It asks other SuperNodes to know if their are working on this list
{
Node node = null ;
GNode remp = null, gnode = null ;
+
+ int idAlgo = searchAlgo( _spawnerIP ) ;
+
+ if( idAlgo == -1 )
+ {
+ System.err.println( "No algorithm found for this Spawner!" ) ;
+ return null ;
+ }
/** Can we use gnodes ?**/
workingOnGnodes() ;
{
authorized = true ;
- gnode = delGNodeFromList( _deadNode, 1 ) ;
+ gnode = delGNodeFromList( _deadNode, 1, _spawnerIP ) ;
- remp = al.replaceNode( gnode, gnodes ) ;
+ remp = algos.get( idAlgo ).replaceNode( gnode, gnodes ) ;
if( remp != null )
{
remp.setMapped( true ) ;
- delGNodeFromList( (Node) remp.getNode(), 2 ) ;
+ delGNodeFromList( (Node) remp.getNode(), 2, _spawnerIP ) ;
authorized = false ;
System.err.println( "Replacing node not found !!" ) ;
}
} else {
- remp = al.getOtherGNode( gnodes ) ;
+ remp = algos.get( idAlgo ).getOtherGNode( gnodes ) ;
if( remp != null )
{
authorized = true ;
- delGNodeFromList( (Node) remp.getNode(), 2 ) ;
+ delGNodeFromList( (Node) remp.getNode(), 2, _spawnerIP ) ;
authorized = false ;
}
}
+ if( remp != null )
+ {
+ node = (Node) remp.getNode() ;
+ }
+
/** Updating all mapping **/
- updateMappedNode( gnode, remp ) ;
- propagateReplaceNode( gnode, remp ) ;
+ updateMappedNode( gnode, remp, _spawnerIP ) ;
+ propagateReplaceNode( gnode, remp, _spawnerIP ) ;
/** Free the gnodes use **/
* @author Sébastien Miquée
*/
@Override
- public void updateMappedNode( GNode _dead, GNode _remp )
+ public void updateMappedNode( GNode _dead, GNode _remp, String _spawnerIP )
{
if( _remp != null )
{
int pos = 0 ;
+
+ int idAlgo = searchAlgo( _spawnerIP ) ;
+
+ if( idAlgo == -1 )
+ {
+ System.err.println( "No algorithm found for this Spawner!" ) ;
+ return ;
+ }
- pos = al.getMapping().getIdOfAssociation( _dead ) ;
+ pos = algos.get( idAlgo ).getMapping().getIdOfAssociation( _dead ) ;
if( pos != -1 )
{
/** Changing the node in the mapping **/
- al.getMapping().getMapping().get( pos ).setGNode( _remp ) ;
+ algos.get( idAlgo ).getMapping().getMapping().get( pos ).setGNode( _remp ) ;
System.out.println( "Succesfully replacing the fallen node in the mapping." ) ;
}
/** Changing the status in the grid **/
- al.getGrid().setMappedStatus( _remp, true ) ;
+ algos.get( idAlgo ).getGrid().setMappedStatus( _remp, true ) ;
- al.updateGrid() ;
+ algos.get( idAlgo ).updateGrid() ;
} else {
System.err.println( "The new GNode is null!" ) ;
}
*
* @author Sébastien Miquée
*/
- private void propagateReplaceNode( GNode _dead, GNode _remp ) throws RemoteException
+ private void propagateReplaceNode( GNode _dead, GNode _remp, String _spawnerIP ) throws RemoteException
{
if( _remp != null )
{
- SuperNodeListe.Instance().propagateReplaceNode( _dead, _remp ) ;
+ SuperNodeListe.Instance().propagateReplaceNode( _dead, _remp, _spawnerIP ) ;
}
}
@Override
public void setMapping( Algo _al ) throws RemoteException
{
- al = _al ;
+ if( searchAlgo( _al.getIdS() ) == -1 )
+ algos.add( _al ) ;
}
return gnodes ;
}
+
+ /**
+ * Remove a mapping algorithm of the algorithms list.
+ * @param _id The algorithm identifier
+ * @param _mode Indicate if the information should be transmitted
+ *
+ * @author Sébastien Miquée
+ */
+ public void removeAlgo( String _id, int _mode ) throws RemoteException
+ {
+ int i ;
+
+ i = searchAlgo( _id ) ;
+
+ if( i != -1 )
+ {
+ algos.remove( i ) ;
+
+ if( _mode == 0 )
+ {
+ SuperNodeListe.Instance().removeAlgo( _id ) ;
+ }
+ }
+ }
+
}
/** ! **/
}
}
}
-
- public void removeGNode( GNode _g, int _mode )
+
+ public void removeGNode( GNode _g, int _mode, String _spawnerIP )
{
if( _g != null )
{
// if not me, I inform the other super nodes
remoteStub = d.getStub() ;
try {
- remoteStub.delGNodeFromList( (Node)_g.getNode(), _mode ) ;
+ remoteStub.delGNodeFromList( (Node)_g.getNode(), _mode, _spawnerIP ) ;
} catch( Exception e ) {
System.err.println( "Unable to remove GNode on SuperNode " + d.getIP() ) ;
}
}
}
- public void propagateReplaceNode( GNode _dead, GNode _remp )
+ public void propagateReplaceNode( GNode _dead, GNode _remp, String _spawnerIP )
{
if( _dead != null && _remp != null )
{
// if not me, I inform the other super nodes
remoteStub = d.getStub() ;
try {
- remoteStub.updateMappedNode( _dead, _remp ) ;
+ remoteStub.updateMappedNode( _dead, _remp, _spawnerIP ) ;
} catch( Exception e ) {
System.err.println( "Unable to propagate replacing node on SuperNode " + d.getIP() ) ;
}
}
}
+
+ /**
+ * Send to all SuperNode the deletion of a mapping algorithm.
+ * @param id The mapping algorithm's identifier
+ */
+ public void removeAlgo( String _id )
+ {
+ 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.removeAlgo( _id, 1 ) ;
+ } catch( Exception e ) {
+ System.err.println( "Unable to propagate the mapping algorithm deletion " + d.getIP() ) ;
+ }
+ }
+ }
+ }
+
}