19
19
20
20
import com .alipay .oceanbase .hbase .OHTable ;
21
21
import com .alipay .oceanbase .rpc .protocol .payload .impl .execute .ObTableBatchOperation ;
22
- import com .google .common .annotations .VisibleForTesting ;
23
22
import org .apache .hadoop .classification .InterfaceAudience ;
24
23
import org .apache .hadoop .conf .Configuration ;
25
24
import org .apache .hadoop .hbase .KeyValue ;
@@ -48,9 +47,7 @@ public class OHBufferedMutatorImpl implements BufferedMutator {
48
47
private volatile Configuration conf ;
49
48
50
49
private OHTable ohTable ;
51
- @ VisibleForTesting
52
50
final ConcurrentLinkedQueue <Mutation > asyncWriteBuffer = new ConcurrentLinkedQueue <Mutation >();
53
- @ VisibleForTesting
54
51
AtomicLong currentAsyncBufferSize = new AtomicLong (0 );
55
52
56
53
private long writeBufferSize ;
@@ -166,7 +163,6 @@ private void validateOperation(Mutation mt) throws IllegalArgumentException {
166
163
}
167
164
168
165
/**
169
- * This execute only supports for server version of 4_3_5.
170
166
* Send the operations in the buffer to the servers. Does not wait for the server's answer. If
171
167
* there is an error, either throw the error, or use the listener to deal with the error.
172
168
*
@@ -189,38 +185,25 @@ private void batchExecute(boolean flushAll) throws IOException {
189
185
if (execBuffer .isEmpty ()) {
190
186
return ;
191
187
}
192
- ohTable .batch (execBuffer );
188
+ Object [] results = new Object [execBuffer .size ()];
189
+ ohTable .batch (execBuffer , results );
193
190
// if commit all successfully, clean execBuffer
194
191
execBuffer .clear ();
195
192
} catch (Exception ex ) {
193
+ // do not recollect error operations, notify outside
194
+ LOGGER .error (LCD .convert ("01-00026" ), ex );
196
195
if (ex .getCause () instanceof RetriesExhaustedWithDetailsException ) {
197
- LOGGER .error (LCD .convert ("01-00011" ), tableName .getNameAsString ()
198
- + ": One or more of the operations have failed after retries." , ex .getCause ());
196
+ LOGGER .error (tableName + ": One or more of the operations have failed after retries." );
199
197
RetriesExhaustedWithDetailsException retryException = (RetriesExhaustedWithDetailsException ) ex .getCause ();
200
- // recollect mutations and log error information
201
- execBuffer .clear ();
202
- for (int i = 0 ; i < retryException .getNumExceptions (); ++i ) {
203
- Row failedOp = retryException .getRow (i );
204
- execBuffer .add ((Mutation ) failedOp );
205
- LOGGER .error (LCD .convert ("01-00011" ), failedOp , tableName .getNameAsString (),
206
- currentAsyncBufferSize .get (), retryException .getCause (i ));
207
- }
208
198
if (listener != null ) {
209
199
listener .onException (retryException , this );
210
200
} else {
211
201
throw retryException ;
212
202
}
213
203
} else {
214
- LOGGER .error (LCD .convert ("01-00011" ), tableName .getNameAsString ()
215
- + ": Errors unrelated to operations occur during mutation operation" , ex );
204
+ LOGGER .error ("Errors unrelated to operations occur during mutation operation" , ex );
216
205
throw ex ;
217
206
}
218
- } finally {
219
- for (Mutation mutation : execBuffer ) {
220
- long size = mutation .heapSize ();
221
- currentAsyncBufferSize .addAndGet (size );
222
- asyncWriteBuffer .add (mutation );
223
- }
224
207
}
225
208
}
226
209
@@ -230,7 +213,7 @@ public void close() throws IOException {
230
213
return ;
231
214
}
232
215
try {
233
- flush ( );
216
+ batchExecute ( true );
234
217
} finally {
235
218
// the pool in ObTableClient will be shut down too
236
219
this .pool .shutdown ();
0 commit comments