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.HostNotFoundException;
23 import org.simgrid.msg.MsgException;
25 public class Client extends Process {
26 public Client(Host host, int number) {
27 super(host, Integer.toString(number), null);
30 public void main(String[] args) throws MsgException {
31 // Retrieve all mount points of current host
32 Storage[] storages = getHost().getMountedStorage();
34 for (int i = 0; i < storages.length; i++) {
35 // For each disk mounted on host
36 Msg.info("------------------------------------");
37 Msg.info("Disk name: "+storages[i].getName());
38 Msg.info("Size: "+storages[i].getSize()+" bytes.");
39 Msg.info("Free Size: "+storages[i].getFreeSize()+" bytes.");
40 Msg.info("Used Size: "+storages[i].getUsedSize()+" bytes.");
43 Storage st = Storage.getByName("Disk2");
44 Msg.info("Disk name: "+st.getName());
45 Msg.info("Attached to host:"+st.getHost());
47 st.setProperty("key","Pierre");
48 Msg.info("Property key: "+st.getProperty("key"));
50 Host h = Host.currentHost();
51 h.setProperty("key2","Pierre");
52 Msg.info("Property key2: "+h.getProperty("key2"));
54 String[] attach = h.getAttachedStorage();
55 for (int j = 0; j < attach.length; j++) {
56 Msg.info("Disk attached: "+attach[j]);
59 Msg.info("**************** ALL *************************");
60 Storage[] stos = Storage.all();
61 for (int i = 0; i < stos.length; i++) {
62 Msg.info("Disk: "+ stos[i].getName());