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 private int priority;
38
39 public Action(Row action, int originalIndex) {
40 this(action, originalIndex, HConstants.PRIORITY_UNSET);
41 }
42
43 public Action(Row action, int originalIndex, int priority) {
44 super();
45 this.action = action;
46 this.originalIndex = originalIndex;
47 this.priority = priority;
48 }
49
50
51
52
53
54
55 public Action(Action<R> action, int replicaId) {
56 super();
57 this.action = action.action;
58 this.nonce = action.nonce;
59 this.originalIndex = action.originalIndex;
60 this.replicaId = replicaId;
61 }
62
63
64 public void setNonce(long nonce) {
65 this.nonce = nonce;
66 }
67
68 public boolean hasNonce() {
69 return nonce != HConstants.NO_NONCE;
70 }
71
72 public Row getAction() {
73 return action;
74 }
75
76 public int getOriginalIndex() {
77 return originalIndex;
78 }
79
80 public int getReplicaId() {
81 return replicaId;
82 }
83
84 public int getPriority() { return priority; }
85
86 @SuppressWarnings("rawtypes")
87 @Override
88 public int compareTo(Object o) {
89 return action.compareTo(((Action) o).getAction());
90 }
91
92 @Override
93 public int hashCode() {
94 return this.action.hashCode();
95 }
96
97 @Override
98 public boolean equals(Object obj) {
99 if (this == obj) return true;
100 if (obj == null || getClass() != obj.getClass()) return false;
101 Action<?> other = (Action<?>) obj;
102 return compareTo(other) == 0;
103 }
104
105 public long getNonce() {
106 return nonce;
107 }
108 }