/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+/********************* Files and Storage handling ****************************
+ * This example implements all main file functions of the MSG API
+ *
+ * Scenario: Each host
+ * - opens a file
+ * - tries to read 10,000 bytes in this file
+ * - writes 100,000 bytes in the file
+ * - seeks back to the beginning of the file
+ * - tries to read 150,000 bytes in this file
+ *
+******************************************************************************/
+
package io.file;
import org.simgrid.msg.Msg;
Msg.info("Open file " + filename);
File file = new File(filename);
- long read = file.read(10000000,1);
+ long read = file.read(10000,1);
Msg.info("Having read " + read + " on " + filename);
- long write = file.read(100000,1);
+ long write = file.write(100000,1);
Msg.info("Having write " + write + " on " + filename);
- read = file.read(10000000,1);
+ Msg.info("Seek back to the beginning of " + filename);
+ file.seek(0,file.SEEK_SET);
+
+ read = file.read(150000,1);
Msg.info("Having read " + read + " on " + filename);
}
}
> [carl:2:(3) 0.000000] [jmsg/INFO] Open file /home/doc/simgrid/examples/platforms/g5k_cabinets.xml
> [bob:3:(4) 0.000000] [jmsg/INFO] Open file /home/doc/simgrid/examples/platforms/nancy.xml
> [bob:3:(4) 0.000040] [jmsg/INFO] Having read 4028 on /home/doc/simgrid/examples/platforms/nancy.xml
-> [bob:3:(4) 0.000040] [jmsg/INFO] Having write 0 on /home/doc/simgrid/examples/platforms/nancy.xml
-> [bob:3:(4) 0.000040] [jmsg/INFO] Having read 0 on /home/doc/simgrid/examples/platforms/nancy.xml
-> [denise:0:(1) 0.000085] [jmsg/INFO] Having read 17028 on /home/doc/simgrid/examples/platforms/g5k.xml
-> [denise:0:(1) 0.000085] [jmsg/INFO] Having write 0 on /home/doc/simgrid/examples/platforms/g5k.xml
-> [denise:0:(1) 0.000085] [jmsg/INFO] Having read 0 on /home/doc/simgrid/examples/platforms/g5k.xml
-> [carl:2:(3) 0.000226] [jmsg/INFO] Having read 22645 on /home/doc/simgrid/examples/platforms/g5k_cabinets.xml
-> [carl:2:(3) 0.000226] [jmsg/INFO] Having write 0 on /home/doc/simgrid/examples/platforms/g5k_cabinets.xml
-> [carl:2:(3) 0.000226] [jmsg/INFO] Having read 0 on /home/doc/simgrid/examples/platforms/g5k_cabinets.xml
-> [alice:1:(2) 0.000508] [jmsg/INFO] Having read 101663 on c:\Windows\setupact.log
-> [alice:1:(2) 0.000508] [jmsg/INFO] Having write 0 on c:\Windows\setupact.log
-> [alice:1:(2) 0.000508] [jmsg/INFO] Having read 0 on c:\Windows\setupact.log
-> [0.000508] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
+> [denise:0:(1) 0.000050] [jmsg/INFO] Having read 10000 on /home/doc/simgrid/examples/platforms/g5k.xml
+> [alice:1:(2) 0.000050] [jmsg/INFO] Having read 10000 on c:\Windows\setupact.log
+> [carl:2:(3) 0.000100] [jmsg/INFO] Having read 10000 on /home/doc/simgrid/examples/platforms/g5k_cabinets.xml
+> [denise:0:(1) 0.001717] [jmsg/INFO] Having write 100000 on /home/doc/simgrid/examples/platforms/g5k.xml
+> [denise:0:(1) 0.001717] [jmsg/INFO] Seek back to the beginning of /home/doc/simgrid/examples/platforms/g5k.xml
+> [alice:1:(2) 0.001717] [jmsg/INFO] Having write 100000 on c:\Windows\setupact.log
+> [alice:1:(2) 0.001717] [jmsg/INFO] Seek back to the beginning of c:\Windows\setupact.log
+> [denise:0:(1) 0.002267] [jmsg/INFO] Having read 110000 on /home/doc/simgrid/examples/platforms/g5k.xml
+> [alice:1:(2) 0.002267] [jmsg/INFO] Having read 110000 on c:\Windows\setupact.log
+> [bob:3:(4) 0.003374] [jmsg/INFO] Having write 100000 on /home/doc/simgrid/examples/platforms/nancy.xml
+> [bob:3:(4) 0.003374] [jmsg/INFO] Seek back to the beginning of /home/doc/simgrid/examples/platforms/nancy.xml
+> [carl:2:(3) 0.003433] [jmsg/INFO] Having write 100000 on /home/doc/simgrid/examples/platforms/g5k_cabinets.xml
+> [carl:2:(3) 0.003433] [jmsg/INFO] Seek back to the beginning of /home/doc/simgrid/examples/platforms/g5k_cabinets.xml
+> [bob:3:(4) 0.004414] [jmsg/INFO] Having read 104028 on /home/doc/simgrid/examples/platforms/nancy.xml
+> [carl:2:(3) 0.004533] [jmsg/INFO] Having read 110000 on /home/doc/simgrid/examples/platforms/g5k_cabinets.xml
+> [0.004533] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
* under the terms of the license (GNU LGPL) which comes with this package. */
/********************* Files and Storage handling ****************************
- * This example implements all main storage and file functions of the MSG API
+ * This example implements some storage related functions of the MSG API
*
* Scenario :
* - display information on the disks mounted by the current host
- * - create a 200,000 bytes file
- * - completely read the created file
- * - write 100,000 bytes in the file
- * - rename the created file
- * - attach some user data to a disk
- * - dump disk's contents
+ * - attach some properties to a disk
+ * - list all the storage elements in the platform
*
******************************************************************************/