-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMachInfo.java
More file actions
50 lines (38 loc) · 1 KB
/
MachInfo.java
File metadata and controls
50 lines (38 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package common;
import java.util.Collections;
import java.util.Collection;
import java.util.Comparator;
import util.CommChannel;
// Information about Nodes and Virtual Machines
//
//
public abstract class MachInfo
{
String ipAddress;
CommChannel contact;
double cpuUsage;
public MachInfo(String address, CommChannel contact){
this.ipAddress = address;
this.contact = contact;
}
public String getAddress(){
return ipAddress;
}
public CommChannel getContact(){
return contact;
}
public void updateCpu(double load){
cpuUsage = load;
}
public double getCpu(){
return cpuUsage;
}
public static MachInfo findMinCpu(Collection<? extends MachInfo> machines){
return Collections.min(machines, new Comparator<MachInfo>() {
public int compare(MachInfo a, MachInfo b) {
Double first = a.getCpu();
return first.compareTo(b.getCpu());
}
});
}
}