Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Refunding the restart/redeployment mechanisms.
authorSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Mon, 4 Jul 2011 17:10:03 +0000 (19:10 +0200)
committerSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Mon, 4 Jul 2011 17:10:03 +0000 (19:10 +0200)
 - rewritting vmx file
 - adding flags of state

Adding some functionnalities and correction of some bugs.

src/and/hpcvm/Client.java
src/and/hpcvm/HpcVm.java
src/and/hpcvm/Server.java
src/and/hpcvm/ServicesClient.java
src/and/hpcvm/ServicesServer.java
src/and/hpcvm/User.java
src/and/hpcvm/VirtualMachine.java

index 66a43c3..793d066 100644 (file)
@@ -85,6 +85,12 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                System.err.println( "Problem with semaphore acquiring!" ) ;
                                e2.printStackTrace() ;
                        }
+
+                       // Checking first start
+                       if( machine.checkVmx() == 1 )
+                       {
+                               return 1 ;
+                       }
                        
                        boolean ret = true ;
                        int retry = 0 ;
@@ -561,41 +567,43 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                e1.printStackTrace() ;
                        }
                        
-                       if( ! isRestartedSave )
+//                     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 )
                        {
-                               /** 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 {
                                sema.release() ;
                                emergencyStop = false ;
                                return 0 ;
@@ -795,60 +803,51 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                if( isRestartedSave )
                                {
                                        // Using the specific vmx file
-                                       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() } ;
+                                       machine.setDeployFault( true ) ;
                                        
+                                       // Writing the restarted save mark
                                        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() ;
-                                       }
-                                       
-                                       // Removing lock files
-                                       System.out.print( "Removing lock files ... " ) ;
-                               
-                                       command = new String[]{ "/bin/rm", "-rf", 
-                                               working_directory + "/" + machine.getDirectory() 
-                                               + "/" + machine.getVmx_name() + ".lck" } ;
+                                               FileWriter fw = new FileWriter( new File( working_directory + "/" + machine.getDirectory() + "/fault.hpcvm" ) ) ;
+                                               fw.write( "fault!" ) ;
+                                               fw.flush() ;
+                                               fw.close() ;
+                                               fw = null ;
+                                       } catch( IOException e1 ) {
+                                               e1.printStackTrace() ;
+                                               System.err.println( "Unable to mark the fault!" ) ;
+                                       }       
                                        
-                                       try {
-                                               Process p = Runtime.getRuntime().exec( command ) ;
-                                               p.waitFor() ;
-                               
-                                               if( p.exitValue() == 0 )
-                                               {
-                                                       System.out.println( "Successfully deleted lock files." ) ;
-                                               } else {
-                                                       System.err.println( "Unsuccessful deletion of lock files!" ) ;
-//                                                     printProcessError( p.getErrorStream() ) ;
-                                                       printProcessError( p ) ;
-                                                       
-                                                       return 1 ;
-                                               }
-                                       } catch( IOException e ) {
-                                               System.err.println( "Error during lock files deletion: " ) ;
-                                               e.printStackTrace() ;
-                                       } catch( InterruptedException e ) {
-                                               e.printStackTrace() ;
+                                       if( machine.checkVmx() == 1 )
+                                       {
+                                               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 ;
@@ -871,6 +870,8 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                {
                                        if( sendSaveOkVM() == 0 )
                                        {
+                                               date_last_save = System.currentTimeMillis() ;
+                                               
                                                return 0 ;
                                        }
                                } else {
@@ -1104,6 +1105,8 @@ public class Client extends UnicastRemoteObject implements ServicesClient
 //                     if( ! error )
 //                     {
                                if( sendSaveOkVM() == 1 ) { error = true ; }
+                               
+                               
 //                     }               
                        
 //                     /** Deletion of the tar archive **/
@@ -1146,24 +1149,29 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                        return 1 ;
                                }
                                
-                               boolean ok = true ;
-                               
                                ArrayList<ServicesClient> sn = machine.getSaveNeighbors() ;
                                
                                for( int i = 0 ; i < sn.size() ; i++ )
                                {
-                                       System.out.print( "Sending save to " + sn.get( i ) + " ... " ) ;
+                                       String name ;
+                                       String wd ;
+                                       String snIP ;
+                                       
                                        try {
-                                               command = new String[]{ "/usr/bin/scp", working_directory + "/" + saveName,
-                                                               sn.get( i ).getIPHost() + ":" 
-                                                               + sn.get( i ).getWorkingDirectory() } ;
-                                       } catch( RemoteException e1 ) {
-                                               System.err.println( "Unable to retrieve save neighbor information!" ) ;
-                                               e1.printStackTrace() ;
-                                               ok = false ;
+                                               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 ; 
                                        }
+                                       
+                                       System.out.print( "Sending save to " + name + " ... " ) ;
+                                       
+                                       command = new String[]{ "/usr/bin/scp", working_directory + "/" + saveName,
+                                                               snIP + ":" + wd } ;
                                
-                                       if( ok )
                                        try {
                                                procSave = Runtime.getRuntime().exec( command ) ;
                                                procSave.waitFor() ;
@@ -1607,6 +1615,8 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                                                
                                                        /* Starting the VM save */
                                                        saveVM() ;
+                                                       
+                                                       date_last_save = System.currentTimeMillis() ; 
                                                } else {
                                                        sendSaveOkVM() ;
                                                }
@@ -1668,8 +1678,8 @@ public class Client extends UnicastRemoteObject implements ServicesClient
        @Override
        public void saveOk() 
        {
-               String save_name = machine.getName() + "_" + machine.getComputationId() +
-                       "_last.tar.gz" ;
+               String save_name = machine.getName() + "_last_" + machine.getComputationId() +
+                       ".tar.gz" ;
                
                String save_new = machine.getName() + "_new_" 
                  + machine.getComputationId() + ".tar.gz" ;
@@ -1715,6 +1725,22 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                        }
                }
                
