You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2023/05/23 12:54:02 UTC
[accumulo] branch elasticity updated: handles case where location is not required in root tablet cache (#3421)
This is an automated email from the ASF dual-hosted git repository.
kturner pushed a commit to branch elasticity
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/elasticity by this push:
new b080ce7aa1 handles case where location is not required in root tablet cache (#3421)
b080ce7aa1 is described below
commit b080ce7aa1bfa6521fe5e307b0784c8221c560a1
Author: Keith Turner <kt...@apache.org>
AuthorDate: Tue May 23 08:53:56 2023 -0400
handles case where location is not required in root tablet cache (#3421)
The root tablet client cache was not handling request that did not
require a location. Adds support for handling that case in a manner
that is similar to the non-root tablet client cache.
fixes #3420
---
.../core/clientImpl/ClientTabletCache.java | 1 -
.../core/clientImpl/RootClientTabletCache.java | 33 ++++++++++------------
2 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientTabletCache.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientTabletCache.java
index 8cea7ad8e1..71e0510978 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientTabletCache.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientTabletCache.java
@@ -105,7 +105,6 @@ public abstract class ClientTabletCache {
throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
InvalidTabletHostingRequestException;
- // ELASTICITY_TODO rename to findTablets
/**
* <p>
* This method finds what tablets overlap a given set of ranges, passing each range and its
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/RootClientTabletCache.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/RootClientTabletCache.java
index ed8a6e4da2..dcdb6a2625 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/RootClientTabletCache.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/RootClientTabletCache.java
@@ -27,6 +27,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.function.BiConsumer;
import org.apache.accumulo.core.Constants;
@@ -45,8 +46,6 @@ import org.apache.hadoop.io.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-
public class RootClientTabletCache extends ClientTabletCache {
private final TabletServerLockChecker lockChecker;
@@ -74,18 +73,17 @@ public class RootClientTabletCache extends ClientTabletCache {
public List<Range> findTablets(ClientContext context, List<Range> ranges,
BiConsumer<CachedTablet,Range> rangeConsumer, LocationNeed locationNeed) {
- // only expect the hosted case so this code only handles that, so throw an exception is
- // something else is seen
- Preconditions.checkArgument(locationNeed == LocationNeed.REQUIRED);
-
CachedTablet rootCachedTablet = getRootTabletLocation(context);
- if (rootCachedTablet != null) {
+
+ if (rootCachedTablet.getTserverLocation().isEmpty() && locationNeed == LocationNeed.REQUIRED) {
+ // there is no location and one is required so return all ranges as failures
+ return ranges;
+ } else {
for (Range range : ranges) {
rangeConsumer.accept(rootCachedTablet, range);
}
return Collections.emptyList();
}
- return ranges;
}
@Override
@@ -125,7 +123,8 @@ public class RootClientTabletCache extends ClientTabletCache {
}
if (loc == null || loc.getType() != LocationType.CURRENT) {
- return null;
+ return new CachedTablet(RootTable.EXTENT, Optional.empty(), Optional.empty(),
+ TabletHostingGoal.ALWAYS);
}
String server = loc.getHostPort();
@@ -133,25 +132,23 @@ public class RootClientTabletCache extends ClientTabletCache {
if (lockChecker.isLockHeld(server, loc.getSession())) {
return new CachedTablet(RootTable.EXTENT, server, loc.getSession(), TabletHostingGoal.ALWAYS);
} else {
- return null;
+ return new CachedTablet(RootTable.EXTENT, Optional.empty(), Optional.empty(),
+ TabletHostingGoal.ALWAYS);
}
}
@Override
public CachedTablet findTablet(ClientContext context, Text row, boolean skipRow,
LocationNeed locationNeed) {
- // only expect the hosted case so this code only handles that, so throw an exception is
- // something else is seen
- Preconditions.checkArgument(locationNeed == LocationNeed.REQUIRED);
- CachedTablet location = getRootTabletLocation(context);
+ CachedTablet cachedTablet = getRootTabletLocation(context);
+
// Always retry when finding the root tablet
- while (location == null) {
+ while (cachedTablet.getTserverLocation().isEmpty() && locationNeed == LocationNeed.REQUIRED) {
sleepUninterruptibly(500, MILLISECONDS);
- location = getRootTabletLocation(context);
+ cachedTablet = getRootTabletLocation(context);
}
- return location;
+ return cachedTablet;
}
-
}