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 some storage related functions of the MSG API
10 * - display information on the disks mounted by the current host
11 * - attach some properties to a disk
12 * - list all the storage elements in the platform
14 ******************************************************************************/
18 import org.simgrid.msg.Msg;
19 import org.simgrid.msg.Host;
20 import org.simgrid.msg.Process;
21 import org.simgrid.msg.Storage;
22 import org.simgrid.msg.MsgException;
24 public class Client extends Process {
25 public Client(Host host, int number) {
26 super(host, Integer.toString(number), null);
29 public void main(String[] args) throws MsgException {
30 // Retrieve all mount points of current host
31 Storage[] storages = getHost().getMountedStorage();
33 for (int i = 0; i < storages.length; i++) {
34 // For each disk mounted on host
35 Msg.info("------------------------------------");
36 Msg.info("Disk name: "+storages[i].getName());
37 Msg.info("Size: "+storages[i].getSize()+" bytes.");
38 Msg.info("Free Size: "+storages[i].getFreeSize()+" bytes.");
39 Msg.info("Used Size: "+storages[i].getUsedSize()+" bytes.");
42 Storage st = Storage.getByName("Disk2");
43 Msg.info("Disk name: "+st.getName());
44 Msg.info("Attached to host:"+st.getHost());
46 st.setProperty("key","Pierre");
47 Msg.info("Property key: "+st.getProperty("key"));
49 Host h = Host.currentHost();
50 h.setProperty("key2","Pierre");
51 Msg.info("Property key2: "+h.getProperty("key2"));
53 String[] attach = h.getAttachedStorage();
54 for (int j = 0; j < attach.length; j++) {
55 Msg.info("Disk attached: "+attach[j]);
58 Msg.info("**************** ALL *************************");
59 Storage[] stos = Storage.all();
60 for (int i = 0; i < stos.length; i++) {
61 Msg.info("Disk: "+ stos[i].getName());