+               // Informing the server
+               int ret = 1 ;
+               try {
+                       ret = LocalHost.Instance().getServerStub().changeSaveName( LocalHost.Instance().getIP(), save_name ) ;
+               } catch( RemoteException e ) {
+                       System.err.println( "Unable to inform the server about the new save name!" ) ;
+                       e.printStackTrace() ;
+               }
+               
+               if( ret == 0 )
+               {
+                       System.out.println( "Successfully informing the server about the new save name." ) ;
+               } else {
+                       System.err.println( "Problem on the server while informing it about the new save name!" ) ;
+               }
+               
                // Ok here
                lastSaveOk = true ;
        }
@@ -1847,7 +1873,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
        
        
        @Override
-       public void replaceSavingNeighbor( ServicesClient _old, ServicesClient _new )
+       public void replaceSavingNeighbor( String _old, ServicesClient _new )
        {
                System.out.print( "Replacing a save neihgbor ... " ) ;
                if( _old != null && _new != null )
@@ -1857,7 +1883,7 @@ public class Client extends UnicastRemoteObject implements ServicesClient
                        for( i = 0 ; i < machine.getSaveNeighbors().size() ; i++ )
                        {
                                try {
-                                       if( machine.getSaveNeighbors().get( i ).getIPHost().equalsIgnoreCase( _old.getIPVM() ) )
+                                       if( machine.getSaveNeighbors().get( i ).getIPHost().equalsIgnoreCase( _old ) )
                                        {
                                                machine.getSaveNeighbors().set( i, _new ) ;
                                                System.out.println( "Save neighbor successfully changed." ) ;
@@ -1990,6 +2016,40 @@ public class Client extends UnicastRemoteObject implements ServicesClient
        }
        
        
+       public Integer deployVM( String _name, String _archive, String _directory )
+       {
+               if( _name != null && _name.length() > 0 && _archive != null && _name.length() > 0 )
+               {
+                       File file = new File( working_directory + "/" + _archive ) ;
+                       if( ! file.exists() )
+                       {
+                               System.err.println( "There is no archive named " + _archive + " in my working directory!" ) ;
+                               file = null ;
+                               return 2 ;
+                       } else if( file.isDirectory() ) {
+                               System.err.println( _archive + " is a directory!" ) ;
+                               file = null ;
+                               return 1 ;
+                       }
+                       
+                       file = null ;
+                       
+                       machine.setName( _name ) ;
+                       machine.setInitial_archive_name( _archive ) ;
+                       machine.setDirectory( _directory ) ;
+                       
+                       if( machine.deployInitialVM() == 1 ) 
+                       {
+                               System.err.println( "Unable to deploy the initial VM archive!" ) ;
+                       } else {                                
+                               return 0 ;
+                       }
+               }
+               
+               return 1 ;
+       }
+       
+       
        private class SaveProcess
        {
                boolean status ;
index d3416a8..98994b7 100644 (file)
@@ -140,6 +140,19 @@ public class HpcVm
                                System.exit( 0 ) ;
                        }
                        
+                       if( argv[3].equalsIgnoreCase( "deploy" ) )
+                       {
+                               if( argv.length != 7 )
+                               {
+                                       usage() ;
+                                       System.exit( 1 ) ;
+                               }
+                               
+                               user.deploy( argv[4], argv[5], argv [6] ) ;
+                               
+                               System.exit( 0 ) ;
+                       }
+                       
                } else {
                        usage() ;
                        System.exit( 1 ) ;
@@ -153,6 +166,7 @@ public class HpcVm
                System.err.println( "HpcVm client server_ip server_port client_port " ) ;
                System.err.println( "HpcVm server server_port" ) ;
                System.err.println( "HpcVm user server_ip server_port {start nbVM | stop | stopAll}" ) ;
+               System.err.println( "HpcVm user server_ip server_port deploy VM_name VM_archive VM_directory" ) ;
                System.out.println() ;
        }
        
index b776409..0c696a4 100644 (file)
@@ -1,5 +1,9 @@
 package and.hpcvm ;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.rmi.Naming;
 import java.rmi.RemoteException;
 import java.rmi.registry.LocateRegistry;
@@ -103,9 +107,14 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                { 
                        if( _sn != null )
                        {
-                               save_neighbor.set( 0, _sn ) ; 
+                               if( save_neighbor.size() == 0 )
+                               {
+                                       save_neighbor.add( _sn ) ;
+                               } else {
+                                       save_neighbor.set( 0, _sn ) ;
+                               }
                                
-                               System.out.println( "My save neighbor is " + _sn ) ;
+//                             System.out.println( "My save neighbor is " + _sn ) ;
                        
                                try {
                                        client.getStub().setSavingNeighbor( _sn ) ;
@@ -179,6 +188,7 @@ public class Server extends UnicastRemoteObject implements ServicesServer
        private ConnectedMonitor monitor ;
        private DiscCount counter ;
        private ArrayList<IPAssociation> vmIPs ;
+       private String working_directory ;
        
        
        protected Server() throws RemoteException 
@@ -304,6 +314,8 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                computingClients = new ArrayList<Server.ComputingClient>() ;
                monitor = null ;
                
+               working_directory = "/localhome/vmware" ;
+               
                exportObject() ;
 
                vmIPs = new ArrayList<IPAssociation>() ;
@@ -414,7 +426,7 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                        cl.getStatus().equalsIgnoreCase( "saving" ) )
                        {
                                ComputingClient cc = cl.getComputingClient() ;
-                               ServicesClient dead = cc.getClient().getStub() ;
+//                             ServicesClient dead = cc.getClient().getStub() ;
                                String ipDead = cc.getClient().getIP() ;
                                                                
                                boolean ok = false ;
@@ -497,8 +509,8 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                                        for( int k = 0 ; k < computingClients.size() ; k++ )
                                                        {
                                                                try {
-                                                                       computingClients.get( i ).getClient().getStub().
-                                                                               replaceSavingNeighbor( dead, clients.get( i ).getStub() ) ;
+                                                                       computingClients.get( k ).getClient().getStub().
+                                                                               replaceSavingNeighbor( ipDead, clients.get( i ).getStub() ) ;
                                                                } catch( RemoteException e ) {
                                                                        System.err.println( "Unable to inform " + computingClients.get( k ).getClient().getName() +
                                                                                        " of the replacement of a save neighbor!" ) ;
@@ -506,9 +518,8 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                                                }
                                                        }
                                                        
-                                                       
                                                        System.out.println( "Dead client successfully replaced." ) ;
-                                                       // restart vms
+
                                                        break ;
                                                } else {
                                                        System.err.println( "Dead client not replaced!!" ) ;
@@ -631,8 +642,7 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                                                while( counter.getNb() != 0 )
                                                {
                                                        try {
-                                                               System.out.println( "### WAITING counter ###" ) ;
-                                                               counter.wait() ;  // !!!!! synchro
+                                                               counter.wait() ;
                                                        } catch( InterruptedException e ) {
                                                                e.printStackTrace() ;
                                                        }
@@ -707,8 +717,25 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                
                return 0 ;
        }
-
-
+       
+       
+       public Integer changeSaveName( String _ip, String _saveName )
+       {
+               if( _ip != null && _ip.length() > 0 && _saveName != null && _saveName.length() > 0 )
+               {
+                       for( int i = 0 ; i < computingClients.size() ; i ++ )
+                       {
+                               if( computingClients.get( i ).getClient().getIP().equalsIgnoreCase( _ip ) ) 
+                               {
+                                       computingClients.get( i ).setLastSave( _saveName ) ;
+                                       System.out.println( "Save name successfully change for " + _ip ) ;
+                                       return 0 ;
+                               }
+                       }
+               }
+               
+               return 1 ;
+       }
 
        @Override
        public ArrayList<ServicesClient> startApplication( int _nb ) 
@@ -819,7 +846,7 @@ public class Server extends UnicastRemoteObject implements ServicesServer
 
 
        @Override
-       public String getAssociatedIP( String _ip ) throws RemoteException 
+       public String getAssociatedIP( String _ip )
        {
                String ret = null ;
                
@@ -835,6 +862,150 @@ public class Server extends UnicastRemoteObject implements ServicesServer
                return ret ;
        }
        
+       
+       public Integer deployVM( String _name, String _archive, String _directory )
+       {
+               int pb = -1 ;
+               int nb = 0 ;
+               
+               if( _name != null && _name.length() > 0 && _archive != null && _name.length() > 0 
+                               && _directory != null && _directory.length() > 0 )
+               {
+                       System.out.println( "Deploying the VM " + _name + " (" + _archive + ") ... " ) ;
+                       
+                       File file = new File( working_directory + "/" + _archive ) ;
+                       if( ! file.exists() )
+                       {
+                               System.err.println( "There is no archive named " + _archive + " in my working directory!" ) ;
+                               file = null ;
+                               return 1 ;
+                       } else if( file.isDirectory() ) {
+                               System.err.println( _archive + " is a directory!" ) ;
+                               file = null ;
+                               return 1 ;
+                       }
+                       
+                       file = null ;
+                       
+                       // TODO do a better deployment !!
+                       int ret ;
+                       boolean error ;
+                       
+                       pb = 0 ;
+                       
+                       for( int i = 0 ; i < clients.size() ; i++ )
+                       {
+                               ret = 1 ;
+                               error = false ;
+                               try {
+                                       ret = clients.get( i ).getStub().deployVM( _name, _archive, _directory ) ;
+                               } catch( RemoteException e ) {
+                                       System.err.println( "Unable to deploy the VM on " + clients.get( i ).getName() + "!" ) ;
+                                       e.printStackTrace() ;
+                               }
+                               
+                               // The client does not have the archive, we have to send it.
+                               if( ret == 2 )
+                               {
+                                       System.out.print( "Sending VM archive to " + clients.get( i ).getName() + " ... " ) ;
+                                       
+                                       String wd = "" ;
+                                       String snIP = "" ;
+                                       error = false ;
+                                       
+                                       try {
+                                               wd = clients.get( i ).getStub().getWorkingDirectory() ;
+                                               snIP = clients.get( i ).getStub().getIPHost() ;
+                                       } catch (RemoteException e2) {
+                                               System.err.println( "Unable to retrieve information on " + clients.get( i ).getName() + "!" ) ;
+                                               e2.printStackTrace() ;
+                                               error = true ;
+                                               pb++ ;
+                                       }
+                                       
+                                       String[] command = new String[]{ "/usr/bin/scp", working_directory + "/" + _archive,
+                                                               snIP + ":" + wd } ;
+                               
+                                       if( ! error )
+                                       try {
+                                               Process proc = Runtime.getRuntime().exec( command ) ;
+                                               proc.waitFor() ;
+                       
+                                               if( proc.exitValue() == 0 )
+                                               {
+                                                       System.out.println( "Initial VM archive successfully sent." ) ;
+                                               } else {
+                                                       System.err.println( "Initial VM archive not sent!" ) ;
+//                                                     printProcessError( p.getErrorStream() ) ;
+                                                       System.err.println( "Error: " + proc.exitValue() ) ;
+                                                       BufferedReader b = new BufferedReader( new InputStreamReader( proc.getErrorStream() ) ) ;
+                                                       
+                                                       String l ;
+                                                       try {
+                                                               while( (l = b.readLine()) != null )
+                                                               {
+                                                                       System.err.println( l ) ;
+                                                               }
+                                                       } catch( IOException e ) {
+                                                                       e.printStackTrace() ;
+                                                       }
+                                                       
+                                                       error = true ;
+                                                       pb++ ;
+                                               }
+                                       } catch( IOException e ) {
+                                               System.err.println( "Error during initial VM archive send command: " ) ;
+                                               e.printStackTrace() ;
+                                               error = true ;
+                                               pb++ ;
+                                       } catch( InterruptedException e ) {
+                                               e.printStackTrace() ;
+                                               error = true ;
+                                               pb++ ;
+                                       }
+                               
+                               
+                                       if( error )
+                                       {
+                                               continue ;
+                                       }
+                               
+                                       // Second try ...
+                                       ret = 1 ;
+                                       try {
+                                               ret = clients.get( i ).getStub().deployVM( _name, _archive, _directory ) ;
+                                       } catch( RemoteException e ) {
+                                               System.err.println( "Unable to deploy the VM on " + clients.get( i ).getName() + "!" ) ;
+                                               e.printStackTrace() ;
+                                               pb++ ;
+                                       }
+                               }
+                               
+                               if( ret == 0 )
+                               {
+                                       System.out.println( "Initial VM archive successfully deployed on " + clients.get( i ).getName() + "." ) ;
+                                       nb++ ;
+                               }
+                       }
+               }
+               
+               if( pb > 0 )
+               {
+                       if( pb == 1 )
+                               System.err.println( "** " + pb + " machine is not deployed!" ) ;
+                       if( pb > 1 )
+                               System.err.println( "** " + pb + " machine(s) are not deployed!" ) ;
+               }
+               
+               return nb ;
+       }
+       
+       
+       public String getWorkingDirectory()
+       {
+               return working_directory ;
+       }
+       
 }
 
 /** La programmation est un art, respectons ceux qui la pratiquent !! **/
index 6e4945c..4ea41da 100644 (file)
@@ -38,6 +38,8 @@ public interface ServicesClient extends Remote
        
        public void saveOk() throws RemoteException ;
        
+       public Integer deployVM( String _name, String _archive, String _directory ) throws RemoteException ;
+       
        public void changeSaveName( String _n1, String _n2, int _id ) throws RemoteException ;
        
        public void setSavingNeighbor( ServicesClient _sn ) throws RemoteException ;
@@ -48,7 +50,7 @@ public interface ServicesClient extends Remote
        
        public void addSavingNeighbors( ArrayList<ServicesClient> _sn ) throws RemoteException ;
        
-       public void replaceSavingNeighbor( ServicesClient _old, ServicesClient _new ) throws RemoteException ;
+       public void replaceSavingNeighbor( String _old, ServicesClient _new ) throws RemoteException ;
        
        public int retrieveSave( String _saveName ) throws RemoteException ;
        
index 6eb2f97..60ac97b 100644 (file)
@@ -16,11 +16,18 @@ public interface ServicesServer extends Remote
        
        public Integer saveOk( String _ip, String _saveName ) throws RemoteException ;
        
+       public Integer changeSaveName( String _ip, String _saveName ) throws RemoteException ;
+       
        public ArrayList<ServicesClient> startApplication( int _nb ) throws RemoteException ;
        
        public void endApplication() throws RemoteException ;
        
        public void stop() throws RemoteException ;
+       
+       public Integer deployVM( String _name, String _archive, String _directory ) throws RemoteException ;
+       
+       public String getWorkingDirectory() throws RemoteException ;
+
 }
 
 
index e70bc43..63e8028 100644 (file)
@@ -86,6 +86,25 @@ public class User
                }
        }
        
+       
+       public void deploy( String _name, String _archive, String _directory )
+       {
+               int nb = 0 ;
+               try {
+                       nb = ss.deployVM( _name, _archive, _directory ) ;
+               } catch (RemoteException e) {
+                       e.printStackTrace();
+               }
+               
+               if( nb > 0 )
+               {
+                       if( nb == 1 )
+                               System.out.println( "There is only 1 machine available." ) ;
+                       if( nb > 1 )
+                               System.out.println( "There are " + nb + " machines available." ) ;
+               }
+       }
+       
 }
 
 
