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