keith-turner commented on code in PR #3429:
URL: https://github.com/apache/accumulo/pull/3429#discussion_r1214911077
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ClientTabletCacheImpl.java:
##########
@@ -556,15 +557,68 @@ public CachedTablet findTablet(ClientContext context,
Text row, boolean skipRow,
String.format("%.3f secs", timer.scale(SECONDS)));
}
- if (tl != null && locationNeed == LocationNeed.REQUIRED &&
tl.getTserverLocation().isEmpty()) {
- requestTabletHosting(context, List.of(tl));
- return null;
+ if (tl != null && locationNeed == LocationNeed.REQUIRED) {
+ Map<KeyExtent,CachedTablet> extentsToHost =
+ findExtentsToHost(context, minimumHostAhead * 2, hostAheadRange,
lcSession, tl);
+
+ if (!extentsToHost.isEmpty()) {
+ if (extentsToHost.containsKey(tl.getExtent()) || extentsToHost.size()
>= minimumHostAhead) {
+ requestTabletHosting(context, extentsToHost.values());
+ }
+ }
+
+ if (tl.getTserverLocation().isEmpty()) {
+ return null;
+ }
}
return tl;
}
+ private Map<KeyExtent,CachedTablet> findExtentsToHost(ClientContext context,
int hostAheadCount,
+ Range hostAheadRange, LockCheckerSession lcSession, CachedTablet
firstTablet)
+ throws AccumuloException, TableNotFoundException,
InvalidTabletHostingRequestException,
+ AccumuloSecurityException {
+ Map<KeyExtent,CachedTablet> extentsToHost;
+
+ if (hostAheadCount > 0) {
+ extentsToHost = new HashMap<>();
+ if (firstTablet.getTserverLocation().isEmpty()) {
+ extentsToHost.put(firstTablet.getExtent(), firstTablet);
+ }
+
+ KeyExtent extent = firstTablet.getExtent();
+
+ var currTablet = extent;
+
+ for (int i = 0; i < hostAheadCount; i++) {
+ if (currTablet.endRow() == null || !hostAheadRange.contains(new
Key(currTablet.endRow()))) {
+ break;
+ }
+
+ CachedTablet followingTablet = _findTablet(context,
currTablet.endRow(), true, false, true,
+ lcSession, LocationNeed.REQUIRED);
Review Comment:
I added the preconditions check which helps tightly couple the method with
the caller. Looking into the code the `_findTablet` method does not host
tablets, it uses the location need to determine if it needs to do a metadata
lookup for tablets in the cache w/o a location.
--
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]