if( ! lastSaveOk )
{
- String arch1 = "", arch2 = "" ;
- File file = new File( working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar" ) ;
+// 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 ;
+//
+ String arch = "" ;
+ File file = new File( working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar.gz" ) ;
if( file.exists() )
{
- arch1 = working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar" ;
+ arch = working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar.gz" ;
}
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 )
+ if( arch.length() > 0 )
{
System.out.println( "Deletion of last nok archive ... " ) ;
- command = new String[]{ "/bin/rm", "-rf",
- arch1, arch2 } ;
+ command = new String[]{ "/bin/rm", "-rf", arch } ;
try {
procSave = Runtime.getRuntime().exec( command ) ;
System.out.print( "Creation of the archive ... " ) ;
/** Archive creation **/
- command = new String[]{ "/bin/tar", "-cf",
- machine.getName() + "_new_" + machine.getComputationId() + ".tar",
- machine.getDirectory(), "-C", working_directory } ;
+ command = new String[]{ "/bin/tar", "-cz", "-C", working_directory,
+ "-f", working_directory + "/" + machine.getName() + "_new_" + machine.getComputationId() + ".tar.gz",
+ machine.getDirectory() } ;
if( emergencyStop )
{
error = true ;
}
- /** Compression of the archive **/
- if( ! error )
- {
- System.out.print( "Compression of the archive ... " ) ;
- command = new String[]{ "/bin/gzip",
- working_directory + "/" + machine.getName()
- + "_new_" + machine.getComputationId() + ".tar" } ;
-
- if( emergencyStop )
- {
- return 1 ;
- }
-
- try {
- procSave = Runtime.getRuntime().exec( command ) ;
- procSave.waitFor() ;
-
- if( procSave.exitValue() == 0 )
- {
- System.out.println( "Archive successfully compressed." ) ;
- } else {
- System.err.println( "Archive not compressed!" ) ;
- printProcessError( procSave ) ;
-
- error = true ;
- }
- } catch( IOException e ) {
- System.err.println( "Error during archive compression command: " ) ;
- e.printStackTrace() ;
- error = true ;
- } catch( InterruptedException e ) {
- e.printStackTrace() ;
- error = true ;
- }
- }
+// /** Compression of the archive **/
+// if( ! error )
+// {
+// System.out.print( "Compression of the archive ... " ) ;
+// command = new String[]{ "/bin/gzip",
+// working_directory + "/" + machine.getName()
+// + "_new_" + machine.getComputationId() + ".tar" } ;
+//
+// if( emergencyStop )
+// {
+// return 1 ;
+// }
+//
+// try {
+// procSave = Runtime.getRuntime().exec( command ) ;
+// procSave.waitFor() ;
+//
+// if( procSave.exitValue() == 0 )
+// {
+// System.out.println( "Archive successfully compressed." ) ;
+// } else {
+// System.err.println( "Archive not compressed!" ) ;
+// printProcessError( procSave ) ;
+//
+// error = true ;
+// }
+// } catch( IOException e ) {
+// System.err.println( "Error during archive compression command: " ) ;
+// e.printStackTrace() ;
+// error = true ;
+// } catch( InterruptedException e ) {
+// e.printStackTrace() ;
+// error = true ;
+// }
+// }
long fin = System.currentTimeMillis() ;
// date_last_save = 0 ;
isRestartedSave = false ;
- lastSaveOk = true ;
+ lastSaveOk = false ;
/** Connection to server **/
try {
private class PingServer extends Thread
{
- private boolean run ;
+ protected boolean go ;
PingServer()
{
- run = true ;
+ go = true ;
}
- protected void stopPing() { run = false ; }
+ protected void stopPing() { go = false ; }
@Override
public void run()
{
- while( run )
+ while( go )
{
try {
LocalHost.Instance().getServerStub().ping( LocalHost.Instance().getIP() ) ;
}
try {
- Thread.sleep( 2000 ) ;
+ sleep( 2000 ) ;
} catch( InterruptedException e ) {
e.printStackTrace() ;
}
private class DialogVMServer extends Thread
{
- private boolean run ;
+ protected boolean go ;
private Socket socket ;
- private ArrayList<DialogVM> dialogs = new ArrayList<DialogVM>() ;
+// private ArrayList<DialogVM> dialogs = new ArrayList<DialogVM>() ;
DialogVMServer()
{
- run = true ;
+ go = true ;
}
protected void stopDialogVMServer()
{
- run = false ;
+ go = false ;
if( serverSocket != null )
{
try {
serverSocket.close() ;
- for( int i = 0 ; i < dialogs.size() ; i++ )
- {
- dialogs.get( i ).stopDialogVM() ;
- }
+// for( int i = 0 ; i < dialogs.size() ; i++ )
+// {
+// dialogs.get( i ).stopDialogVM() ;
+// }
} catch( IOException e ) {
e.printStackTrace() ;
System.err.println( "Unable to launch the SocketServer on port " + dialog_port + "!" ) ;
e.printStackTrace() ;
- run = false ;
+ go = false ;
}
- while( run )
+ while( go )
{
try {
socket = serverSocket.accept() ;
- dialogs.add( new DialogVM( socket ) ) ;
- dialogs.get( dialogs.size() - 1 ).start() ;
+ new DialogVM( socket ).start() ;
+// dialogs.add( new DialogVM( socket ) ) ;
+// dialogs.get( dialogs.size() - 1 ).start() ;
} catch( IOException e ) {
System.err.println( "Problem with the accept function!" ) ;
e.printStackTrace() ;
private class DialogVM extends Thread
{
- private boolean run ;
+ protected boolean go ;
private Socket socket ;
private BufferedReader reader ;
private String line ;
- DialogVM( Socket _socket ) { run = true ; socket = _socket ; }
+ DialogVM( Socket _socket ) { go = true ; socket = _socket ; }
protected void stopDialogVM()
{
- run = false ;
+ go = false ;
try {
reader.close() ; reader = null ;
stopDialogVM() ;
}
- while( run )
+// while( go )
{
try {
line = null ;
}
/** VM is starting -- retrieving informations **/
- if( run && line != null && line.equalsIgnoreCase( "infos" ) )
+ if( go && line != null && line.equalsIgnoreCase( "infos" ) )
{
/* Receiving name */
machine.setName( reader.readLine() ) ;
reader.close() ; reader = null ;
socket.close() ; socket = null ;
- run = false ;
+ go = false ;
}
/** It's time to do a save **/
- if( run && line != null && line.equalsIgnoreCase( "save" ) )
+ if( go && line != null && line.equalsIgnoreCase( "save" ) )
{
try {
machine.setComputationId( Integer.parseInt( reader.readLine() ) ) ;
reader.close() ; reader = null ;
socket.close() ; socket = null ;
- run = false ;
+ go = false ;
saveRequest.setStatus( false ) ;
/** Computation is done, we can shutdown the VM **/
- if( run && line != null && line.equalsIgnoreCase( "quit" ) )
+ if( go && line != null && line.equalsIgnoreCase( "quit" ) )
{
try {
Thread.sleep( 5000 ) ;
reader.close() ; reader = null ;
socket.close() ; socket = null ;
- run = false ;
+ go = false ;
stopVM() ;
}
} catch( IOException e ) {
+ go = false ;
e.printStackTrace() ;
}
}