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 storage and file functions of the MSG API
11 * - display information on the disks mounted by the current host
12 * - create a 200,000 bytes file
13 * - completely read the created file
14 * - write 100,000 bytes in the file
15 * - rename the created file
16 * - attach some user data to a disk
17 * - dump disk's contents
19 ******************************************************************************/
23 import org.simgrid.msg.Host;
24 import org.simgrid.msg.Msg;
25 import org.simgrid.msg.MsgException;
26 import org.simgrid.msg.Process;
27 import org.simgrid.msg.HostNotFoundException;
28 import org.simgrid.msg.Storage;
30 public class Client extends Process {
32 public Client(Host host, int number) throws HostNotFoundException {
33 super(host, Integer.toString(number), null);
36 public void main(String[] args) throws MsgException {
38 // Retrieve all mount points of current host
39 Storage[] storages = getHost().getMountedStorage();
41 for (int i = 0; i < storages.length; i++) {
42 // For each disk mounted on host
43 Msg.info("------------------------------------");
44 Msg.info("Disk name: "+storages[i].getName());
45 Msg.info("Size: "+storages[i].getSize()+" bytes.");
46 Msg.info("Free Size: "+storages[i].getFreeSize()+" bytes.");
47 Msg.info("Used Size: "+storages[i].getUsedSize()+" bytes.");
51 Storage st = Storage.getByName("Disk2");
52 Msg.info("Disk name: "+st.getName());
53 Msg.info("Attached to host:"+st.getHost());
56 st.setProperty("key","Pierre");
57 Msg.info("Property key: "+st.getProperty("key"));
59 Host h = Host.currentHost();
60 h.setProperty("key2","Pierre");
61 Msg.info("Property key2: "+h.getProperty("key"));
64 String[] attach = h.getAttachedStorage();
65 for (int j = 0; j < attach.length; j++) {
66 Msg.info("Disk attached: "+attach[j]);
69 Msg.info("**************** ALL *************************");
71 Storage[] stos = Storage.all();
72 for (int i = 0; i < stos.length; i++) {
73 Msg.info("Disk: "+ stos[i].getName());