From 0f24648ed27a5e3bd060e04afac15b2821dd693a Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Miqu=C3=A9e?= Date: Tue, 9 Feb 2010 16:02:05 +0100 Subject: [PATCH] Correction of interlock implementation. - Now we do not block the SuperNode itself when it uses functions modifying gnodes. - Correction of some function declarations in order to launch "rmic" correctly. --- Makefile | 10 +++--- src/jaceP2P/JaceSpawner.java | 2 +- src/jaceP2P/JaceSuperNodeInterface.java | 5 ++- src/jaceP2P/JaceSuperNodeServer.java | 45 +++++++++++++++++++++---- 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index b747d81..12ccc45 100644 --- a/Makefile +++ b/Makefile @@ -7,17 +7,19 @@ SRC=src PACKAGE=jaceP2P BIN=bin JAR=JaceP2P.jar +MAPPING=/home/miquee/lib/Mapping.jar +CLASSPATH=.:$(MAPPING) all: compile jar compile:clean javac -d ./$(BIN) ./$(SRC)/$(PACKAGE)/*.java - rmic -d ./$(BIN) jaceP2P.JaceServer - rmic -d ./$(BIN) jaceP2P.JaceSuperNodeServer + rmic -classpath $(CLASSPATH):$(BIN) -d ./$(BIN) jaceP2P.JaceServer + rmic -classpath $(CLASSPATH):$(BIN) -d ./$(BIN) jaceP2P.JaceSuperNodeServer rmi:compile - rmic -d ./$(BIN) jaceP2P.JaceServer - rmic -d ./$(BIN) jaceP2P.JaceSuperNodeServer + rmic -classpath $(CLASSPATH):$(BIN) -d ./$(BIN) jaceP2P.JaceServer + rmic -classpath $(CLASSPATH):$(BIN) -d ./$(BIN) jaceP2P.JaceSuperNodeServer jar: jar cvfm ./$(JAR) Manifest -C ./$(BIN) $(PACKAGE) diff --git a/src/jaceP2P/JaceSpawner.java b/src/jaceP2P/JaceSpawner.java index 4f38cbe..e2f68d5 100644 --- a/src/jaceP2P/JaceSpawner.java +++ b/src/jaceP2P/JaceSpawner.java @@ -841,7 +841,7 @@ public class JaceSpawner { centralServer = (JaceSuperNodeInterface) Naming.lookup("rmi://" + superNode_IP + ":" + superNode_port + "/JaceSuperNode"); - System.out.println("succesfully located " + superNode_IP); + System.out.println("Succesfully located " + superNode_IP); // add stub and IP in LocalHost to store it until super node // death diff --git a/src/jaceP2P/JaceSuperNodeInterface.java b/src/jaceP2P/JaceSuperNodeInterface.java index 9f9573f..23cb489 100644 --- a/src/jaceP2P/JaceSuperNodeInterface.java +++ b/src/jaceP2P/JaceSuperNodeInterface.java @@ -50,10 +50,9 @@ public interface JaceSuperNodeInterface extends Remote { public void removeGNode( GNode _g ) throws RemoteException ; + public boolean blockForMapping() throws RemoteException ; + public void setMapping( Algo al ) throws RemoteException ; - - public boolean blockForMapping(); - } /** ! **/ diff --git a/src/jaceP2P/JaceSuperNodeServer.java b/src/jaceP2P/JaceSuperNodeServer.java index 8809d17..c85a7c5 100644 --- a/src/jaceP2P/JaceSuperNodeServer.java +++ b/src/jaceP2P/JaceSuperNodeServer.java @@ -27,7 +27,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements private ArrayList gnodes = null; private Algo al = null ; private int count = 0 ; - private boolean inDemand = false, operating = false ; + private boolean inDemand = false, operating = false, authorized = false ; // private boolean daemonListChange ; // Constructors @@ -216,6 +216,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements /** Initialization of Grid architecture (G5K for now) **/ Grid grid = Utils.createGridG5k(gnodes); grid.initClusters(); + /** Creation of tasks GTask **/ ArrayList ts = new ArrayList(); @@ -237,6 +238,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements } } } + Graph graph = new Graph(); @@ -279,17 +281,23 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements /** Launching the Mapping **/ al.map(); + /** Transforming mapping in register **/ Mapping mp = al.getMapping(); - + + /** Creating the register **/ ArrayList ag = mp.getMappedGNodes(); + authorized = true ; + for (int i = 0; i < ag.size(); i++) { reg.addNode((Node) ag.get(i).getNode()); gnodes.remove(ag.get(i)); Register.Instance().removeNode((Node) ag.get(i).getNode()); } + + authorized = false ; if (ag.size() != 0) { SuperNodeListe.Instance().forwardCountNode(); @@ -321,8 +329,14 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements GNode removedGNode = null ; if( _n != null ) - { - workingOnGnodes() ; + { + boolean free = false ; + + if( ! operating ) + { + workingOnGnodes() ; + free = true ; + } for( int i = 0 ; i < gnodes.size() ; i++ ) { @@ -337,7 +351,10 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements SuperNodeListe.Instance().removeGNode( removedGNode ) ; - operating = false ; + if( free ) + { + operating = false ; + } } @@ -355,6 +372,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements while( ! operating ) { inDemand = true ; + tmp = true ; tmp = tmp && SuperNodeListe.Instance().workingOnGnodes() ; @@ -394,7 +412,13 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements { System.out.println( "Replacing node found." ) ; node = (Node) remp.getNode() ; + + authorized = true ; + delGNodeFromList( node ) ; + + authorized = false ; + SuperNodeListe.Instance().forwardCountNode(); } else { System.err.println( "Replacing node not found !!" ) ; @@ -406,7 +430,13 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements { System.out.println( "Other new node found." ) ; node = (Node) remp.getNode() ; + + authorized = true ; + delGNodeFromList( node ) ; + + authorized = false ; + SuperNodeListe.Instance().forwardCountNode(); } else { System.err.println( "Other new node not found !!" ) ; @@ -465,6 +495,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements al = _al ; } + @Override /** * Allow or deny the use of operations on the gnodes list, in order to @@ -472,7 +503,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements * @author miquee * @return The authorization or not to block gnodes */ - public boolean blockForMapping() + public boolean blockForMapping() throws RemoteException { while( inDemand ) { @@ -483,7 +514,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements } } - if( operating ) + if( operating && ! authorized ) { return false ; } else { -- 2.20.1