1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.client;
20
21 import org.apache.hadoop.hbase.classification.InterfaceAudience;
22 import org.apache.hadoop.hbase.HConstants;
23
24
25
26
27
28
29 @InterfaceAudience.Private
30
31 public class Action<R> implements Comparable<R> {
32
33 private Row action;
34 private int originalIndex;
35 private long nonce = HConstants.NO_NONCE;
36 private int replicaId = RegionReplicaUtil.DEFAULT_REPLICA_ID;
37
38 public Action(Row action, int originalIndex) {
39 super();
40 this.action = action;
41 this.originalIndex = originalIndex;
42 }
43
44
45
46
47
48
49 public Action(Action<R> action, int replicaId) {
50 super();
51 this.action = action.action;
52 this.nonce = action.nonce;
53 this.originalIndex = action.originalIndex;
54 this.replicaId = replicaId;
55 }
56
57
58 public void setNonce(long nonce) {
59 this.nonce = nonce;
60 }
61
62 public boolean hasNonce() {
63 return nonce != HConstants.NO_NONCE;
64 }
65
66 public Row getAction() {
67 return action;
68 }
69
70 public int getOriginalIndex() {
71 return originalIndex;
72 }
73
74 public int getReplicaId() {
75 return replicaId;
76 }
77
78 @SuppressWarnings("rawtypes")
79 @Override
80 public int compareTo(Object o) {
81 return action.compareTo(((Action) o).getAction());
82 }
83
84 @Override
85 public int hashCode() {
86 return this.action.hashCode();
87 }
88
89 @Override
90 public boolean equals(Object obj) {
91 if (this == obj) return true;
92 if (obj == null || getClass() != obj.getClass()) return false;
93 Action<?> other = (Action<?>) obj;
94 return compareTo(other) == 0;
95 }
96
97 public long getNonce() {
98 return nonce;
99 }
100 }