You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2024/12/16 23:55:31 UTC
(accumulo) 02/02: (Trivial) Fix recent dead code and warnings
This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
commit 88e10aa31d7bcfc96ff102ac5ef5d760dc7b1577
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Mon Dec 16 18:42:12 2024 -0500
(Trivial) Fix recent dead code and warnings
* Fix unused import introduced in #5127
* Remove dead code for `--fixFiles` in Admin checks left by #4957
* Fix unclosed resource warning introduced in #5148
---
.../org/apache/accumulo/server/util/Admin.java | 78 ----------------------
.../apache/accumulo/test/fate/FateStoreUtil.java | 1 -
.../apache/accumulo/test/functional/SplitIT.java | 3 +-
3 files changed, 1 insertion(+), 81 deletions(-)
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
index 4fadd83358..d24824df4b 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
@@ -38,14 +38,11 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
-import java.util.Optional;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -83,7 +80,6 @@ import org.apache.accumulo.core.lock.ServiceLockPaths.ServiceLockPath;
import org.apache.accumulo.core.manager.thrift.FateService;
import org.apache.accumulo.core.manager.thrift.TFateId;
import org.apache.accumulo.core.metadata.AccumuloTable;
-import org.apache.accumulo.core.metadata.schema.Ample;
import org.apache.accumulo.core.metadata.schema.TabletMetadata;
import org.apache.accumulo.core.rpc.ThriftUtil;
import org.apache.accumulo.core.rpc.clients.ThriftClientTypes;
@@ -116,8 +112,6 @@ import org.slf4j.LoggerFactory;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
-import com.github.benmanes.caffeine.cache.Caffeine;
-import com.github.benmanes.caffeine.cache.LoadingCache;
import com.google.auto.service.AutoService;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
@@ -1048,78 +1042,6 @@ public class Admin implements KeywordExecutable {
return typesFilter;
}
- private static long printDanglingFateOperations(ServerContext context, String tableName)
- throws Exception {
- long totalDanglingSeen = 0;
- if (tableName == null) {
- for (var dataLevel : Ample.DataLevel.values()) {
- try (var tablets = context.getAmple().readTablets().forLevel(dataLevel).build()) {
- totalDanglingSeen += printDanglingFateOperations(context, tablets);
- }
- }
- } else {
- var tableId = context.getTableId(tableName);
- try (var tablets = context.getAmple().readTablets().forTable(tableId).build()) {
- totalDanglingSeen += printDanglingFateOperations(context, tablets);
- }
- }
-
- System.out.printf("\nFound %,d dangling references to fate operations\n", totalDanglingSeen);
-
- return totalDanglingSeen;
- }
-
- private static long printDanglingFateOperations(ServerContext context,
- Iterable<TabletMetadata> tablets) throws Exception {
- Function<Collection<KeyExtent>,Map<KeyExtent,TabletMetadata>> tabletLookup = extents -> {
- try (var lookedupTablets =
- context.getAmple().readTablets().forTablets(extents, Optional.empty()).build()) {
- Map<KeyExtent,TabletMetadata> tabletMap = new HashMap<>();
- lookedupTablets
- .forEach(tabletMetadata -> tabletMap.put(tabletMetadata.getExtent(), tabletMetadata));
- return tabletMap;
- }
- };
-
- UserFateStore<?> ufs = new UserFateStore<>(context, createDummyLockID(), null);
- MetaFateStore<?> mfs = new MetaFateStore<>(context.getZooKeeperRoot() + Constants.ZFATE,
- context.getZooReaderWriter(), createDummyLockID(), null);
- LoadingCache<FateId,ReadOnlyFateStore.TStatus> fateStatusCache = Caffeine.newBuilder()
- .maximumSize(100_000).expireAfterWrite(10, TimeUnit.SECONDS).build(fateId -> {
- if (fateId.getType() == FateInstanceType.META) {
- return mfs.read(fateId).getStatus();
- } else {
- return ufs.read(fateId).getStatus();
- }
- });
-
- Predicate<FateId> activePredicate = fateId -> {
- var status = fateStatusCache.get(fateId);
- switch (status) {
- case NEW:
- case IN_PROGRESS:
- case SUBMITTED:
- case FAILED_IN_PROGRESS:
- return true;
- case FAILED:
- case SUCCESSFUL:
- case UNKNOWN:
- return false;
- default:
- throw new IllegalStateException("Unexpected status: " + status);
- }
- };
-
- AtomicLong danglingSeen = new AtomicLong();
- BiConsumer<KeyExtent,Set<FateId>> danglingConsumer = (extent, fateIds) -> {
- danglingSeen.addAndGet(fateIds.size());
- fateIds.forEach(fateId -> System.out.println(fateId + " " + extent));
- };
-
- findDanglingFateOperations(tablets, tabletLookup, activePredicate, danglingConsumer, 10_000);
- return danglingSeen.get();
- }
-
/**
* Finds tablets that point to fate operations that do not exists or are complete.
*
diff --git a/test/src/main/java/org/apache/accumulo/test/fate/FateStoreUtil.java b/test/src/main/java/org/apache/accumulo/test/fate/FateStoreUtil.java
index 856fd11f26..1f96bd9b94 100644
--- a/test/src/main/java/org/apache/accumulo/test/fate/FateStoreUtil.java
+++ b/test/src/main/java/org/apache/accumulo/test/fate/FateStoreUtil.java
@@ -33,7 +33,6 @@ import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter;
import org.apache.accumulo.core.metadata.AccumuloTable;
import org.apache.accumulo.test.zookeeper.ZooKeeperTestingServer;
-import org.apache.zookeeper.ZooKeeper;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.io.TempDir;
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SplitIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SplitIT.java
index f97c646ae4..720e56f93f 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/SplitIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/SplitIT.java
@@ -59,7 +59,6 @@ import org.apache.accumulo.core.client.admin.InstanceOperations;
import org.apache.accumulo.core.client.admin.NewTableConfiguration;
import org.apache.accumulo.core.client.rfile.RFile;
import org.apache.accumulo.core.client.rfile.RFileWriter;
-import org.apache.accumulo.core.clientImpl.ClientContext;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
@@ -519,7 +518,7 @@ public class SplitIT extends AccumuloClusterHarness {
c.tableOperations().importDirectory(dir).to(tableName).load();
// wait for the tablet to be marked unsplittable
- var ctx = (ClientContext) c;
+ var ctx = getServerContext();
Wait.waitFor(() -> {
var tableId = ctx.getTableId(tableName);
try (var tabletsMeta = ctx.getAmple().readTablets().forTable(tableId).build()) {