index 1cba1f1..95a6683 100644 (file)
@@ -1,6 +1,10 @@
 package and.hpcvm ;
 
 import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
@@ -12,8 +16,8 @@ public class VirtualMachine
        private String initial_archive_name ;
        private String directory ;
        private String vmx_name ;
-       private String vmx_name_normal ;
-       private String vmx_name_crash ;
+       private String vmx_name_first ;
+       private String vmx_name_initial ;
        private String save_current ;
        private String save_last ;
        private int no_save ;
@@ -25,6 +29,9 @@ public class VirtualMachine
        private String clientInVM ;
        private String vm_user ;
        private String vm_user_passwd ;
+       private boolean deploy ;
+       private boolean first ;
+       private boolean deployFault ;
        
        public VirtualMachine()
        {
@@ -33,8 +40,8 @@ public class VirtualMachine
                initial_archive_name = "VmTest.tgz" ;
                directory = "VmTest" ;
                vmx_name = "VmTest.vmx" ;
-               vmx_name_normal = "VmTest.vmx.normal" ;
-               vmx_name_crash = "VmTest.vmx.crash" ;
+               vmx_name_first = "VmTest.vmx.first" ;
+               vmx_name_initial = "VmTest.vmx.initial" ;
                save_current = "VmTest.tgz" ;
                save_last = "VmTest.tgz" ;
                working_directory = "/localhome/vmware" ;
@@ -47,6 +54,15 @@ public class VirtualMachine
                clientInVM = "/home/mpi/InGuest" ;
                vm_user = "mpi" ;
                vm_user_passwd = "mpi" ;
+               first = false ;
+               deploy = false ;
+               deployFault = false ;
+       }
+       
+       
+       public void setDeployFault( boolean _bool )
+       {
+               deployFault = _bool ;
        }
        
        
