-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-26942 cache region locations when getAllRegionLocations #4335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
c73a751
329ef8b
5c53f68
3e1530e
9ccecce
98d106d
4f334a0
7da42da
c5798cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| package org.apache.hadoop.hbase.client; | ||
|
|
||
| import static org.apache.hadoop.hbase.trace.TraceUtil.tracedFuture; | ||
| import static org.apache.hadoop.hbase.util.FutureUtils.addListener; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
@@ -61,8 +62,23 @@ public CompletableFuture<List<HRegionLocation>> getAllRegionLocations() { | |
| return conn.registry.getMetaRegionLocations() | ||
| .thenApply(locs -> Arrays.asList(locs.getRegionLocations())); | ||
| } | ||
| return ClientMetaTableAccessor | ||
| .getTableHRegionLocations(conn.getTable(TableName.META_TABLE_NAME), tableName); | ||
| 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; | ||
| } | ||
| try { | ||
| locs.forEach(loc -> conn.getLocator() | ||
| .getNonMetaRegionLocator().addLocationToCache(loc)); | ||
| } catch (Exception e) { | ||
| future.completeExceptionally(e); | ||
| } finally { | ||
| future.complete(locs); | ||
|
||
| } | ||
| }); | ||
| return future; | ||
| }, getClass().getSimpleName() + ".getAllRegionLocations"); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.