Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright comments
[simgrid.git] / org / simgrid / msg / VM.java
1 /*
2  * JNI interface to Cloud interface in Simgrid
3  * 
4  * Copyright 2006-2012 The SimGrid Team.           
5  * All right reserved. 
6  *
7  * This program is free software; you can redistribute 
8  * it and/or modify it under the terms of the license 
9  * (GNU LGPL) which comes with this package.
10  */
11 package org.simgrid.msg;
12
13 import org.simgrid.msg.Host;
14 import org.simgrid.msg.Process;
15
16 public class VM {
17         /**
18          * This attribute represents a bind between a java task object and
19          * a native task. Even if this attribute is public you must never
20          * access to it. It is set automatically during the build of the object.
21          */
22         private long bind = 0;
23         
24         private int coreAmount;
25         /**
26          * @brief Create a new empty VM.
27          * @bug it is expected that in the future, the coreAmount parameter will be used
28          * to add extra constraints on the execution, but the argument is ignored for now.
29          */
30         public VM(Host host, int coreAmount) {
31                 this.coreAmount = coreAmount;
32                 start(host,coreAmount);
33         }
34         protected void finalize() {
35                 destroy();
36         }
37         /**
38          * Destroy the VM
39          */
40         protected native void destroy();
41         /**
42          * Natively implemented method starting the VM.
43          * @param coreAmount
44          */
45         private native void start(Host host, int coreAmount);
46                 
47         /** @brief Returns whether the given VM is currently suspended
48          */     
49         public native boolean isSuspended();
50         /** @brief Returns whether the given VM is currently running
51          */
52         public native boolean isRunning();
53         /** @brief Add the given process into the VM.
54          * Afterward, when the VM is migrated or suspended or whatever, the process will have the corresponding handling, too.
55          */     
56         public native void bind(Process process);
57         /** @brief Removes the given process from the given VM, and kill it
58          *  Will raise a ProcessNotFound exception if the process were not binded to that VM
59          */     
60         public native void unbind(Process process);
61         /** @brief Immediately change the host on which all processes are running
62          *
63          * No migration cost occurs. If you want to simulate this too, you want to use a
64          * Task.send() before or after, depending on whether you want to do cold or hot
65          * migration.
66          */     
67         public native void migrate(Host destination);
68         /** @brief Immediately suspend the execution of all processes within the given VM
69          *
70          * No suspension cost occurs. If you want to simulate this too, you want to
71          * use a \ref File.write() before or after, depending on the exact semantic
72          * of VM suspend to you.
73          */     
74         public native void suspend();
75         /** @brief Immediately resumes the execution of all processes within the given VM
76          *
77          * No resume cost occurs. If you want to simulate this too, you want to
78          * use a \ref File.read() before or after, depending on the exact semantic
79          * of VM resume to you.
80          */
81         public native void resume();
82         /**
83          * @brief Immediately kills all processes within the given VM. Any memory that they allocated will be leaked.
84          * No extra delay occurs. If you want to simulate this too, you want to use a MSG_process_sleep() or something
85          */
86         public native void shutdown();
87                 
88 }