forked from meisner/BigHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSurvivor.java
50 lines (37 loc) · 1.17 KB
/
Survivor.java
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 squeezer;
import java.util.Vector;
import core.Job;
import datacenter.Server;
public class Survivor {
private long jobId;
private Vector<Integer> survivorServerVec;
private int count;
public Survivor(final Job job, final Server server, final int survivorNum) {
this.jobId = job.getJobId();
int serverNum = server.getExperiment().getServerNumber();
this.count = serverNum;
this.survivorServerVec = ReservoirSampling.generate(survivorNum, serverNum);
}
public Survivor(final Job job, final Server server, final int survivorNum, final Vector<Integer> serverVec) {
this.jobId = job.getJobId();
int serverNum = serverVec.size();
this.count = serverNum;
Vector<Integer> sampleVector = ReservoirSampling.generate(survivorNum, serverNum);
this.survivorServerVec = new Vector<Integer>();
for(int sample : sampleVector) {
this.survivorServerVec.add(serverVec.get(sample));
}
}
public long getJobId() {
return this.jobId;
}
public boolean containsServerId(int serverId) {
return this.survivorServerVec.contains(serverId);
}
public void updateCount() {
this.count--;
}
public boolean isEmpty() {
return this.count == 0;
}
}