Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Energy, onHostDestruction: ensured ptr existence
[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.File;
10 import org.simgrid.msg.Host;
11 import org.simgrid.msg.HostNotFoundException;
12 import org.simgrid.msg.Msg;
13 import org.simgrid.msg.MsgException;
14 import org.simgrid.msg.Process;
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         public void main(String[] args) throws MsgException {
29                 String mount = "";
30                 String filename;
31                 switch (number) {
32                         case 0:
33                 mount = "/home";
34                                 filename = mount + FILENAME1;
35                         break;
36                         case 1:
37                 mount = "c:";
38                                 filename = mount + FILENAME2;
39                         break;
40                         case 2:
41                 mount = "/home";
42                                 filename = mount + FILENAME3;
43                         break;
44                         case 3:
45                 mount = "/home";
46                                 filename = mount + FILENAME4;
47                         break;
48                         default:
49                 mount = "/home";
50                                 filename = mount + FILENAME1;
51                 }
52                 Msg.info("Open file " + filename);
53                 File file = new File(filename);
54
55                 long read = file.read(10000000,1);
56                 Msg.info("Having read " + read + " on " + filename);
57                 
58                 long write = file.read(100000,1);
59                 Msg.info("Having write " + write + " on " + filename);
60
61                 read = file.read(10000000,1);
62                 Msg.info("Having read " + read + " on " + filename);    
63         }
64 }