1 /* Copyright (c) 2012-2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 /********************* Files and Storage handling ****************************
8 * This example implements all main file functions of the MSG API
12 * - tries to read 10,000 bytes in this file
13 * - writes 100,000 bytes in the file
14 * - seeks back to the beginning of the file
15 * - tries to read 150,000 bytes in this file
17 ******************************************************************************/
21 import org.simgrid.msg.Msg;
22 import org.simgrid.msg.File;
23 import org.simgrid.msg.Host;
24 import org.simgrid.msg.Process;
25 import org.simgrid.msg.HostNotFoundException;
26 import org.simgrid.msg.MsgException;
28 public class Node extends Process {
29 private static String FILENAME1 = "/doc/simgrid/examples/platforms/g5k.xml";
30 private static String FILENAME2 = "\\Windows\\setupact.log";
31 private static String FILENAME3 = "/doc/simgrid/examples/platforms/g5k_cabinets.xml";
32 private static String FILENAME4 = "/doc/simgrid/examples/platforms/nancy.xml";
36 public Node(Host host, int number) throws HostNotFoundException {
37 super(host, Integer.toString(number), null);
41 public void main(String[] args) throws MsgException {
47 filename = mount + FILENAME1;
51 filename = mount + FILENAME2;
55 filename = mount + FILENAME3;
59 filename = mount + FILENAME4;
63 filename = mount + FILENAME1;
66 Msg.info("Open file " + filename);
67 File file = new File(filename);
69 long read = file.read(10000,1);
70 Msg.info("Having read " + read + " on " + filename);
72 long write = file.write(100000,1);
73 Msg.info("Having write " + write + " on " + filename);
75 Msg.info("Seek back to the beginning of " + filename);
76 file.seek(0,file.SEEK_SET);
78 read = file.read(150000,1);
79 Msg.info("Having read " + read + " on " + filename);