Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
improve I/O Java examples
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 17 May 2016 04:39:25 +0000 (06:39 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 17 May 2016 04:39:25 +0000 (06:39 +0200)
examples/java/io/file/Node.java
examples/java/io/file/io_file.tesh
examples/java/io/storage/Client.java

index 89e992b..3044f17 100644 (file)
@@ -4,6 +4,18 @@
 /* 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;
@@ -54,13 +66,16 @@ public class Node extends Process {
     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);  
   }
 }
index 7167d37..a03eed5 100644 (file)
@@ -8,15 +8,19 @@ $ java -classpath ${classpath:=.} io/file/Main ${srcdir:=.}/../platforms/storage
 > [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...
index 509c323..e3e6fcd 100644 (file)
@@ -5,16 +5,12 @@
  * 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
  *
 ******************************************************************************/