chenxu14 commented on a change in pull request #656: HBASE-23063 Add an option
to enable multiget in parallel
URL: https://github.com/apache/hbase/pull/656#discussion_r328452649
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
##########
@@ -934,13 +939,61 @@ private Result increment(final HRegion region, final
OperationQuota quota,
builder.addResultOrException(resultOrExceptionBuilder.build());
}
}
+ // do multiget in parallel
+ if (getCtxs != null && !getCtxs.isEmpty()) {
+ doParallelGet(getCtxs, cellsToReturn, builder);
+ }
// Finish up any outstanding mutations
if (!CollectionUtils.isEmpty(mutations)) {
doNonAtomicBatchOp(builder, region, quota, mutations, cellScanner,
spaceQuotaEnforcement);
}
return cellsToReturn;
}
+ private void doParallelGet(List<GetContext> getCtxs, List<CellScannable>
cellsToReturn,
+ RegionActionResult.Builder builder) throws ServiceException {
+ ResultOrException.Builder resultOrExceptionBuilder = null;
+ CountDownLatch latch = new CountDownLatch(getCtxs.size());
+ List<GetActionHandler> handlers = new ArrayList<>(getCtxs.size());
+ for (GetContext getCtx : getCtxs) {
+ GetActionHandler handler = new GetActionHandler(getCtx, latch);
+ this.regionServer.executorService.submit(handler);
+ handlers.add(handler);
+ }
+ try {
+ latch.await();
Review comment:
The fallowing Test has no problem @ramatronics
The main thread will not hang
```
public class Test {
public static void main(String[] args) throws Throwable {
CountDownLatch doneSignal = new CountDownLatch(2);
new Thread(new WorkerRunnable(doneSignal)).start();
new Thread(new WorkerRunnable(doneSignal)).start();
Thread.sleep(5000);
doneSignal.await();
System.out.println("await happend");
}
}
class WorkerRunnable implements Runnable {
private final CountDownLatch doneSignal;
WorkerRunnable(CountDownLatch doneSignal) {
this.doneSignal = doneSignal;
}
public void run() {
System.out.println("countDown happend");
doneSignal.countDown();
}
}
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services