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 6210f6747a use conditional mutations to remove hosting request (#4635)
6210f6747a is described below
commit 6210f6747a9e54a62b66980738023154bfcd803f
Author: Keith Turner <[email protected]>
AuthorDate: Wed Jun 5 13:36:32 2024 -0400
use conditional mutations to remove hosting request (#4635)
---
.../org/apache/accumulo/tserver/TabletServer.java | 20 +++++++++++++++++---
.../test/functional/OnDemandTabletUnloadingIT.java | 3 +++
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git
a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index 8aa8f65f4b..bab4c589a6 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -41,6 +41,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
@@ -87,7 +88,7 @@ import org.apache.accumulo.core.manager.thrift.TableInfo;
import org.apache.accumulo.core.manager.thrift.TabletServerStatus;
import org.apache.accumulo.core.metadata.AccumuloTable;
import org.apache.accumulo.core.metadata.TServerInstance;
-import org.apache.accumulo.core.metadata.schema.Ample.TabletsMutator;
+import org.apache.accumulo.core.metadata.schema.Ample;
import org.apache.accumulo.core.metadata.schema.TabletMetadata;
import org.apache.accumulo.core.metrics.MetricsInfo;
import org.apache.accumulo.core.rpc.ThriftUtil;
@@ -1180,6 +1181,9 @@ public class TabletServer extends AbstractServer
implements TabletHostingServer
return;
}
});
+
+ var myLocation = TabletMetadata.Location.current(getTabletSession());
+
tableIds.forEach(tid -> {
Map<KeyExtent,
Long> subset = sortedOnDemandExtents.entrySet().stream()
@@ -1191,10 +1195,20 @@ public class TabletServer extends AbstractServer
implements TabletHostingServer
UnloaderParams params = new UnloaderParamsImpl(tid, new
ServiceEnvironmentImpl(context),
subset, onDemandTabletsToUnload);
unloaders.get(tid).evaluate(params);
- try (TabletsMutator tm = getContext().getAmple().mutateTablets()) {
+ try (var tabletsMutator =
getContext().getAmple().conditionallyMutateTablets()) {
onDemandTabletsToUnload.forEach(ke -> {
log.debug("Unloading on-demand tablet: {} for table: {}", ke, tid);
- tm.mutateTablet(ke).deleteHostingRequested().mutate();
+
tabletsMutator.mutateTablet(ke).requireLocation(myLocation).deleteHostingRequested()
+ .submit(tm -> !tm.getHostingRequested());
+ });
+
+ tabletsMutator.process().forEach((extent, result) -> {
+ if (result.getStatus() != Ample.ConditionalResult.Status.ACCEPTED) {
+ var loc =
Optional.ofNullable(result.readMetadata()).map(TabletMetadata::getLocation)
+ .orElse(null);
+ log.debug("Failed to clear hosting request marker for {} location
in metadata:{}",
+ extent, loc);
+ }
});
}
});
diff --git
a/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java
b/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java
index 1c9de1da24..27bf68a5d6 100644
---
a/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java
+++
b/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java
@@ -267,6 +267,9 @@ public class OnDemandTabletUnloadingIT extends
SharedMiniClusterBase {
scanner.setConsistencyLevel(ScannerBase.ConsistencyLevel.IMMEDIATE);
assertEquals(100, scanner.stream().count());
}
+
+ // delete table to unhost any tablets so they do not show up in counts
for the next test
+ c.tableOperations().delete(tableName);
}
}
}