@@ -170,21 +186,21 @@ public class VirtualMachine
                this.vmx_name = vmx_name;
        }
 
-       public String getVmx_name_normal() {
-               return vmx_name_normal;
-       }
+//     public String getVmx_name_normal() {
+//             return vmx_name_normal;
+//     }
 
-       public void setVmx_name_normal(String vmx_name_normal) {
-               this.vmx_name_normal = vmx_name_normal;
-       }
+//     public void setVmx_name_normal(String vmx_name_normal) {
+//             this.vmx_name_normal = vmx_name_normal;
+//     }
 
-       public String getVmx_name_crash() {
-               return vmx_name_crash;
-       }
+//     public String getVmx_name_crash() {
+//             return vmx_name_crash;
+//     }
 
-       public void setVmx_name_crash(String vmx_name_crash) {
-               this.vmx_name_crash = vmx_name_crash;
-       }
+//     public void setVmx_name_crash(String vmx_name_crash) {
+//             this.vmx_name_crash = vmx_name_crash;
+//     }
 
        public String getSave_current() {
                return save_current;
@@ -230,7 +246,7 @@ public class VirtualMachine
        {
                computation_id = _id ;
        }
-
+       
        
        public int deployLastSave()
        {
@@ -256,18 +272,8 @@ public class VirtualMachine
                {
                        System.out.println( "Successful deletion of current VM." ) ;
                } else {
-                       System.err.println( "Error: " + pr.exitValue() ) ;
-                       BufferedReader b = new BufferedReader( new InputStreamReader( pr.getErrorStream() ) ) ;
-                       
-                       String l ;
-                       try {
-                               while( (l = b.readLine()) != null )
-                               {
-                                       System.err.println( l ) ;
-                               }
-                       } catch( IOException e ) {
-                                       e.printStackTrace() ;
-                       }
+                       System.err.println( "Unssuccessful deletion of current VM!" ) ;
+                       printProcessError( pr ) ;
                }
                
                System.out.print( "Deploying the last save ... " ) ;
@@ -295,22 +301,575 @@ public class VirtualMachine
                        System.out.println( "Successful extraction of the save archive." ) ;
                        return 0 ;
                } else {
-                       System.err.println( "Error: " + pr.exitValue() ) ;
-                       BufferedReader b = new BufferedReader( new InputStreamReader( pr.getErrorStream() ) ) ;
+                       System.err.println( "unSuccessful extraction of the save archive!" ) ;
+                       printProcessError( pr ) ;
+               }
+               
+               return 1 ;
+       }
+       
+       
+       public int deployInitialVM()
+       {
+               System.out.print( "Removing current VM ... " ) ;
+               
+               String[] command = new String[] { "/bin/rm", "-rf", 
+                               working_directory + "/" + directory } ;
+               Process pr = null ;
+               try {
+                       pr = Runtime.getRuntime().exec( command ) ;
+//                     synchronized( pr ){
+                       pr.waitFor() ; //;}
+               } catch( IOException e ) {
+                       System.err.println( "Error while removing current VM!" ) ;
+                       e.printStackTrace() ;
+                       return 1 ;
+               } catch( InterruptedException e ) {
+                       e.printStackTrace() ;
+                       return 1 ;
+               }
+               
+               if( pr.exitValue() == 0 )
+               {
+                       System.out.println( "Successful deletion of current VM." ) ;
+               } else {
+                       System.err.println( "Unsuccessful deletion of current VM!" ) ;
+                       printProcessError( pr ) ;
+               }
+               
+               System.out.print( "Deploying the initial archive ... " ) ;
+               
+               command = new String[] { "/bin/tar", "-xzf", 
+                               working_directory + "/" + save_last,
+                               "-C", working_directory } ;
+               pr = null ;
+               try {
+                       pr = Runtime.getRuntime().exec( command ) ;
+//                     synchronized( pr ){
+                       pr.waitFor() ; //;}
+               } catch( IOException e ) {
+                       System.err.println( "Error while deploying the initial archive!" ) ;
+                       e.printStackTrace() ;
+                       return 1 ;
+               } catch( InterruptedException e ) {
+                       e.printStackTrace() ;
+                       return 1 ;
+               }
+                       
+               
+               if( pr.exitValue() == 0 )
+               {
+                       System.out.println( "Successful extraction of the initial archive." ) ;
+                       deploy = true ;
+               } else {
+                       System.err.println( "Unsuccessful extraction of the initial archive!" ) ;
+                       printProcessError( pr ) ;
+                       return 1 ;
+               }
+               
+               try {
+                       FileWriter fw = new FileWriter( new File( working_directory + "/" + directory + "/initial.hpcvm" ) ) ;
+                       fw.write( "initial!" ) ;
+                       fw.flush() ;
+                       fw.close() ;
+                       fw = null ;
+                       return 0 ;
+               } catch( IOException e1 ) {
+                       e1.printStackTrace() ;
+                       System.err.println( "Unable to mark the initial deployment!" ) ;
+               }
+               
+               return 1 ;
+       }
+
+
+       public int checkVmx() 
+       {
+               // Initial deployment
+               File file = new File( working_directory + "/" + directory + "/initial.hpcvm" ) ;
+               
+               if( file.exists() )
+               {
+                       deploy = true ;
+               }
+               
+               // First execution
+               file = null ;
+               file = new File( working_directory + "/" + directory + "/first.hpcvm" ) ;
+               
+               if( file.exists() )
+               {
+                       first = true ;
+               }
+               
+               // Redeployment after a fault
+               file = null ;
+               file = new File( working_directory + "/" + directory + "/fault.hpcvm" ) ;
+               
+               if( file.exists() )
+               {
+                       deploy = false ;
+                       first = false ;
+                       deployFault = true ;
+               }
+               
+               file = null ;
+               
+               // Deployment of the VM
+               
+               if( deploy )
+               {
+                       System.out.print( "Saving the initial VMX file ... " ) ;
+                       
+                       String[] command = new String[]{ "/bin/cp", 
+                                       working_directory + "/" + directory + "/" + vmx_name,
+                                       working_directory + "/" + directory + "/" + vmx_name_initial } ;
                        
-                       String l ;
                        try {
-                               while( (l = b.readLine()) != null )
+                               Process p = Runtime.getRuntime().exec( command ) ;
+                               p.waitFor() ;
+               
+                               if( p.exitValue() == 0 )
                                {
-                                       System.err.println( l ) ;
+                                       System.out.println( "Successfully saved initial the VMX file." ) ;
+                               } else {
+                                       System.err.println( "Unsuccessful save of the initial VMX file!" ) ;
+                                       printProcessError( p ) ;
+                                       return 1 ;
                                }
                        } catch( IOException e ) {
-                                       e.printStackTrace() ;
+                               System.err.println( "Error during initial VMX file save: " ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       } catch( InterruptedException e ) {
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                       
+                       System.out.print( "Rewritting WMX file ... " ) ;
+                       
+                       
+                       FileReader fin = null ;
+                       try {
+                               fin = new FileReader( new File( working_directory + "/" + directory + "/" + vmx_name_initial ) );
+                       } catch( FileNotFoundException e ) {
+                               System.err.println( "Unable to open the initial VMX file!" ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
                        }
+                               
+                       BufferedReader bin = new BufferedReader( fin ) ;
+                       String line = "" ;
+                       FileWriter fout = null ;
+                       
+                       try {
+                               fout = new FileWriter( new File( working_directory + "/" + directory + "/" + vmx_name ) ) ;
+                       } catch( IOException e ) {
+                               System.err.println( "Unable to open the VMX file!" ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                               
+                       // Keeping only some information
+                       // -- this force VmWare to generate new identifiers and MAC address
+                       while( line != null )
+                       {               
+                               try {
+                                       line = bin.readLine() ;
+                                       if( line != null )
+                                       if(    ! line.contains( "ethernet0.addressType" ) 
+                                           && ! line.contains( "uuid.location " ) 
+                                           && ! line.contains( "uuid.bios " ) 
+                                           && ! line.contains( "ethernet0.generatedAddress " ) 
+                                           && ! line.contains( "ethernet0.generatedAddressOffset " ) 
+                                         )
+                                       {
+                                               fout.write( line + "\n" ) ;
+                                       }
+                               } catch( IOException e ) {}
+                       }
+                               
+                       try {
+                               bin.close() ;
+                       } catch (IOException e) {
+                               System.err.println( "Unable to close the initial VMX file!" ) ;
+                               e.printStackTrace() ;
+                       }
+                               
+                       // Adding the copy information
+                       try
+                       {
+                               fout.write( "msg.autoAnswer = \"TRUE\"\n" ) ;
+                               fout.write( "answer.msg.checkpoint.cpufeaturecheck.fail = \"_Yes\"\n" ) ;
+                               fout.write( "checkpoint.vmState = \"\"\n" ) ;
+                               fout.write( "answer.msg.uuid.altered = \"I _copied it\"\n" ) ;
+                       } catch( IOException e ) {
+                               System.err.println( "Unable to add infortion to VMX file!" ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                               
+                       try {
+                               fout.close() ;
+                       } catch( IOException e ) {
+                               System.err.println( "Unable to close the VMX file!" ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                       
+                       System.out.println( "Successful rewrite of the VMX file." ) ;
+                       
+                       // Removing the initial mark
+                       System.out.print( "Removing the deployment mark ... " ) ;
+                       
+                       command = new String[]{ "/bin/rm", 
+                                       working_directory + "/" + directory + "/initial.hpcvm" } ;
+                       
+                       try {
+                               Process p = Runtime.getRuntime().exec( command ) ;
+                               p.waitFor() ;
+               
+                               if( p.exitValue() == 0 )
+                               {
+                                       System.out.println( "Successfully deletion of the deployment mark." ) ;
+                               } else {
+                                       System.err.println( "Unsuccessful deletion of the deployment mark!" ) ;
+                                       printProcessError( p ) ;
+                                       return 1 ;
+                               }
+                       } catch( IOException e ) {
+                               System.err.println( "Error during deletion of the deployment mark: " ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       } catch( InterruptedException e ) {
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                       
+                       deploy = false ;
+                       
+                       // Writing the first start mark
+                       try {
+                               FileWriter fw = new FileWriter( new File( working_directory + "/" + directory + "/first.hpcvm" ) ) ;
+                               fw.write( "first!\n" ) ;
+                               fw.flush() ;
+                               fw.close() ;
+                               fw = null ;
+                               return 0 ;
+                       } catch( IOException e1 ) {
+                               e1.printStackTrace() ;
+                               System.err.println( "Unable to mark the first run of the VM!" ) ;
+                       }       
+               }
+               
+               
+               // First start of the VM
+               
+               if( first )
+               {
+                       System.out.print( "Saving the first start VMX file ... " ) ;
+                       
+                       String[] command = new String[]{ "/bin/cp", 
+                                       working_directory + "/" + directory + "/" + vmx_name,
+                                       working_directory + "/" + directory + "/" + vmx_name_first } ;
+                       
+                       try {
+                               Process p = Runtime.getRuntime().exec( command ) ;
+                               p.waitFor() ;
+               
+                               if( p.exitValue() == 0 )
+                               {
+                                       System.out.println( "Successfully saved the first start VMX file." ) ;
+                               } else {
+                                       System.err.println( "Unsuccessful save of the first start VMX file!" ) ;
+                                       printProcessError( p ) ;
+                                       return 1 ;
+                               }
+                       } catch( IOException e ) {
+                               System.err.println( "Error during first start VMX file save: " ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       } catch( InterruptedException e ) {
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                       
+                       System.out.print( "Rewritting WMX file ... " ) ;
+                       
+                       
+                       FileReader fin = null ;
+                       try {
+                               fin = new FileReader( new File( working_directory + "/" + directory + "/" + vmx_name_first ) );
+                       } catch( FileNotFoundException e ) {
+                               System.err.println( "Unable to open the first start VMX file!" ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                               
+                       BufferedReader bin = new BufferedReader( fin ) ;
+                       String line = "" ;
+                       FileWriter fout = null ;
+                       
+                       try {
+                               fout = new FileWriter( new File( working_directory + "/" + directory + "/" + vmx_name ) ) ;
+                       } catch( IOException e ) {
+                               System.err.println( "Unable to open the VMX file!" ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                               
+                       // Keeping all information
+                       // -- except copy information
+                       while( line != null )
+                       {               
+                               try {
+                                       line = bin.readLine() ;
+                                       if( line != null )
+                                       if( ! line.contains( "answer.msg.uuid.altered " ) )
+                                       {
+                                               fout.write( line + "\n" ) ;
+                                       }
+                               } catch( IOException e ) {}
+                       }
+                               
+                       try {
+                               bin.close() ;
+                       } catch (IOException e) {
+                               System.err.println( "Unable to close the first start VMX file!" ) ;
+                               e.printStackTrace() ;
+                       }
+                               
+                       try {
+                               fout.close() ;
+                       } catch( IOException e ) {
+                               System.err.println( "Unable to close the VMX file!" ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                       
+                       System.out.println( "Successful rewrite of the VMX file." ) ;
+                       
+                       // Removing the initial mark
+                       System.out.print( "Removing the first start mark ... " ) ;
+                       
+                       command = new String[]{ "/bin/rm", 
+                                       working_directory + "/" + directory + "/first.hpcvm" } ;
+                       
+                       try {
+                               Process p = Runtime.getRuntime().exec( command ) ;
+                               p.waitFor() ;
+               
+                               if( p.exitValue() == 0 )
+                               {
+                                       System.out.println( "Successfully deletion of the first start mark." ) ;
+                               } else {
+                                       System.err.println( "Unsuccessful deletion of the first start mark!" ) ;
+                                       printProcessError( p ) ;
+                                       return 1 ;
+                               }
+                       } catch( IOException e ) {
+                               System.err.println( "Error during deletion of the first start mark: " ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       } catch( InterruptedException e ) {
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                       
+                       first = false ;
+
+                       return 0 ;
                }
                
+               
+               // Redeployment after a fault of a VM
+               
+               if( deployFault )
+               {
+                       System.out.print( "Saving the original VMX file ... " ) ;
+                       
+                       String[] command = new String[]{ "/bin/cp", 
+                                       working_directory + "/" + directory + "/" + vmx_name,
+                                       working_directory + "/" + directory + "/" + vmx_name_first } ;
+                       
+                       try {
+                               Process p = Runtime.getRuntime().exec( command ) ;
+                               p.waitFor() ;
+               
+                               if( p.exitValue() == 0 )
+                               {
+                                       System.out.println( "Successfully saved the original VMX file." ) ;
+                               } else {
+                                       System.err.println( "Unsuccessful save of the original VMX file!" ) ;
+                                       printProcessError( p ) ;
+                                       return 1 ;
+                               }
+                       } catch( IOException e ) {
+                               System.err.println( "Error during original VMX file save: " ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       } catch( InterruptedException e ) {
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                       
+                       System.out.print( "Rewritting WMX file ... " ) ;
+                       
+                       
+                       FileReader fin = null ;
+                       try {
+                               fin = new FileReader( new File( working_directory + "/" + directory + "/" + vmx_name_first ) );
+                       } catch( FileNotFoundException e ) {
+                               System.err.println( "Unable to open the original VMX file!" ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                               
+                       BufferedReader bin = new BufferedReader( fin ) ;
+                       String line = "" ;
+                       FileWriter fout = null ;
+                       
+                       try {
+                               fout = new FileWriter( new File( working_directory + "/" + directory + "/" + vmx_name ) ) ;
+                       } catch( IOException e ) {
+                               System.err.println( "Unable to open the VMX file!" ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                               
+                       // Keeping all information
+                       while( line != null )
+                       {               
+                               try {
+                                       line = bin.readLine() ;
+                                       if( line != null )
+                                       if( ! line.contains( "answer.msg.uuid.altered " ) )
+                                       {
+                                               fout.write( line + "\n" ) ;
+                                       }
+                               } catch( IOException e ) {}
+                       }
+                               
+                       try {
+                               bin.close() ;
+                       } catch (IOException e) {
+                               System.err.println( "Unable to close the original VMX file!" ) ;
+                               e.printStackTrace() ;
+                       }
+                       
+                       // Writing information to indicate that the VM has been moved
+                       try {
+                               fout.write( "answer.msg.uuid.altered = \"I _moved it\"\n" ) ;
+                       } catch (IOException e1) {
+                               System.err.println( "Unable to indicate that the VM has been moved in the VMX file!" ) ;
+                               e1.printStackTrace() ;
+                       }
+                               
+                       try {
+                               fout.close() ;
+                       } catch( IOException e ) {
+                               System.err.println( "Unable to close the VMX file!" ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                       
+                       System.out.println( "Successful rewrite of the VMX file." ) ;
+                       
+                       // Removing lock files
+                       System.out.print( "Removing lock files ... " ) ;
+               
+                       command = new String[]{ "/bin/rm", "-rf", 
+                               working_directory + "/" + directory 
+                               + "/" + vmx_name + ".lck" } ;
+                       
+                       try {
+                               Process p = Runtime.getRuntime().exec( command ) ;
+                               p.waitFor() ;
+               
+                               if( p.exitValue() == 0 )
+                               {
+                                       System.out.println( "Successfully deleted lock files." ) ;
+                               } else {
+                                       System.err.println( "Unsuccessful deletion of lock files!" ) ;
+//                                     printProcessError( p.getErrorStream() ) ;
+                                       printProcessError( p ) ;
+                                       
+                                       return 1 ;
+                               }
+                       } catch( IOException e ) {
+                               System.err.println( "Error during lock files deletion: " ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       } catch( InterruptedException e ) {
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                       
+                       // Removing the initial mark
+                       System.out.print( "Removing the fault mark ... " ) ;
+                       
+                       command = new String[]{ "/bin/rm", 
+                                       working_directory + "/" + directory + "/fault.hpcvm" } ;
+                       
+                       try {
+                               Process p = Runtime.getRuntime().exec( command ) ;
+                               p.waitFor() ;
+               
+                               if( p.exitValue() == 0 )
+                               {
+                                       System.out.println( "Successfully deletion of the fault mark." ) ;
+                               } else {
+                                       System.err.println( "Unsuccessful deletion of the fault mark!" ) ;
+                                       printProcessError( p ) ;
+                                       return 1 ;
+                               }
+                       } catch( IOException e ) {
+                               System.err.println( "Error during deletion of the fault mark: " ) ;
+                               e.printStackTrace() ;
+                               return 1 ;
+                       } catch( InterruptedException e ) {
+                               e.printStackTrace() ;
+                               return 1 ;
+                       }
+                       
+                       deployFault = false ;
+                       
+                       // Writing the first start mark
+                       try {
+                               FileWriter fw = new FileWriter( new File( working_directory + "/" + directory + "/first.hpcvm" ) ) ;
+                               fw.write( "first!" ) ;
+                               fw.flush() ;
+                               fw.close() ;
+                               fw = null ;
+                               first = true ;
+                               return 0 ;
+                       } catch( IOException e1 ) {
+                               e1.printStackTrace() ;
+                               System.err.println( "Unable to mark the first run of the VM!" ) ;
+                       }       
+               }               
+               
                return 1 ;
        }
+       
+       
+       private void printProcessError( Process _p )
+       {
+               if( _p != null )
+               {
+                       System.err.println( "Error: " + _p.exitValue() ) ;
+                       BufferedReader br = new BufferedReader( new InputStreamReader( _p.getErrorStream() ) ) ;
+                       String line ;
+                       try {
+                               while( (line = br.readLine()) != null )
+                               {
+                                       System.err.println( line ) ;
+                               }
+                       } catch( IOException e ) {
+                               e.printStackTrace() ;
+                       }
+               }
+       }
 
        
 }