forked from rartner/p2pfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathData.java
More file actions
53 lines (41 loc) · 1.02 KB
/
Data.java
File metadata and controls
53 lines (41 loc) · 1.02 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
import java.util.*;
import java.io.Serializable;
import java.io.*;
import java.nio.file.*;
import broadcast.Peer;
public class Data implements Serializable {
private LinkedList<String> peers = new LinkedList<>();
private byte[] data = new byte[64*1024];
private long hash_chunk;
public Data(byte[] d) {
this.data = Arrays.copyOf(d, d.length);
this.hash_chunk = this.data.hashCode();
}
public Data(byte[] d, LinkedList<String> peers) {
this.peers = peers;
this.data = Arrays.copyOf(d, d.length);
this.hash_chunk = this.data.hashCode();
}
public void setData(byte[] data) throws NullPointerException {
this.data = data;
}
public void freeData() {
data = null;
System.gc(); // Chama o garbage collector
}
public void addPeer(String s) {
peers.add(s);
}
public byte[] getData() {
return this.data;
}
public LinkedList<String> getPeers() {
return this.peers;
}
public long getHashChunk() {
return this.hash_chunk;
}
public void setHashChunk(long hash_chunk) {
this.hash_chunk = hash_chunk;
}
}