-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLease.java
More file actions
45 lines (39 loc) · 1.1 KB
/
Lease.java
File metadata and controls
45 lines (39 loc) · 1.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
import java.io.Serializable;
public class Lease implements Serializable {
public long term; // term time im millisecond
public String type; // Read or Write lease
public String filename;
// private boolean isExpired;
// avoid false sharing, set to true when client is done using. lease will be returned even not expired
// private int client; // used later to enable lease revoke
// release()
// check()
private final long RTTIME = 100; // estimated round trip time in the system
// constructor
public Lease(long term, String type, String filename) {
this.term = term;
this.type = type;
this.filename = filename;
}
// /** @param timePassed time passed after client got the lease
// *
// */
// public boolean checkIfExpired(long timePassed) {
// if (timePassed >= term) {
// return true;
// } else {
// return false;
// }
// }
/** @param timePassed time passed after client got the lease
*
*/
public boolean checkIfRenew(long timePassed) {
long actualLeasePeriod = term - RTTIME;
if (timePassed >= actualLeasePeriod) {
return true;
} else {
return false;
}
}
}