]> git.somenet.org - pub/jan/lsdc.git/blob - src/at/ac/tuwien/lsdc/types/Application.java
started implementing MachineManager, VM & PM
[pub/jan/lsdc.git] / src / at / ac / tuwien / lsdc / types / Application.java
1 package at.ac.tuwien.lsdc.types;
2
3 public class Application implements Comparable<Application> {
4
5         private int id;
6         private long timestamp;
7         private int size;
8         private int ram;
9         private int cpu;
10         private int duration;
11
12         private VirtualMachine runningOn;
13
14         public Application(int id, long timestamp, int size, int ram, int cpu,
15                         int duration) {
16                 this.id = id;
17                 this.timestamp = timestamp;
18                 this.size = size;
19                 this.ram = ram;
20                 this.cpu = cpu;
21                 this.duration = duration;
22         }
23
24         public int getID() {
25                 return id;
26         }
27
28         public long getTimestamp() {
29                 return timestamp;
30         }
31
32         public int getSize() {
33                 return size;
34         }
35
36         public int getRam() {
37                 return ram;
38         }
39
40         public int getCpu() {
41                 return cpu;
42         }
43
44         public int getDuration() {
45                 return duration;
46         }
47
48         public String toString() {
49                 return new String("App ID: " + id + " Timestamp: " + timestamp
50                                 + " size: " + size + " ram: " + ram + " cpu: " + cpu
51                                 + " duration: " + duration);
52         }
53
54         public VirtualMachine getRunningOn() {
55                 return runningOn;
56         }
57
58         public void setRunningOn(VirtualMachine vm) {
59                 runningOn = vm;
60         }
61
62         @Override
63         public int compareTo(Application other) {
64                 final int BEFORE = -1;
65                 final int EQUAL = 0;
66                 final int AFTER = 1;
67
68                 // this optimization is usually worthwhile, and can
69                 // always be added
70                 if (this == other)
71                         return EQUAL;
72                 if (this.getTimestamp() == other.getTimestamp())
73                         return EQUAL;
74                 if (this.getTimestamp() < other.getTimestamp())
75                         return BEFORE;
76                 if (this.getTimestamp() > other.getTimestamp())
77                         return AFTER;
78
79                 return EQUAL;
80         }
81
82 }