Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
91141c841276bfe89db36cbd93f1bb4df41cecc1
[simgrid.git] / examples / java / cloud / migration-test / src / Daemon.java
1 import org.simgrid.msg.*;
2 import org.simgrid.msg.Process;
3
4 public class Daemon extends Process {
5         private Task currentTask;
6     public Daemon(VM vm, int load) {
7                 super((Host)vm,"Daemon");
8        currentTask = new Task(this.getHost().getName()+"-daemon-0", this.getHost().getSpeed()*100, 0);
9     }
10     public void main(String[] args) throws MsgException {
11         int i = 1;
12         while(!Main.isEndOfTest()) {
13             // TODO the binding is not yet available
14             try {
15                 currentTask.execute();
16             } catch (HostFailureException e) {
17                 e.printStackTrace();
18             } catch (TaskCancelledException e) {
19                 System.out.println("task cancelled");
20                 suspend(); // Suspend the process
21             }
22             currentTask = new Task(this.getHost().getName()+"-daemon-"+(i++), this.getHost().getSpeed()*100, 0);
23             Msg.info(currentTask.getName());
24         }
25     }
26
27     public double getRemaining(){
28         return this.currentTask.getRemainingDuration();
29     }
30     }