package at.ac.tuwien.lsdc.types;
public class Application implements Comparable<Application> {
-
- private int id;
- private long timestamp;
- private int size;
- private int ram;
- private int cpu;
- private int duration;
-
- private VirtualMachine runningOn;
-
- public Application(int id, long timestamp, int size, int ram, int cpu, int duration) {
- this.id = id;
- this.timestamp = timestamp;
- this.size = size;
- this.ram = ram;
- this.cpu = cpu;
- this.duration = duration;
- }
-
- public int getID() {
- return id;
- }
-
- public long getTimestamp() {
- return timestamp;
- }
-
- public int getSize() {
- return size;
- }
-
- public int getRam() {
- return ram;
- }
-
- public int getCpu() {
- return cpu;
- }
-
- public int getDuration() {
- return duration;
- }
-
- @Override
- public String toString() {
- return new String("App ID: " + id + " Timestamp: " + timestamp + " size: " + size
- + " ram: " + ram + " cpu: " + cpu + " duration: " + duration);
- }
-
- public VirtualMachine getRunningOn() {
- return runningOn;
- }
-
- public void setRunningOn(VirtualMachine vm) {
- runningOn = vm;
- }
-
- @Override
- public int compareTo(Application other) {
- final int BEFORE = -1;
- final int EQUAL = 0;
- final int AFTER = 1;
-
- // this optimization is usually worthwhile, and can
- // always be added
- if (this == other)
- return EQUAL;
- if (this.getTimestamp() == other.getTimestamp())
- return EQUAL;
- if (this.getTimestamp() < other.getTimestamp())
- return BEFORE;
- if (this.getTimestamp() > other.getTimestamp())
- return AFTER;
-
- return EQUAL;
- }
+ static private int nextid = 0;
+ private int id;
+ private long timestamp;
+ private int size;
+ private int ram;
+ private int cpu;
+ private int duration;
+
+ private VirtualMachine runningOn;;
+
+ public Application(long timestamp, int size, int ram, int cpu, int duration) {
+ id = ++nextid;
+ this.timestamp = timestamp;
+ this.size = size;
+ this.ram = ram;
+ this.cpu = cpu;
+ this.duration = duration;
+ }
+
+ public int getID() {
+ return id;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public int getRam() {
+ return ram;
+ }
+
+ public int getCpu() {
+ return cpu;
+ }
+
+ public int getDuration() {
+ return duration;
+ }
+
+ @Override
+ public String toString() {
+ return new String("App ID: " + id + " Timestamp: " + timestamp + " size: " + size + " ram: " + ram + " cpu: " + cpu
+ + " duration: " + duration);
+ }
+
+ public VirtualMachine getRunningOn() {
+ return runningOn;
+ }
+
+ public void setRunningOn(VirtualMachine vm) {
+ runningOn = vm;
+ }
+
+ @Override
+ public int compareTo(Application other) {
+ final int BEFORE = -1;
+ final int EQUAL = 0;
+ final int AFTER = 1;
+
+ // this optimization is usually worthwhile, and can
+ // always be added
+ if (this == other)
+ return EQUAL;
+ if (getTimestamp() == other.getTimestamp())
+ return EQUAL;
+ if (getTimestamp() < other.getTimestamp())
+ return BEFORE;
+ if (getTimestamp() > other.getTimestamp())
+ return AFTER;
+
+ return EQUAL;
+ }
}