root / src / Chunk.java
History | View | Annotate | Download (1.86 KB)
1 | 1 | up20150487 | |
---|---|---|---|
2 | import java.io.IOException; |
||
3 | import java.util.ArrayList; |
||
4 | import java.io.Serializable; |
||
5 | |||
6 | public class Chunk implements Serializable { |
||
7 | |||
8 | public static int CHUNK_MAXSIZE = 64000; |
||
9 | private String fileID; |
||
10 | private int chunkNo; |
||
11 | private int size; |
||
12 | private byte[] data; |
||
13 | private int replicationDegree; |
||
14 | private int currReplicationDegree; |
||
15 | private ArrayList<Integer> peersId; |
||
16 | private int initiatorPeer; |
||
17 | private Boolean receivedChunk; |
||
18 | |||
19 | public Chunk(int initiatorPeer, String fileId, int no, int size,byte[] data, int repDegree) { |
||
20 | |||
21 | this.fileID = fileId;
|
||
22 | this.chunkNo = no;
|
||
23 | this.size = size;
|
||
24 | this.data=data;
|
||
25 | this.receivedChunk=false; |
||
26 | this.initiatorPeer=initiatorPeer;
|
||
27 | this.peersId= new ArrayList<Integer>(); |
||
28 | this.replicationDegree = repDegree;
|
||
29 | this.currReplicationDegree = 0; |
||
30 | } |
||
31 | |||
32 | public Boolean getReceivedChunk(){ |
||
33 | return receivedChunk;
|
||
34 | } |
||
35 | |||
36 | public void setReceivedChunk(Boolean type){ |
||
37 | this.receivedChunk=type;
|
||
38 | } |
||
39 | public ArrayList<Integer> getPeersId(){ |
||
40 | return peersId;
|
||
41 | } |
||
42 | public void addPeersId(int id){ |
||
43 | this.peersId.add(id);
|
||
44 | } |
||
45 | public int getInitiatorPeer(){ |
||
46 | return initiatorPeer;
|
||
47 | } |
||
48 | public void setInitiatorPeer(int initiatorPeer){ |
||
49 | this.initiatorPeer=initiatorPeer;
|
||
50 | } |
||
51 | |||
52 | public int getCurrReplicationDegree(){ |
||
53 | return currReplicationDegree;
|
||
54 | } |
||
55 | |||
56 | public int getReplicationDegree(){ |
||
57 | return replicationDegree;
|
||
58 | } |
||
59 | |||
60 | public String getFileID(){ |
||
61 | return fileID;
|
||
62 | } |
||
63 | |||
64 | public int getChunkNo(){ |
||
65 | return chunkNo;
|
||
66 | } |
||
67 | public byte[] getData(){ |
||
68 | return data;
|
||
69 | } |
||
70 | |||
71 | public int getSize(){ |
||
72 | return size;
|
||
73 | } |
||
74 | |||
75 | public void updateCurrReplicationDegree(int i){ |
||
76 | this.currReplicationDegree = this.currReplicationDegree+i; |
||
77 | } |
||
78 | } |