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 private HRegionInfo regionInfo;
28 private HServerAddress serverAddress;
29
30
31
32
33
34
35
36 public HRegionLocation(HRegionInfo regionInfo, HServerAddress serverAddress) {
37 this.regionInfo = regionInfo;
38 this.serverAddress = serverAddress;
39 }
40
41
42
43
44 @Override
45 public String toString() {
46 return "address: " + this.serverAddress.toString() + ", regioninfo: " +
47 this.regionInfo;
48 }
49
50
51
52
53 @Override
54 public boolean equals(Object o) {
55 if (this == o) {
56 return true;
57 }
58 if (o == null) {
59 return false;
60 }
61 if (!(o instanceof HRegionLocation)) {
62 return false;
63 }
64 return this.compareTo((HRegionLocation)o) == 0;
65 }
66
67
68
69
70 @Override
71 public int hashCode() {
72 int result = this.regionInfo.hashCode();
73 result ^= this.serverAddress.hashCode();
74 return result;
75 }
76
77
78 public HRegionInfo getRegionInfo(){
79 return regionInfo;
80 }
81
82
83 public HServerAddress getServerAddress(){
84 return serverAddress;
85 }
86
87
88
89
90
91 public int compareTo(HRegionLocation o) {
92 int result = this.regionInfo.compareTo(o.regionInfo);
93 if(result == 0) {
94 result = this.serverAddress.compareTo(o.serverAddress);
95 }
96 return result;
97 }
98 }