-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexEntry.java
More file actions
97 lines (86 loc) · 2.56 KB
/
IndexEntry.java
File metadata and controls
97 lines (86 loc) · 2.56 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import java.util.List;
import java.util.concurrent.CountDownLatch;
/**
* Class used to represent an entry in the index
*/
public class IndexEntry {
//Size of file that this entry belongs to
private final int fileSize;
//Ports of the Dstores used to store the file that this entry belongs to
private final List<Integer> DstorePorts;
//State of the file that this entry belongs to
private String fileState;
//Number of STORE_ACKs received for the file that this entry belongs to
private final CountDownLatch storeACKs;
//Number of REMOVE_ACKs received for the file that this entry belongs to
private final CountDownLatch removeACKs;
/**
* Constructs an entry in the Index
* @param fileSize size of file that this entry belongs to
* @param DstorePorts ports of the Dstores used to store the file that this entry belongs to
* @param fileState state of the file that this entry belongs to
*/
public IndexEntry(int fileSize, List<Integer> DstorePorts, String fileState, int R) {
this.fileSize = fileSize;
this.DstorePorts = DstorePorts;
this.fileState = fileState;
this.storeACKs = new CountDownLatch(R);
this.removeACKs = new CountDownLatch(R);
}
/**
* Gets this entry's file size
* @return file size
*/
public int getFileSize() {
return this.fileSize;
}
/**
* Gets this entry's Dstore ports
* @return Dstore ports
*/
public List<Integer> getDstorePorts() {
return this.DstorePorts;
}
/**
* Gets this entry's file state
* @return file state
*/
public String getFileState() {
return this.fileState;
}
/**
* Gets this entry's store ACKs
* @return store ACKs
*/
public CountDownLatch getStoreACKs() {
return this.storeACKs;
}
/**
* Gets this entry's remove ACKs
* @return remove ACKs
*/
public CountDownLatch getRemoveACKs() {
return this.removeACKs;
}
/**
* Changes this entry's file state to a new state
* @param newState new state
*/
public void setFileState(String newState) {
this.fileState = newState;
}
/**
* Removes a port from this entry's Dstore ports
* @param port port being removed
*/
public void removePort(Integer port) {
this.DstorePorts.remove(port);
}
/**
* Adds a port to this entry's Dstore ports
* @param port port being added
*/
public void addPort(Integer port) {
this.DstorePorts.add(port);
}
}