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