1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase;
21
22
23
24
25
26 public class HRegionLocation implements Comparable<HRegionLocation> {
27
28 private HRegionInfo regionInfo;
29 private HServerAddress serverAddress;
30
31
32
33
34
35
36
37 public HRegionLocation(HRegionInfo regionInfo, HServerAddress serverAddress) {
38 this.regionInfo = regionInfo;
39 this.serverAddress = serverAddress;
40 }
41
42
43
44
45 @Override
46 public String toString() {
47 return "address: " + this.serverAddress.toString() + ", regioninfo: " +
48 this.regionInfo.getRegionNameAsString();
49 }
50
51
52
53
54 @Override
55 public boolean equals(Object o) {
56 if (this == o) {
57 return true;
58 }
59 if (o == null) {
60 return false;
61 }
62 if (!(o instanceof HRegionLocation)) {
63 return false;
64 }
65 return this.compareTo((HRegionLocation)o) == 0;
66 }
67
68
69
70
71 @Override
72 public int hashCode() {
73 int result = this.regionInfo.hashCode();
74 result ^= this.serverAddress.hashCode();
75 return result;
76 }
77
78
79 public HRegionInfo getRegionInfo(){
80 return regionInfo;
81 }
82
83
84 public HServerAddress getServerAddress(){
85 return serverAddress;
86 }
87
88
89
90
91
92 public int compareTo(HRegionLocation o) {
93 int result = this.regionInfo.compareTo(o.regionInfo);
94 if(result == 0) {
95 result = this.serverAddress.compareTo(o.serverAddress);
96 }
97 return result;
98 }
99 }