Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Refunding the restart mechanism.
[hpcvm.git] / src / and / hpcvm / Client.java
index 793d066..7d58da8 100644 (file)
@@ -39,14 +39,15 @@ public class Client extends UnicastRemoteObject implements ServicesClient
        private int wait_start ;
        private int max_start_try ;
        private boolean isRestartedSave ;
-       private long save_interleave ;
-       private long date_last_save ;
+//     private long save_interleave ;
+//     private long date_last_save ;
        private SaveProcess saveProcess;
        private int maxRetryVM ;
        private int timeRetryVM ;
        private Semaphore sema ;
        private boolean emergencyStop ;
        private Process procSave ;
+       private SaveRequest saveRequest ;
        private boolean lastSaveOk ;
        
                
@@ -71,9 +72,19 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                        procSave.destroy() ;
                } catch( Exception e ) {}
                
+               // Stopping the save request
+               synchronized( saveRequest )
+               {
+                       saveRequest.setStatus( false ) ;
+                       try {
+                               saveRequest.notifyAll() ;
+                       } catch( Exception e ) {}
+               }
+               
                stopVM() ;
        }
        
+       
        @Override
        public int startVM( int _mode ) 
        {               
@@ -86,6 +97,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                e2.printStackTrace() ;
                        }
 
+                       
                        // Checking first start
                        if( machine.checkVmx() == 1 )
                        {
@@ -191,7 +203,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                " -gp " + machine.getVmUserPasswd() + " runScriptInGuest " +
                                working_directory + "/" + machine.getDirectory() 
                                + "/" + machine.getVmx_name() + " " + ushell + 
-                               " \"echo ok\"" ;// + " -noWait " ;
+                               " \"echo ok\"" ;
                                
                                try {
                                        FileWriter fw = new FileWriter( new File( working_directory + "/testStarted.sh" ) ) ;
@@ -221,16 +233,9 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                                if( p.exitValue() == 0 )
                                                {
                                                        started = true ;
-//                                             machine.setStatus( "running" ) ;
-//                                             if( _mode == 0 )
-//                                             {
-//                                                     LocalHost.Instance().getServerStub().changeStatus( 
-//                                                             LocalHost.Instance().getIP(), "running" ) ;
-//                                             } 
                                                        ret = false ;
                                                } else {
                                                        System.err.println( "Error while checking if the VM is started!" ) ;
-//                                             printProcessError( p.getErrorStream() ) ;
                                                        ret = printProcessError( p ) ;
                                                
                                                        if( ! ret )
@@ -251,7 +256,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                                                System.out.println( "Retrying (" + retry + ") ... " ) ;
                                                                Thread.sleep( timeRetryVM ) ;
                                                        }
-//                                             wait_start = wait_start / 2 ;
                                                        count++ ;
                                                }
                                        } catch( IOException e ) {
@@ -337,7 +341,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                                ret = false ;
                                        } else {
                                                System.err.println( "VM did not received the host IP!" ) ;
-//                                     printProcessError( p.getErrorStream() ) ;
                                                ret = printProcessError( p ) ;
                                        
                                                if( ! ret )
@@ -416,12 +419,10 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                        if( p.exitValue() == 0 )
                                        {
                                                System.out.println( "VM received its assigned IP." ) ;
-//                                     return 0 ;
                                                ret = false ;
                                                machine.setStatus( "running" ) ;
                                        } else {
                                                System.err.println( "VM did not received its assigned IP!" ) ;
-//                                     printProcessError( p.getErrorStream() ) ;
                                                ret = printProcessError( p ) ;
                                        
                                                if( ! ret )
@@ -479,6 +480,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                return 1 ;
        }
 
+       
        @Override
        public int stopVM() 
        {               
@@ -526,7 +528,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                        ret = false ;
                                } else {
                                        System.err.println( "Virtual machine not stopped!" ) ;
-//                                     printProcessError( p.getErrorStream() ) ;
                                        ret = printProcessError( p ) ;
                                        
                                        if( ! ret )
@@ -567,41 +568,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                e1.printStackTrace() ;
                        }
                        
-//                     if( ! isRestartedSave )
-//                     {
-//                             /** Restoring the original vmx file (necessary after a crash) **/
-//                             command = new String[]{ "/bin/cp", 
-//                                             working_directory + "/" + machine.getDirectory() + "/" + machine.getVmx_name_normal(),
-//                                             working_directory + "/" + machine.getDirectory() + "/" + machine.getVmx_name() } ;
-//                             
-//                                     try {
-//                                             Process p = Runtime.getRuntime().exec( command ) ;
-//                                             p.waitFor() ;
-//                     
-//                                             if( p.exitValue() == 0 )
-//                                             {
-//                                                     System.out.println( "Successfully replaced the VMX file." ) ;
-//                                                     sema.release() ;
-//                                                     emergencyStop = false ;
-//                                                     return 0 ;
-//                                             } else {
-//                                                     System.err.println( "Unsuccessful replacement of the VMX file!" ) ;
-////                                                   printProcessError( p.getErrorStream() ) ;
-//                                                     printProcessError( p ) ;
-//                                                     sema.release() ;
-//                                                     return 1 ;
-//                                             }
-//                                     } catch( IOException e ) {
-//                                             System.err.println( "Error during VMX file replacement: " ) ;
-//                                             e.printStackTrace() ;
-//                                             sema.release() ;
-//                                             return 1 ;
-//                                     } catch( InterruptedException e ) {
-//                                             e.printStackTrace() ;
-//                                             sema.release() ;
-//                                             return 1 ;
-//                                     }
-//                     } else {
+
                        if(     machine.checkVmx() == 0 )
                        {
                                sema.release() ;
@@ -663,7 +630,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                        ret = false ;
                                } else {
                                        System.err.println( "Virtual machine not suspended!" ) ;
-//                                     printProcessError( p.getErrorStream() ) ;
                                        ret = printProcessError( p ) ;
                                        
                                        if( ! ret )
@@ -753,7 +719,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
 
                                } else {
                                        System.err.println( "Virtual machine not restarted!" ) ;
-//                                     printProcessError( p.getErrorStream() ) ;
                                        ret = printProcessError( p ) ;
                                        
                                        if( ! ret )
@@ -822,32 +787,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                                return 1 ;
                                        }
                                        
-//                                     System.out.print( "Changing VMX file after crash ... " ) ;
-//                             
-//                                     String[] command = new String[]{ "/bin/cp", 
-//                                             working_directory + "/" + machine.getDirectory() + "/" + machine.getVmx_name_crash(),
-//                                             working_directory + "/" + machine.getDirectory() + "/" + machine.getVmx_name() } ;
-//                                     
-//                                     try {
-//                                             Process p = Runtime.getRuntime().exec( command ) ;
-//                                             p.waitFor() ;
-//                             
-//                                             if( p.exitValue() == 0 )
-//                                             {
-//                                                     System.out.println( "Successfully replaced the VMX file." ) ;
-//                                             } else {
-//                                                     System.err.println( "Unsuccessful replacement of the VMX file!" ) ;
-////                                                   printProcessError( p.getErrorStream() ) ;
-//                                                     printProcessError( p ) ;
-//                                                     
-//                                                     return 1 ;
-//                                             }
-//                                     } catch( IOException e ) {
-//                                             System.err.println( "Error during VMX file replacement: " ) ;
-//                                             e.printStackTrace() ;
-//                                     } catch( InterruptedException e ) {
-//                                             e.printStackTrace() ;
-//                                     }
                                
                                        /** Retrieving VM assigned IP **/
                                        String vmIP = null ;
@@ -869,8 +808,13 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                if( startVM( 0 ) == 0 ) 
                                {
                                        if( sendSaveOkVM() == 0 )
-                                       {
-                                               date_last_save = System.currentTimeMillis() ;
+                                       {                                               
+                                               try {
+                                                       LocalHost.Instance().getServerStub().restartOk( LocalHost.Instance().getIP() ) ;
+                                               } catch( RemoteException e ) {
+                                                       System.err.println( "Unable to inform server about my successful restart!" ) ;
+                                                       e.printStackTrace() ;
+                                               }
                                                
                                                return 0 ;
                                        }
@@ -921,7 +865,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                return 0 ;
                        } else {
                                System.err.println( "Signal not sent!" ) ;
-//                             printProcessError( p.getErrorStream() ) ;
                                ret = printProcessError( p ) ;
                                
                                if( ! ret )
@@ -968,6 +911,8 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                System.out.println( "Saving VM ..." ) ;
                saveProcess.setStatus( true ) ;
                
+               long deb = System.currentTimeMillis() ;
+               
                machine.setStatus( "saving" ) ;
                try {
                        LocalHost.Instance().getServerStub().changeStatus( 
@@ -980,50 +925,67 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                String[] command ;
                String saveName = "" ;
                boolean error = false ;
-               boolean errorVM = false ;
                
-               if( suspendVM( 1 ) == 1 ) { error = true ; errorVM = true ; }
+               
+               if( suspendVM( 1 ) == 1 ) { return 1 ; }
+               
                
                if( ! lastSaveOk )
                {
-                       System.out.println( "Deletion of last nok archive ... " ) ;
+                       String arch1 = "", arch2 = "" ;
+                       File file = new File( working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar" )  ;
+                       if( file.exists() )
+                       {
+                               arch1 = working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar" ;
+                       }
+                       
+                       file = null ;
+                       
+                       file = new File( working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar.gz" ) ;
+                       if( file.exists() )
+                       {
+                               arch2 = working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar.gz" ;
+                       }
+                       
+                       file = null ;
+                       
+                       if( arch1.length() > 0 || arch2.length() > 0 )
+                       {                       
+                               System.out.println( "Deletion of last nok archive ... " ) ;
                        
-                       command = new String[]{ "/bin/rm", "-rf", 
-                                       working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar",
-                                       working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar.gz", } ;
+                               command = new String[]{ "/bin/rm", "-rf", 
+                                       arch1, arch2 } ;
                                                        
-                       try {
-                               procSave = Runtime.getRuntime().exec( command ) ;
-                               procSave.waitFor() ;
+                               try {
+                                       procSave = Runtime.getRuntime().exec( command ) ;
+                                       procSave.waitFor() ;
                                
-                               if( procSave.exitValue() == 0 )
-                               {
-                                       System.out.println( "Last nok archive successfully deleted." ) ;
-                               } else {
-                                       System.err.println( "Last nok archive not deleted!" ) ;
-//                                     printProcessError( p.getErrorStream() ) ;
-                                       printProcessError( procSave ) ;
+                                       if( procSave.exitValue() == 0 )
+                                       {
+                                               System.out.println( "Last nok archive successfully deleted." ) ;
+                                       } else {
+                                               System.err.println( "Last nok archive not deleted!" ) ;
+                                               printProcessError( procSave ) ;
                                        
+                                               error = true ;
+                                       }
+                               } catch( IOException e ) {
+                                       System.err.println( "Error during nok archive deletion command: " ) ;
+                                       error = true ;
+                                       e.printStackTrace() ;
+                               } catch( InterruptedException e ) {
+                                       e.printStackTrace() ;
                                        error = true ;
                                }
-                       } catch( IOException e ) {
-                               System.err.println( "Error during nok archive deletion command: " ) ;
-                               error = true ;
-                               e.printStackTrace() ;
-                       } catch( InterruptedException e ) {
-                               e.printStackTrace() ;
-                               error = true ;
                        }
                }
                
+               
                if( ! error )
                {
                        System.out.print( "Creation of the archive ... " ) ;
+                       
                        /** Archive creation **/
-//                     command = new String[]{ "/bin/tar", "-cf", 
-//                             working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar",
-//                             working_directory + "/" + machine.getDirectory() } ;
-//                     
                        command = new String[]{ "/bin/tar", "-cf", 
                                        machine.getName() + "_new_" + machine.getComputationId() + ".tar",
                                        machine.getDirectory(), "-C", working_directory } ;
@@ -1045,7 +1007,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                        
                                } else {
                                        System.err.println( "Archive not created!" ) ;
-//                                     printProcessError( p.getErrorStream() ) ;
                                        printProcessError( procSave ) ;
                                        
                                        error = true ;
@@ -1081,7 +1042,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                                System.out.println( "Archive successfully compressed." ) ;
                                        } else {
                                                System.err.println( "Archive not compressed!" ) ;
-//                                             printProcessError( p.getErrorStream() ) ;
                                                printProcessError( procSave ) ;
                                                
                                                error = true ;
@@ -1096,48 +1056,17 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                }
                        }
                        
+                       long fin = System.currentTimeMillis() ;
+                       
+                       System.out.println( "Time to create the save: " + (fin-deb)/1000 + " seconds." ) ;
+                       
                        
                        /** Restarting VM **/
-                       if( errorVM || startVM( 0 ) == 1 ) { error = true ; }
+                       if( startVM( 0 ) == 1 ) { return 1 ; }
                        
                        
                        /** Sending ok save signal **/
-//                     if( ! error )
-//                     {
-                               if( sendSaveOkVM() == 1 ) { error = true ; }
-                               
-                               
-//                     }               
-                       
-//                     /** Deletion of the tar archive **/
-//                     if( ! error )
-//                     {
-//                             command = new String[]{ "/bin/rm", 
-//                                             working_directory + "/" + machine.getName() 
-//                                             + "_new_" + machine.getComputationId() + ".tar" } ;
-//                             
-//                             try {
-//                                     Process p = Runtime.getRuntime().exec( command ) ;
-//                                     p.waitFor() ;
-//                     
-//                                     if( p.exitValue() == 0 )
-//                                     {
-//                                             System.out.println( "Archive (not compressed) successfully deleted." ) ;
-//                                     } else {
-//                                             System.err.println( "Archive (not compressed) not deleted!" ) ;
-//                                             printProcessError( p.getErrorStream() ) ;
-//                                             
-//                                             error = true ;
-//                                     }
-//                             } catch( IOException e ) {
-//                                     System.err.println( "Error during archive (not compressed) deletion command: " ) ;
-//                                     e.printStackTrace() ;
-//                                     error = true ;
-//                             } catch( InterruptedException e ) {
-//                                     e.printStackTrace() ;
-//                                     error = true ;
-//                             }
-//                     }       
+                       if( sendSaveOkVM() == 1 ) { return 1 ; }
                
                        saveName = machine.getName() + "_new_" + machine.getComputationId() + ".tar.gz" ;       
                
@@ -1149,23 +1078,13 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                        return 1 ;
                                }
                                
-                               ArrayList<ServicesClient> sn = machine.getSaveNeighbors() ;
+                               ArrayList<SaveNeighbor> sn = machine.getSaveNeighbors() ;
                                
                                for( int i = 0 ; i < sn.size() ; i++ )
                                {
-                                       String name ;
-                                       String wd ;
-                                       String snIP ;
-                                       
-                                       try {
-                                               name = sn.get( i ).getName() ;
-                                               wd = sn.get( i ).getWorkingDirectory() ;
-                                               snIP = sn.get( i ).getIPHost() ;
-                                       } catch (RemoteException e2) {
-                                               System.err.println( "Unable to retrieve information on one save neighbor!" ) ;
-                                               e2.printStackTrace() ;
-                                               continue ; 
-                                       }
+                                       String name = sn.get( i ).getName() ;
+                                       String wd = sn.get( i ).getWorkingDirectory() ;
+                                       String snIP = sn.get( i ).getIPHost() ;
                                        
                                        System.out.print( "Sending save to " + name + " ... " ) ;
                                        
@@ -1181,7 +1100,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                                        System.out.println( "Archive successfully sent." ) ;
                                                } else {
                                                        System.err.println( "Archive not sent!" ) ;
-//                                                     printProcessError( p.getErrorStream() ) ;
                                                        printProcessError( procSave ) ;
                                                
                                                        error = true ;
@@ -1248,6 +1166,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                
                serverStub = null ;
                saveProcess = new SaveProcess() ;
+               saveRequest = new SaveRequest() ;
                
                machine = new VirtualMachine() ;
                
@@ -1268,8 +1187,8 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                maxRetryVM = 10 ;
                timeRetryVM = 10000 ;
                
-               save_interleave = 30 * 60 * 1000 ;
-               date_last_save = 0 ;
+//             save_interleave = 30 * 60 * 1000 ;
+//             date_last_save = 0 ;
                
                isRestartedSave = false ;
                lastSaveOk = true ;
@@ -1296,7 +1215,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                
                System.out.println( "Connected to server " + server_ip + " on port " + server_port + "." ) ;
                
-//             LocalHost.Instance().setServerIP( server_ip ) ;
                LocalHost.Instance().setServerStub( serverStub ) ;
                
                
@@ -1309,7 +1227,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
        
        private void exportObject() 
        {
-//             ServicesClient ref = null ;
                Registry reg = null ;
                
                try 
@@ -1453,8 +1370,9 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                        {
                                try {
                                        LocalHost.Instance().getServerStub().ping( LocalHost.Instance().getIP() ) ;
-                               } catch (RemoteException e1) {
-                                       e1.printStackTrace();
+                               } catch( RemoteException e1 ) {
+                                       System.err.println( "Unable to ping the server!" ) ;
+                                       e1.printStackTrace() ;
                                }
                                
                                try {
@@ -1486,7 +1404,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                        {
                                try {
                                        serverSocket.close() ;
-//                                     socket = serverSocket.accept() ;
                                        
                                        for( int i = 0 ; i < dialogs.size() ; i++ )
                                        {
@@ -1595,7 +1512,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                        
                                        /** It's time to do a save **/
                                        if( run && line != null &&  line.equalsIgnoreCase( "save" ) )
-                                       {
+                                       {                                               
                                                try {
                                                        machine.setComputationId( Integer.parseInt( reader.readLine() ) ) ;
                                                } catch( Exception e ) {
@@ -1603,20 +1520,34 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                                        e.printStackTrace() ;
                                                }
                                                
-                                               if( (System.currentTimeMillis() - date_last_save) > save_interleave )
+                                               synchronized( saveRequest ) 
+                                               {
+                                                       try {
+                                                               LocalHost.Instance().getServerStub().requestSave( LocalHost.Instance().getIP() ) ;
+                                                       } catch( RemoteException e ) {
+                                                               System.err.println( "Unable to request save to server!" ) ;
+                                                               e.printStackTrace() ;
+                                                       }
+                                       
+                                                       try {
+                                                               saveRequest.wait() ;
+                                                       } catch( InterruptedException e ) {
+                                                               e.printStackTrace();
+                                                       }
+                                               }
+                                               
+                                               if( saveRequest.getStatus() )
                                                {
-                                                       date_last_save = System.currentTimeMillis() ; 
-                                                       
                                                        /* Close streams */
                                                        reader.close() ; reader = null ;
                                                        socket.close() ; socket = null ;
                                                        
                                                        run = false ;
+                                                       
+                                                       saveRequest.setStatus( false ) ;
                                                
-                                                       /* Starting the VM save */
+                                                       /* Requesting the VM save */
                                                        saveVM() ;
-                                                       
-                                                       date_last_save = System.currentTimeMillis() ; 
                                                } else {
                                                        sendSaveOkVM() ;
                                                }
@@ -1699,7 +1630,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                        } else {
                                System.err.println( "Last save NOK!" ) ;
                                System.err.println( "Error: " ) ;
-//                             printProcessError( p.getErrorStream() ) ;
                                printProcessError( p ) ;
                        }
                } catch( IOException e ) {
@@ -1713,14 +1643,9 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                for( int i = 0 ; i < machine.getSaveNeighbors().size() ; i++ )
                {
                        try {
-                               machine.getSaveNeighbors().get( i ).changeSaveName( save_new, save_name, machine.getComputationId() ) ;
+                               machine.getSaveNeighbors().get( i ).getStub().changeSaveName( save_new, save_name, machine.getComputationId() ) ;
                        } catch( RemoteException e ) {
-                               try {
-                                       System.err.println( "Unable to change save name on " + machine.getSaveNeighbors().get( i ).getName() + "!" ) ;
-                               } catch( RemoteException e1 ) {
-                                       System.err.println( "Unable to change save name on an unamed save neighbor!" ) ;
-                                       e1.printStackTrace() ;
-                               }
+                               System.err.println( "Unable to change save name on " + machine.getSaveNeighbors().get( i ).getName() + "!" ) ;
                                e.printStackTrace() ;
                        }
                }
@@ -1766,7 +1691,6 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                } else {
                                        System.err.println( "Change save name NOK!" ) ;
                                        System.err.println( "Error: " ) ;
-//                                     printProcessError( p.getErrorStream() ) ;
                                        printProcessError( p ) ;
                                }
                        } catch( IOException e ) {
@@ -1780,19 +1704,14 @@ public class Client extends UnicastRemoteObject implements ServicesClient
 
        
        @Override
-       public void setSavingNeighbor( ServicesClient _sn )
+       public void setSaveNeighbor( SaveNeighbor _sn )
        {
                if( _sn != null )
                {
-                       ArrayList<ServicesClient> as = new ArrayList<ServicesClient>() ;
+                       ArrayList<SaveNeighbor> as = new ArrayList<SaveNeighbor>() ;
                        as.add( _sn ) ;
                        
-                       try {
-                               System.out.println( "Save neighbor: " + _sn.getName() ) ;
-                       } catch( RemoteException e ) {
-                               System.err.println( "Unable to retrieve the name of the save neighbor!" ) ;
-                               e.printStackTrace() ;
-                       }
+                       System.out.println( "Save neighbor: " + _sn.getName() ) ;
                        
                        machine.setSaveNeighbors( as ) ;
                }
@@ -1800,19 +1719,14 @@ public class Client extends UnicastRemoteObject implements ServicesClient
        
        
        @Override
-       public void setSavingNeighbors( ArrayList<ServicesClient> _sn )
+       public void setSaveNeighbors( ArrayList<SaveNeighbor> _sn )
        {
                if( _sn != null && _sn.size() > 0 )
                {
                        System.out.print( "Save neighbors: " ) ;
                        for( int i = 0 ; i < _sn.size() ; i++ )
                        {
-                               try {
-                                       System.out.print( _sn.get( i ).getName() ) ;
-                               } catch( RemoteException e ) {
-                                       System.err.println( "Unable to retrieve the name of a save neighbor!" ) ;
-                                       e.printStackTrace() ;
-                               }
+                               System.out.print( _sn.get( i ).getName() ) ;
                                
                                if( i != _sn.size() - 1 )
                                {
@@ -1828,16 +1742,11 @@ public class Client extends UnicastRemoteObject implements ServicesClient
 
        
        @Override
-       public void addSavingNeighbor( ServicesClient _sn )
+       public void addSaveNeighbor( SaveNeighbor _sn )
        {
                if( _sn != null )
                {
-                       try {
-                               System.out.println( "Adding save neighbor: " + _sn.getName() ) ;
-                       } catch( RemoteException e ) {
-                               System.err.println( "Unable to retrieve the name of a save neighbor!" ) ;
-                               e.printStackTrace() ;
-                       }
+                       System.out.println( "Adding save neighbor: " + _sn.getName() ) ;
                        
                        machine.getSaveNeighbors().add( _sn ) ;
                }
@@ -1845,20 +1754,15 @@ public class Client extends UnicastRemoteObject implements ServicesClient
        
        
        @Override
-       public void addSavingNeighbors( ArrayList<ServicesClient> _sn )
+       public void addSaveNeighbors( ArrayList<SaveNeighbor> _sn )
        {
                if( _sn != null && _sn.size() > 0 )
                {
                        System.out.print( "Adding save neighbors: " ) ;
                        for( int i = 0 ; i < _sn.size() ; i++ )
                        {
-                               try {
-                                       System.out.print( _sn.get( i ).getName() ) ;
-                               } catch( RemoteException e ) {
-                                       System.err.println( "Unable to retrieve the name of a save neighbor!" ) ;
-                                       e.printStackTrace() ;
-                               }
-                               
+                               System.out.print( _sn.get( i ).getName() ) ;
+                                                       
                                if( i != _sn.size() - 1 )
                                {
                                        System.out.print( ", " ) ;
@@ -1873,29 +1777,26 @@ public class Client extends UnicastRemoteObject implements ServicesClient
        
        
        @Override
-       public void replaceSavingNeighbor( String _old, ServicesClient _new )
+       public void replaceSaveNeighbor( SaveNeighbor _old, SaveNeighbor _new )
        {
                System.out.print( "Replacing a save neihgbor ... " ) ;
                if( _old != null && _new != null )
                {
                        int i = 0 ;
+                       boolean change = false ;
                        
                        for( i = 0 ; i < machine.getSaveNeighbors().size() ; i++ )
                        {
-                               try {
-                                       if( machine.getSaveNeighbors().get( i ).getIPHost().equalsIgnoreCase( _old ) )
-                                       {
-                                               machine.getSaveNeighbors().set( i, _new ) ;
-                                               System.out.println( "Save neighbor successfully changed." ) ;
-                                               break ;
-                                       }
-                               } catch( RemoteException e ) {
-                                       System.err.println( "Unable to retrieve the IP address of a save neighbor!" ) ;
-                                       e.printStackTrace() ;
+                               if( machine.getSaveNeighbors().get( i ).getIPHost().equalsIgnoreCase( _old.getIPHost() ) )
+                               {
+                                       machine.getSaveNeighbors().set( i, _new ) ;
+                                       System.out.println( "Save neighbor successfully changed." ) ;
+                                       change = true ;
+                                       break ;
                                }
                        }
                        
-                       if( i == machine.getSaveNeighbors().size() )
+                       if( ! change )
                        {
                                System.out.println( "I am not concerned by the modification." ) ;
                        }
@@ -1917,36 +1818,21 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                        }
                        
                        // TODO NEIGHBORS !!!!
-                       //System.out.println( "!!!! NEIGHBORS !!!!!" ) ;
                        boolean ok = false ;
-                       boolean go = true ;
                        int i = 0 ;
                        
                        while( ! ok && i < machine.getSaveNeighbors().size() )
                        {
-                               try {
-                                       System.out.print( "Retrieving a save on " + machine.getSaveNeighbors().get( 0 ).getName() + " ... " ) ;
-                               } catch( RemoteException e1 ) {
-                                       System.err.println( "Unable to retrieve the name of a save neighbor!" ) ;
-                                       e1.printStackTrace() ;
-                               }
+                               System.out.print( "Retrieving a save on " + machine.getSaveNeighbors().get( 0 ).getName() + " ... " ) ;
                                
                                String command[] = {} ;
                                
-                               try
-                               {
-                                       command = new String[]{ "/usr/bin/scp", 
-                                                       machine.getSaveNeighbors().get( i ).getIPHost() + ":" +
-                                                       machine.getSaveNeighbors().get( i ).getWorkingDirectory() + "/" +
-                                                       machine.getSave_last(),
-                                                       working_directory } ;
-                               } catch( RemoteException e1 ) {
-                                       System.err.println( "Unable to retrieve the name of a save neighbor!" ) ;
-                                       e1.printStackTrace() ;
-                                       go = false ;
-                               }       
+                               command = new String[]{ "/usr/bin/scp", 
+                                               machine.getSaveNeighbors().get( i ).getIPHost() + ":" +
+                                               machine.getSaveNeighbors().get( i ).getWorkingDirectory() + "/" +
+                                               machine.getSave_last(),
+                                               working_directory } ;
                                
-                               if( go )
                                try {
                                        Process p = Runtime.getRuntime().exec( command ) ;
                                        p.waitFor() ;
@@ -1959,17 +1845,14 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                        } else {
                                                System.err.println( "Archive not retrieved!" ) ;
                                                System.err.println( "Error: " ) ; 
-//                                             printProcessError( p.getErrorStream() ) ;
+
                                                printProcessError( p ) ;
-//                                             error = true ;
                                        }
                                } catch( IOException e ) {
                                        System.err.println( "Error during archive retrieve command: " ) ;
                                        e.printStackTrace() ;
-//                                     error = true ;
                                } catch( InterruptedException e ) {
                                        e.printStackTrace() ;
-//                                     error = true ;
                                }
                                
                                i++ ;
@@ -1987,6 +1870,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                
        }
 
+       
        @Override
        public String getIPVM() throws RemoteException 
        {
@@ -2050,6 +1934,35 @@ public class Client extends UnicastRemoteObject implements ServicesClient
        }
        
        
+       @Override
+       public void responseSave( boolean _b )
+       {
+               synchronized( saveRequest )
+               {
+                       saveRequest.setStatus( _b ) ;
+                       try {
+                               saveRequest.notifyAll() ;
+                       } catch( Exception e ) {
+                               e.printStackTrace() ;
+                       }
+               }
+       }
+       
+       
+       private class SaveRequest
+       {
+               boolean status ;
+               
+               SaveRequest()
+               {
+                       status = false ;
+               }
+               
+               protected boolean getStatus() { return status ; }
+               
+               protected void setStatus( boolean _b ) { status = _b ; }
+       }
+       
        private class SaveProcess
        {
                boolean status ;