-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeInfo.java
More file actions
96 lines (75 loc) · 1.38 KB
/
NodeInfo.java
File metadata and controls
96 lines (75 loc) · 1.38 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
package edu.unl.hcc;
import java.util.HashSet;
public class NodeInfo {
String hostname;
HashSet<Integer> blocks;
int rank;
int weight;
//default ctor
public NodeInfo(){
blocks=new HashSet();
}
public NodeInfo(String name){
if(!name.equals(null)){
hostname=name;
}
blocks=new HashSet();
rank=0;
weight=0;
}
public int getRank(){
return rank;
}
public int getWeight(){
return weight;
}
public void setRank(int ra){
rank=ra;
}
public void setWeight(int wt){
weight=wt;
}
public boolean addBlock(int blockID){
if(blockID>-1){
return blocks.add(blockID);
}
else {
System.out.println("Failed to add block:"+blockID);
return false;
}
}
public String getName(){
if(!hostname.equals(null)){
return hostname;
}
else return null;
}
public HashSet getBlocks(){
return this.blocks;
}
public boolean setHostName(String hn){
if(!hostname.equals(null)){
this.hostname=hn;
return true;
}
else return false;
}
public boolean containsBlock(int blockID){
if(blocks.contains(blockID)){
return true;
}
else return false;
}
public int getblockNum(){
return blocks.size();
}
public boolean removeBlock(int blockID){
if(blocks.contains(blockID)){
return blocks.remove(blockID);
}
else {
System.out.println("Does not contain this block with ID"+ blockID);
return false;
}
}
}