d-c-manning commented on code in PR #7516:
URL: https://github.com/apache/hbase/pull/7516#discussion_r2595930766
##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBufferedMutatorImpl.java:
##########
@@ -118,33 +163,43 @@ protected void internalFlush() {
@Override
public List<CompletableFuture<Void>> mutate(List<? extends Mutation>
mutations) {
- List<CompletableFuture<Void>> futures =
- Stream.<CompletableFuture<Void>>
generate(CompletableFuture::new).limit(mutations.size())
- .collect(Collectors.toList());
+ List<CompletableFuture<Void>> futures = new ArrayList<>(mutations.size());
+ for (int i = 0, n = mutations.size(); i < n; i++) {
+ futures.add(new CompletableFuture<>());
+ }
+ if (closed) {
+ IOException ioe = new IOException("Already closed");
+ futures.forEach(f -> f.completeExceptionally(ioe));
+ return futures;
+ }
long heapSize = 0;
for (Mutation mutation : mutations) {
heapSize += mutation.heapSize();
if (mutation instanceof Put) {
validatePut((Put) mutation, maxKeyValueSize);
}
}
- synchronized (this) {
- if (closed) {
- IOException ioe = new IOException("Already closed");
- futures.forEach(f -> f.completeExceptionally(ioe));
- return futures;
- }
+ Batch batch = null;
+ lock.lock();
+ try {
if (this.mutations.isEmpty() && periodicFlushTimeoutNs > 0) {
periodicFlushTask = periodicalFlushTimer.newTimeout(timeout -> {
- synchronized (AsyncBufferedMutatorImpl.this) {
+ Batch flushBatch = null;
+ lock.lock();
+ try {
// confirm that we are still valid, if there is already an
internalFlush call before us,
// then we should not execute anymore. And in internalFlush we
will set periodicFlush
Review Comment:
```suggestion
// confirm that we are still valid, if there is already a
drainBatch call before us,
// then we should not execute anymore. And in drainBatch we will
set periodicFlush
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]