Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d5fe01fec17064cbf8dbf920fcacb5b7d3b173af
[simgrid.git] / examples / deprecated / java / cloud / migration / Daemon.java
1 /* Copyright (c) 2014-2020. 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 cloud.migration;
8
9 import org.simgrid.msg.*;
10 import org.simgrid.msg.Process;
11
12 public class Daemon extends Process {
13   private Task currentTask;
14   public Daemon(VM vm) {
15     super((Host)vm,"Daemon");
16     currentTask = new Task(this.getHost().getName()+"-daemon-0", this.getHost().getSpeed()*100, 0);
17   }
18   public void main(String[] args) throws MsgException {
19     int i = 1;
20     while(!Main.isEndOfTest()) {
21     try {
22       currentTask.execute();
23     } catch (HostFailureException e) {
24       e.printStackTrace();
25     } catch (TaskCancelledException e) {
26       Msg.info("task cancelled");
27       suspend(); // Suspend the process
28     }
29     currentTask = new Task(this.getHost().getName()+"-daemon-"+(i++), this.getHost().getSpeed()*100, 0);
30   }
31 }
32
33   public double getRemaining(){
34     return this.currentTask.getFlopsAmount();
35   }
36 }