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 java.util.concurrent.ExecutorService;
23 import org.apache.hadoop.hbase.TableName;
24 import org.apache.hadoop.hbase.classification.InterfaceAudience;
25 import org.apache.hadoop.hbase.classification.InterfaceStability;
26
27
28
29
30 @InterfaceAudience.Public
31 @InterfaceStability.Evolving
32 public class BufferedMutatorParams implements Cloneable {
33
34 static final int UNSET = -1;
35
36 private final TableName tableName;
37 private long writeBufferSize = UNSET;
38 private long writeBufferPeriodicFlushTimeoutMs = UNSET;
39 private long writeBufferPeriodicFlushTimerTickMs = UNSET;
40 private int maxKeyValueSize = UNSET;
41 private ExecutorService pool = null;
42 private BufferedMutator.ExceptionListener listener = new BufferedMutator.ExceptionListener() {
43 @Override
44 public void onException(RetriesExhaustedWithDetailsException exception,
45 BufferedMutator bufferedMutator)
46 throws RetriesExhaustedWithDetailsException {
47 throw exception;
48 }
49 };
50
51 public BufferedMutatorParams(TableName tableName) {
52 this.tableName = tableName;
53 }
54
55 public TableName getTableName() {
56 return tableName;
57 }
58
59 public long getWriteBufferSize() {
60 return writeBufferSize;
61 }
62
63
64
65
66
67
68 public BufferedMutatorParams writeBufferSize(long writeBufferSize) {
69 this.writeBufferSize = writeBufferSize;
70 return this;
71 }
72
73 public long getWriteBufferPeriodicFlushTimeoutMs() {
74 return writeBufferPeriodicFlushTimeoutMs;
75 }
76
77
78
79
80 public BufferedMutatorParams setWriteBufferPeriodicFlushTimeoutMs(long timeoutMs) {
81 this.writeBufferPeriodicFlushTimeoutMs = timeoutMs;
82 return this;
83 }
84
85 public long getWriteBufferPeriodicFlushTimerTickMs() {
86 return writeBufferPeriodicFlushTimerTickMs;
87 }
88
89
90
91
92 public BufferedMutatorParams setWriteBufferPeriodicFlushTimerTickMs(long timerTickMs) {
93 this.writeBufferPeriodicFlushTimerTickMs = timerTickMs;
94 return this;
95 }
96
97 public int getMaxKeyValueSize() {
98 return maxKeyValueSize;
99 }
100
101
102
103
104
105
106 public BufferedMutatorParams maxKeyValueSize(int maxKeyValueSize) {
107 this.maxKeyValueSize = maxKeyValueSize;
108 return this;
109 }
110
111 public ExecutorService getPool() {
112 return pool;
113 }
114
115
116
117
118
119 public BufferedMutatorParams pool(ExecutorService pool) {
120 this.pool = pool;
121 return this;
122 }
123
124 public BufferedMutator.ExceptionListener getListener() {
125 return listener;
126 }
127
128
129
130
131 public BufferedMutatorParams listener(BufferedMutator.ExceptionListener listener) {
132 this.listener = listener;
133 return this;
134 }
135
136
137
138
139
140
141 @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="CN_IDIOM_NO_SUPER_CALL",
142 justification="The clone below is complete")
143 @Override
144 public BufferedMutatorParams clone() {
145 BufferedMutatorParams clone = new BufferedMutatorParams(this.tableName);
146 clone.writeBufferSize = this.writeBufferSize;
147 clone.writeBufferPeriodicFlushTimeoutMs = this.writeBufferPeriodicFlushTimeoutMs;
148 clone.writeBufferPeriodicFlushTimerTickMs = this.writeBufferPeriodicFlushTimerTickMs;
149 clone.maxKeyValueSize = this.maxKeyValueSize;
150 clone.pool = this.pool;
151 clone.listener = this.listener;
152 return clone;
153 }
154
155 }