bbeaudreault commented on code in PR #4335:
URL: https://github.com/apache/hbase/pull/4335#discussion_r852107913
##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableRegionLocatorImpl.java:
##########
@@ -65,13 +65,17 @@ public CompletableFuture<List<HRegionLocation>>
getAllRegionLocations() {
CompletableFuture<List<HRegionLocation>> future = new
CompletableFuture<>();
addListener(ClientMetaTableAccessor.getTableHRegionLocations(conn
.getTable(TableName.META_TABLE_NAME), tableName), (locs, error) -> {
- if (error != null) {
- future.completeExceptionally(error);
- return;
- }
- locs.forEach(loc ->
conn.getLocator().getNonMetaRegionLocator().addLocationToCache(loc));
- future.complete(locs);
- });
+ if (error != null) {
+ future.completeExceptionally(error);
+ return;
+ }
+ try {
+ locs.forEach(loc -> conn.getLocator()
+ .getNonMetaRegionLocator().addLocationToCache(loc));
Review Comment:
Ok sounds good. In that case @frostruan I would probably just remove the
extra futures altogether:
```java
CompletableFuture<List<HRegionLocation>> future =
ClientMetaTableAccessor.getTableHRegionLocations(conn
.getTable(TableName.META_TABLE_NAME), tableName);
addListener(future, (locs, error) -> {
// cache
});
return future;
```
No need to handle errors since they're already handled in addListener and
whenComplete will not block the client waiting on the original future.
Sorry for the back and forth
--
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]