1 /* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 /********************* Files and Storage handling ****************************
7 * This example implements all main file functions of the MSG API
11 * - tries to read 10,000 bytes in this file
12 * - writes 100,000 bytes in the file
13 * - seeks back to the beginning of the file
14 * - tries to read 150,000 bytes in this file
16 ******************************************************************************/
20 import org.simgrid.msg.Msg;
21 import org.simgrid.msg.File;
22 import org.simgrid.msg.Host;
23 import org.simgrid.msg.Process;
24 import org.simgrid.msg.MsgException;
26 public class Node extends Process {
27 private static String file1 = "/doc/simgrid/examples/platforms/g5k.xml";
28 private static String file2 = "\\Windows\\setupact.log";
29 private static String file3 = "/doc/simgrid/examples/platforms/g5k_cabinets.xml";
30 private static String file4 = "/doc/simgrid/examples/platforms/nancy.xml";
34 public Node(Host host, int number) {
35 super(host, Integer.toString(number), null);
39 public void main(String[] args) throws MsgException {
40 String mount = "/home";
44 fileName = mount + file1;
48 fileName = mount + file2;
51 fileName = mount + file3;
54 fileName = mount + file4;
57 fileName = mount + file1;
61 Msg.info("Open file " + fileName);
62 File file = new File(fileName);
64 long read = file.read(10000,1);
65 Msg.info("Having read " + read + " on " + fileName);
67 long write = file.write(100000,1);
68 Msg.info("Having write " + write + " on " + fileName);
70 Msg.info("Seek back to the beginning of " + fileName);
71 file.seek(0,File.SEEK_SET);
73 read = file.read(150000,1);
74 Msg.info("Having read " + read + " on " + fileName);