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.client;
21
22 import com.google.common.base.Objects;
23 import com.google.protobuf.Descriptors.MethodDescriptor;
24 import com.google.protobuf.Message;
25
26 import org.apache.hadoop.hbase.classification.InterfaceAudience;
27 import org.apache.hadoop.hbase.util.Bytes;
28
29
30
31
32
33
34
35
36
37
38 @InterfaceAudience.Private
39 public class RegionCoprocessorServiceExec implements Row {
40
41
42
43
44
45 private final byte[] region;
46 private final byte[] startKey;
47 private final MethodDescriptor method;
48 private final Message request;
49
50 public RegionCoprocessorServiceExec(byte[] region, byte[] startKey,
51 MethodDescriptor method, Message request) {
52 this.region = region;
53 this.startKey = startKey;
54 this.method = method;
55 this.request = request;
56 }
57
58 @Override
59 public byte[] getRow() {
60 return startKey;
61 }
62
63 public byte[] getRegion() {
64 return region;
65 }
66
67 public MethodDescriptor getMethod() {
68 return method;
69 }
70
71 public Message getRequest() {
72 return request;
73 }
74
75 @Override
76 public int compareTo(Row o) {
77 int res = Bytes.compareTo(this.getRow(), o.getRow());
78 if ((o instanceof RegionCoprocessorServiceExec) && res == 0) {
79 RegionCoprocessorServiceExec exec = (RegionCoprocessorServiceExec) o;
80 res = method.getFullName().compareTo(exec.getMethod().getFullName());
81 if (res == 0) {
82 res = Bytes.compareTo(request.toByteArray(), exec.getRequest().toByteArray());
83 }
84 }
85 return res;
86 }
87
88 @Override
89 public int hashCode() {
90 return Objects.hashCode(Bytes.hashCode(this.getRow()), method.getFullName(), request);
91 }
92
93 @Override
94 public boolean equals(Object obj) {
95 if (this == obj) {
96 return true;
97 }
98 if (obj == null || getClass() != obj.getClass()) {
99 return false;
100 }
101 Row other = (Row) obj;
102 return compareTo(other) == 0;
103 }
104 }