keith-turner commented on code in PR #3292:
URL: https://github.com/apache/accumulo/pull/3292#discussion_r1170662735
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java:
##########
@@ -584,22 +600,45 @@ private void requestTabletHosting(ClientContext context,
Range range)
return;
}
- String tableName = context.getTableName(tableId);
- if (!context.tableOperations().isOnline(tableName)) {
- log.trace("requestTabletHosting: table {} is not online", tableId);
+ if (extentsWithNoLocation.isEmpty()) {
return;
}
- List<TKeyExtent> extentsToBringOnline =
- findExtentsForRange(context, tableId, range,
Set.of(TabletHostingGoal.NEVER), true);
- if (extentsToBringOnline.isEmpty()) {
+ if (context.getTableState(tableId) != TableState.ONLINE) {
+ log.trace("requestTabletHosting: table {} is not online", tableId);
return;
}
- log.debug("Requesting tablets be hosted: {}", extentsToBringOnline);
- ThriftClientTypes.TABLET_MGMT.executeVoid(context,
- client -> client.requestTabletHosting(TraceUtil.traceInfo(),
context.rpcCreds(),
- tableId.canonical(), extentsToBringOnline));
- tabletHostingRequestCount.addAndGet(extentsToBringOnline.size());
+
+ List<KeyExtent> extentsToLookup = new ArrayList<>();
+ for (var extent : extentsWithNoLocation) {
+ if (recentOndemandRequest.asMap().putIfAbsent(extent,
System.currentTimeMillis()) == null) {
+ extentsToLookup.add(extent);
+ log.debug("Marking tablet as onDemand: {}", extent);
+ }
+ }
+
+ List<TKeyExtent> extentsToBringOnline = new ArrayList<>();
+
+ for (TabletMetadata tabletMetadata : context.getAmple().readTablets()
+ .forTablets(extentsToLookup).fetch(HOSTING_REQUESTED,
HOSTING_GOAL).build()) {
+ if (tabletMetadata.getHostingGoal() == TabletHostingGoal.ONDEMAND
+ && !tabletMetadata.getHostingRequested()) {
+ extentsToBringOnline.add(tabletMetadata.getExtent().toThrift());
+ }
+
+ if (tabletMetadata.getHostingGoal() == TabletHostingGoal.NEVER) {
+ throw new AccumuloException("Extent " + tabletMetadata.getExtent()
+ + " has a tablet hosting goal state " + TabletHostingGoal.NEVER);
+ }
+ }
+
+ if (!extentsToBringOnline.isEmpty()) {
+ log.debug("Requesting tablets be hosted: {}", extentsToBringOnline);
+ ThriftClientTypes.TABLET_MGMT.executeVoid(context,
+ client -> client.requestTabletHosting(TraceUtil.traceInfo(),
context.rpcCreds(),
+ tableId.canonical(), extentsToBringOnline));
+ tabletHostingRequestCount.addAndGet(extentsToBringOnline.size());
+ }
}
public static List<TKeyExtent> findExtentsForRange(ClientContext context,
TableId tableId,
Review Comment:
I moved it to TableOperationsImpl.
After consulting the cache we know what extents have no location, so those
extents are requested to be hosted if needed.
--
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]