private Status status ;
private int computation_id ;
private String working_directory ;
- private ArrayList<String> save_neighbors ;
+ private ArrayList<ServicesClient> save_neighbors ;
private String clientInVM ;
private String vm_user ;
private String vm_user_passwd ;
status = new Status() ;
status.setStatus( "stopped" ) ;
computation_id = -1 ;
- save_neighbors = new ArrayList<String>() ;
- save_neighbors.add( "127.0.0.1" ) ;
+ save_neighbors = new ArrayList<ServicesClient>() ;
clientInVM = "/home/mpi/InGuest" ;
vm_user = "mpi" ;
vm_user_passwd = "mpi" ;
}
- public ArrayList<String> getSaveNeighbors() { return save_neighbors ; }
+ public ArrayList<ServicesClient> getSaveNeighbors() { return save_neighbors ; }
@SuppressWarnings("unchecked")
- public void setSaveNeighbors( ArrayList<String> _sn )
+ public void setSaveNeighbors( ArrayList<ServicesClient> _sn )
{
if( _sn != null )
{
- save_neighbors = (ArrayList<String>) _sn.clone() ;
+ save_neighbors = (ArrayList<ServicesClient>) _sn.clone() ;
}
}
- public void addSaveNeighbor( String _sn )
+ public void addSaveNeighbor( ServicesClient _sn )
{
- if( _sn != null && _sn.length() > 0 )
+ if( _sn != null )
{
save_neighbors.add( _sn ) ;
}
}
public void setSave_last(String save_last) {
+ System.out.println( "Save name: " + save_last ) ;
this.save_last = save_last;
}
public int deployLastSave()
{
- System.out.print( "Deploying the last save ..." ) ;
+ System.out.print( "Removing current VM ... " ) ;
- String[] command = new String[] { "/bin/tar", "-xzvf",
+ 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( "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.out.print( "Deploying the last save ... " ) ;
+
+ command = new String[] { "/bin/tar", "-xzf",
working_directory + "/" + save_last,
"-C", working_directory } ;
- Process pr = null ;
+ pr = null ;
try {
pr = Runtime.getRuntime().exec( command ) ;
// synchronized( pr ){
} catch( IOException e ) {
System.err.println( "Error while deploying the last secure save!" ) ;
e.printStackTrace() ;
+ return 1 ;
} catch( InterruptedException e ) {
e.printStackTrace() ;
+ return 1 ;
}
+
if( pr.exitValue() == 0 )
{
System.out.println( "Successful extraction of the save archive." ) ;