Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups in java examples (2/2)
[simgrid.git] / examples / java / io / Node.java
1 /* Copyright (c) 2012-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 package io;
8
9 import org.simgrid.msg.Msg;
10 import org.simgrid.msg.File;
11 import org.simgrid.msg.Host;
12 import org.simgrid.msg.Process;
13 import org.simgrid.msg.HostNotFoundException;
14 import org.simgrid.msg.MsgException;
15
16 public class Node extends Process {
17   private static String FILENAME1 = "/doc/simgrid/examples/platforms/g5k.xml";
18   private static String FILENAME2 = "\\Windows\\setupact.log";
19   private static String FILENAME3 = "/doc/simgrid/examples/platforms/g5k_cabinets.xml";
20   private static String FILENAME4 = "/doc/simgrid/examples/platforms/nancy.xml";
21
22   protected int number;
23
24   public Node(Host host, int number) throws HostNotFoundException {
25     super(host, Integer.toString(number), null);
26     this.number = number;
27   }
28
29   public void main(String[] args) throws MsgException {
30     String mount = "";
31     String filename;
32     switch (number) {
33       case 0:
34         mount = "/home";
35         filename = mount + FILENAME1;
36       break;
37       case 1:
38         mount = "c:";
39         filename = mount + FILENAME2;
40       break;
41       case 2:
42         mount = "/home";
43         filename = mount + FILENAME3;
44       break;
45       case 3:
46         mount = "/home";
47         filename = mount + FILENAME4;
48       break;
49       default:
50         mount = "/home";
51         filename = mount + FILENAME1;
52     }
53
54     Msg.info("Open file " + filename);
55     File file = new File(filename);
56
57     long read = file.read(10000000,1);
58     Msg.info("Having read " + read + " on " + filename);
59
60     long write = file.read(100000,1);
61     Msg.info("Having write " + write + " on " + filename);
62
63     read = file.read(10000000,1);
64     Msg.info("Having read " + read + " on " + filename);  
65   }
66 }