e.printStackTrace();
System.exit( 1 ) ;
}
+
+ /* Host IP */
+ String ip = null ;
+ try {
+ InetAddress addr = InetAddress.getLocalHost() ;
+ ip = addr.getHostAddress() ;
+ } catch( final Exception e ) {
+ System.err.println( "Unalbe to retrieve host's name !" ) ;
+ e.printStackTrace();
+ System.exit( 1 ) ;
+ }
+ String names[] = decodeG5Knames( name ) ;
/* Updating node information */
n.setFrequency( frequency ) ;
n.setMemory( memory ) ;
n.setNb_cores( nbCore ) ;
n.setName( name ) ;
+ n.setCluster( names[1] ) ;
+ n.setSite( names[2] ) ;
+ n.setIP( ip ) ;
n.setMapped( false ) ;
return n ;
if ( ! _file.endsWith( ".xml" ) )
{
- _file = _file + ".xml"; // On ajoute l'extension xml au nom du fichier
+ _file = _file + ".xml"; // Adding xml extension to file
}
if( ! _file.equals( "" ) )
if ( ! _file.endsWith( ".xml" ) )
{
- _file = _file + ".xml"; // On ajoute l'extension xml au nom du fichier
+ _file = _file + ".xml"; // Adding xml extension to file
}
if( ! _file.equals( "" ) )
}
+ /**
+ * Write a mapping done in a file.
+ * @param _mp The mapping done to be write
+ * @param _path File's path
+ * @param _file File's name
+ */
+ public static void writeMapping( Mapping _mp, String _path, String _file )
+ {
+ if( _file.equals( "" ) )
+ {
+ System.err.println( "No file's name !\n" ) ;
+ return ;
+ }
+
+ if ( ! _file.endsWith( ".xml" ) )
+ {
+ _file = _file + ".xml"; // Adding xml extension to file
+ }
+
+ if( ! _file.equals( "" ) )
+ {
+ String path = "" ;
+
+ if( _path.length() != 0 )
+ {
+ path = _path+"/"+_file ;
+ } else {
+ path = new String( "./" + _file ) ;
+ }
+
+ XStream xstream = new XStream( new DomDriver() ) ;
+
+ String xml = xstream.toXML( _mp ) ;
+
+ PrintWriter ecrivain = null ;
+
+ try {
+ ecrivain = new PrintWriter( new OutputStreamWriter( new FileOutputStream( path ), "UTF8" ) ) ;
+
+ ecrivain.println( "<?xml version=\"1.0\" encoding=\"UTF8\"?>" ) ;
+ ecrivain.println( xml ) ;
+
+ ecrivain.close() ;
+ } catch( Exception e ) {
+ System.err.println( "\nError during the write opération !\n" ) ;
+ e.printStackTrace() ;
+ }
+ }
+ }
+
+
/**
* Read an application Graph from a file.
* @param _file File's name
if ( ! _file.endsWith( ".xml" ) )
{
- _file = _file + ".xml"; // On ajoute l'extension xml au nom du fichier
+ _file = _file + ".xml"; // Adding xml extension to file
}
String path = "" ;
if ( ! _file.endsWith( ".xml" ) )
{
- _file = _file + ".xml"; // On ajoute l'extension xml au nom du fichier
+ _file = _file + ".xml"; // Adding xml extension to file
}
String path = "" ;
return gr ;
}
+
+ /**
+ * Read a Mapping done from a file.
+ * @param _file File's name
+ * @param _path File's path
+ * @return The Mapping read
+ */
+ public static Mapping readMapping( String _path, String _file )
+ {
+ if ( _file.equals( "" ) )
+ {
+ System.err.println( "No file's name !\n" ) ;
+ return null ;
+ }
+
+ if ( ! _file.endsWith( ".xml" ) )
+ {
+ _file = _file + ".xml"; // Adding xml extension to file
+ }
+
+ String path = "" ;
+
+ if( _path.length() != 0 )
+ {
+ path = _path+"/"+_file ;
+ } else {
+ path = new String( "./" + _file ) ;
+ }
+
+ Mapping mp = null ;
+
+ XStream xstream = new XStream( new DomDriver() ) ;
+
+ try {
+ mp = (Mapping) xstream.fromXML( new FileInputStream( path ) ) ;
+ } catch( FileNotFoundException e ) {
+ System.err.println( "File not found !\n" ) ;
+ e.printStackTrace();
+ return null ;
+ } catch( ClassCastException e ) {
+ System.err.println( "The file does not contain a valid Grid" ) ;
+ e.printStackTrace() ;
+ return null ;
+ }
+
+ return mp ;
+ }
+
}