dlmarion commented on code in PR #3292:
URL: https://github.com/apache/accumulo/pull/3292#discussion_r1169965422
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java:
##########
@@ -57,19 +59,23 @@ public <T extends Mutation> void binMutations(ClientContext
context, List<T> mut
Map<String,TabletServerMutations<T>> binnedMutations, List<T> failures) {
TabletLocation rootTabletLocation = getRootTabletLocation(context);
if (rootTabletLocation != null) {
- var tsm = new
TabletServerMutations<T>(rootTabletLocation.getTserverSession());
+ var tsm = new
TabletServerMutations<T>(rootTabletLocation.getTserverSession().get());
for (T mutation : mutations) {
tsm.addMutation(RootTable.EXTENT, mutation);
}
- binnedMutations.put(rootTabletLocation.getTserverLocation(), tsm);
+ binnedMutations.put(rootTabletLocation.getTserverLocation().get(), tsm);
} else {
failures.addAll(mutations);
}
}
@Override
public List<Range> locateTablets(ClientContext context, List<Range> ranges,
- BiConsumer<TabletLocation,Range> rangeConsumer) {
+ BiConsumer<TabletLocation,Range> rangeConsumer, HostingNeed hostingNeed)
{
+
+ // only expect the hosted case so this code only handles that, so throw an
exception is
+ // something else is seed
Review Comment:
Comment is confusing. Why check the hostingNeed variable if it's never used
in the method? Is it to prevent bugs in other parts of the codebase?
##########
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:
IIRC `findExtentsForRange` is called from two places. You just removed one
with the changes above. So, it's possible that we could move this method.
--
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]