This is an automated email from the ASF dual-hosted git repository.
dlmarion pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push:
new 57ecc4d62f Fixes and verification for RFiles located outside of tables
directory (#6611)
57ecc4d62f is described below
commit 57ecc4d62f78aa52255dc64004457c1340cd5a8c
Author: Dave Marion <[email protected]>
AuthorDate: Mon Nov 23 13:41:44 2026 -0500
Fixes and verification for RFiles located outside of tables directory
(#6611)
The changes in this commit are meant to get the existing codebase working
with tablet files that are not located in the conventional path
(/accumulo/tables/.....).
Removed the logic that enforced RFiles were located in paths that contained
'/tables/<tableId>/<tabletDir>'. Removed getVolume(), getTableId(), and
getTabletDir() from ReferencedTabletFile and the parsing of the parts into
the FileParts object.
Made related changes to volume replacment, table disk usage and scan server
references.
Modified existing tests and created a new ExternalTabletFileIT that has
coverage for scanning, major compaction and garbage collection.
Assisted-By: OpenAI GPT-6 Luna
Assisted-By: OpenAI GPT-6.1 Sol
---
.../org/apache/accumulo/core/gc/ReferenceFile.java | 17 +-
.../core/metadata/ReferencedTabletFile.java | 143 ++-----------
.../core/metadata/ScanServerRefTabletFile.java | 6 -
.../accumulo/core/metadata/StoredTabletFile.java | 5 -
.../accumulo/core/metadata/schema/Ample.java | 9 +-
.../metadata/schema/ReferencedTabletFileTest.java | 71 +------
.../org/apache/accumulo/server/fs/VolumeUtil.java | 58 +++++-
.../accumulo/server/metadata/ServerAmpleImpl.java | 9 +-
.../accumulo/server/util/TableDiskUsage.java | 26 +--
.../server/util/adminCommand/ListVolumesUsed.java | 13 +-
.../constraints/MetadataConstraintsTest.java | 15 +-
.../apache/accumulo/server/fs/VolumeUtilTest.java | 9 +
.../accumulo/server/util/TableDiskUsageTest.java | 80 ++++++--
.../main/java/org/apache/accumulo/gc/GCRun.java | 20 +-
.../accumulo/gc/GarbageCollectionAlgorithm.java | 6 +-
.../java/org/apache/accumulo/gc/GcCandidates.java | 2 +-
.../apache/accumulo/gc/GarbageCollectionTest.java | 99 ++++++++-
.../manager/tableOps/bulkVer2/BulkImportMove.java | 3 +-
.../tableOps/bulkVer2/CleanUpBulkImport.java | 3 +-
.../accumulo/monitor/resources/js/functions.js | 6 +-
.../org/apache/accumulo/tserver/ScanServer.java | 4 +-
.../apache/accumulo/test/ExternalTabletFileIT.java | 222 +++++++++++++++++++++
.../accumulo/test/ScanServerMetadataEntriesIT.java | 9 +-
.../test/compaction/ExternalCompaction_1_IT.java | 5 +-
.../test/functional/GarbageCollectorTrashBase.java | 8 +-
.../upgrade/ScanServerUpgrade11to12TestIT.java | 2 +-
26 files changed, 530 insertions(+), 320 deletions(-)
diff --git a/core/src/main/java/org/apache/accumulo/core/gc/ReferenceFile.java
b/core/src/main/java/org/apache/accumulo/core/gc/ReferenceFile.java
index 492e67c2e4..db5f921555 100644
--- a/core/src/main/java/org/apache/accumulo/core/gc/ReferenceFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/gc/ReferenceFile.java
@@ -39,14 +39,20 @@ public class ReferenceFile implements Reference,
Comparable<ReferenceFile> {
// the exact path from the file reference string that is stored in the
metadata
protected final String metadataPath;
- protected ReferenceFile(TableId tableId, String metadataPath, boolean isScan,
- boolean isDirectory) {
+ private ReferenceFile(TableId tableId, String metadataPath, boolean isScan,
boolean isDirectory) {
this.tableId = Objects.requireNonNull(tableId);
this.metadataPath = Objects.requireNonNull(metadataPath);
this.isScan = isScan;
this.isDirectory = isDirectory;
}
+ private ReferenceFile(ScanServerRefTabletFile file) {
+ this.tableId = null;
+ this.metadataPath = Objects.requireNonNull(file.getNormalizedPathStr());
+ this.isScan = true;
+ this.isDirectory = false;
+ }
+
public static ReferenceFile forFile(TableId tableId, StoredTabletFile
tabletFile) {
return new ReferenceFile(tableId, tabletFile.getMetadataPath(), false,
false);
}
@@ -55,8 +61,8 @@ public class ReferenceFile implements Reference,
Comparable<ReferenceFile> {
return new ReferenceFile(tableId, metadataPathPath.toString(), false,
false);
}
- public static ReferenceFile forScan(TableId tableId, ScanServerRefTabletFile
tabletFile) {
- return new ReferenceFile(tableId, tabletFile.getNormalizedPathStr(), true,
false);
+ public static ReferenceFile forScan(ScanServerRefTabletFile tabletFile) {
+ return new ReferenceFile(tabletFile);
}
public static ReferenceFile forScan(TableId tableId, StoredTabletFile
tabletFile) {
@@ -123,7 +129,8 @@ public class ReferenceFile implements Reference,
Comparable<ReferenceFile> {
@Override
public String toString() {
- return "Reference [id=" + tableId + ", ref=" + metadataPath + "]";
+ return "Reference [id=" + tableId + ", ref=" + metadataPath + ", isDir=" +
isDirectory
+ + ", isScan=" + isScan + "]";
}
}
diff --git
a/core/src/main/java/org/apache/accumulo/core/metadata/ReferencedTabletFile.java
b/core/src/main/java/org/apache/accumulo/core/metadata/ReferencedTabletFile.java
index 2bcae4be9d..32123a04bb 100644
---
a/core/src/main/java/org/apache/accumulo/core/metadata/ReferencedTabletFile.java
+++
b/core/src/main/java/org/apache/accumulo/core/metadata/ReferencedTabletFile.java
@@ -18,15 +18,10 @@
*/
package org.apache.accumulo.core.metadata;
-import static org.apache.accumulo.core.Constants.HDFS_TABLES_DIR;
-
-import java.net.URI;
import java.util.Comparator;
import java.util.Objects;
import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.TableId;
-import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.fs.Path;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,114 +44,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
justification = "Constructor validation is required for proper
initialization")
public class ReferencedTabletFile extends
AbstractTabletFile<ReferencedTabletFile> {
- public static class FileParts {
-
- // parts of an absolute URI, like
"hdfs://1.2.3.4/accumulo/tables/2a/t-0003/C0004.rf"
- // volume: hdfs://1.2.3.4/accumulo
- // tableId: 2a
- // tabletDir: t-0003
- // fileName: C0004.rf
- // normalizedPath: hdfs://1.2.3.4/accumulo/tables/2a/t-0003/C0004.rf
- private final String volume;
- private final TableId tableId;
- private final String tabletDir;
- private final String fileName;
- private final String normalizedPath;
-
- public FileParts(String volume, TableId tableId, String tabletDir, String
fileName,
- String normalizedPath) {
- this.volume = volume;
- this.tableId = tableId;
- this.tabletDir = tabletDir;
- this.fileName = fileName;
- this.normalizedPath = normalizedPath;
- }
-
- public String getVolume() {
- return volume;
- }
-
- public TableId getTableId() {
- return tableId;
- }
-
- public String getTabletDir() {
- return tabletDir;
- }
-
- public String getFileName() {
- return fileName;
- }
-
- public String getNormalizedPath() {
- return normalizedPath;
- }
-
- }
-
- private static String constructErrorMsg(Path filePath) {
- return "Missing or invalid part of tablet file metadata entry: " +
filePath;
- }
-
- public static FileParts parsePath(Path filePath) {
- // File name construct: <volume>/<tablePath>/<tableId>/<tablet>/<file>
- // Example: hdfs://namenode:9020/accumulo/tables/1/default_tablet/F00001.rf
- // Example compaction tmp file:
- //
hdfs://namenode:9020/accumulo/tables/1/default_tablet/F00001.rf_tmp_ECID-<uuid>
- final URI uri = filePath.toUri();
-
- // validate that this is a fully qualified uri
- Preconditions.checkArgument(uri.getScheme() != null,
constructErrorMsg(filePath));
-
- final String path = uri.getPath(); // ex:
/accumulo/tables/1/default_tablet/F00001.rf
- final String[] parts = path.split("/");
- final int numParts = parts.length; // should contain tables, 1,
default_tablet, F00001.rf
-
- if (numParts < 4) {
- throw new IllegalArgumentException(constructErrorMsg(filePath));
- }
-
- final String fileName = parts[numParts - 1];
- final String tabletDirectory = parts[numParts - 2];
- final TableId tableId = TableId.of(parts[numParts - 3]);
- final String tablesPath = parts[numParts - 4];
-
- // determine where file path starts, the rest is the volume
- final String computedFilePath =
- HDFS_TABLES_DIR + "/" + tableId.canonical() + "/" + tabletDirectory +
"/" + fileName;
- final String uriString = uri.toString();
- int idx = uriString.lastIndexOf(computedFilePath);
-
- if (idx == -1) {
- throw new IllegalArgumentException(constructErrorMsg(filePath));
- }
-
- // The volume is the beginning portion of the uri up to the start
- // of the file path.
- final String volume = uriString.substring(0, idx);
-
- if (StringUtils.isBlank(fileName) || StringUtils.isBlank(tabletDirectory)
- || StringUtils.isBlank(tablesPath) || StringUtils.isBlank(volume)) {
- throw new IllegalArgumentException(constructErrorMsg(filePath));
- }
- ValidationUtil.validateFileName(fileName);
- Preconditions.checkArgument(tablesPath.equals(HDFS_TABLES_DIR_NAME),
- "tables directory name is not " + HDFS_TABLES_DIR_NAME + ", is " +
tablesPath);
-
- final String normalizedPath = volume + computedFilePath;
-
- if (!normalizedPath.equals(uriString)) {
- throw new RuntimeException("Error parsing file path, " + normalizedPath
+ " != " + uriString);
- }
-
- return new FileParts(volume, tableId, tabletDirectory, fileName,
normalizedPath);
-
- }
-
- private final FileParts parts;
-
private static final Logger log =
LoggerFactory.getLogger(ReferencedTabletFile.class);
- private static final String HDFS_TABLES_DIR_NAME =
HDFS_TABLES_DIR.substring(1);
private static final Comparator<ReferencedTabletFile> comparator =
Comparator.comparing(ReferencedTabletFile::getNormalizedPathStr)
@@ -171,26 +59,20 @@ public class ReferencedTabletFile extends
AbstractTabletFile<ReferencedTabletFil
* qualify an absolute path or create a new file.
*/
public ReferencedTabletFile(Path metaPath, Range range) {
- super(Objects.requireNonNull(metaPath), range);
- log.trace("Parsing TabletFile from {}", metaPath);
- parts = parsePath(metaPath);
- }
-
- public String getVolume() {
- return parts.getVolume();
- }
-
- public TableId getTableId() {
- return parts.getTableId();
+ super(validatePath(metaPath), range);
+ log.trace("Creating tablet file reference from {}", metaPath);
}
- public String getTabletDir() {
- return parts.getTabletDir();
+ private static Path validatePath(Path metaPath) {
+ Path path = ValidationUtil.validate(Objects.requireNonNull(metaPath));
+ Preconditions.checkArgument(!path.getName().isEmpty(), "Path must identify
a file: %s", path);
+ Preconditions.checkArgument(path.getParent() != null, "File must be in a
directory: %s", path);
+ return path;
}
@Override
public String getFileName() {
- return parts.getFileName();
+ return path.getName();
}
/**
@@ -198,7 +80,7 @@ public class ReferencedTabletFile extends
AbstractTabletFile<ReferencedTabletFil
* metadata.
*/
public String getNormalizedPathStr() {
- return parts.getNormalizedPath();
+ return path.toString();
}
/**
@@ -216,20 +98,19 @@ public class ReferencedTabletFile extends
AbstractTabletFile<ReferencedTabletFil
@Override
public boolean equals(Object obj) {
if (obj instanceof ReferencedTabletFile that) {
- return parts.getNormalizedPath().equals(that.parts.getNormalizedPath())
- && range.equals(that.range);
+ return path.equals(that.path) && range.equals(that.range);
}
return false;
}
@Override
public int hashCode() {
- return Objects.hash(parts.getNormalizedPath(), range);
+ return Objects.hash(path, range);
}
@Override
public String toString() {
- return parts.getNormalizedPath();
+ return path.toString();
}
public static ReferencedTabletFile of(final Path path) {
diff --git
a/core/src/main/java/org/apache/accumulo/core/metadata/ScanServerRefTabletFile.java
b/core/src/main/java/org/apache/accumulo/core/metadata/ScanServerRefTabletFile.java
index c289c38a47..35ecc5d926 100644
---
a/core/src/main/java/org/apache/accumulo/core/metadata/ScanServerRefTabletFile.java
+++
b/core/src/main/java/org/apache/accumulo/core/metadata/ScanServerRefTabletFile.java
@@ -34,12 +34,6 @@ public class ScanServerRefTabletFile extends
ReferencedTabletFile {
private final Text serverAddress;
private final Text uuid;
- public ScanServerRefTabletFile(UUID serverLockUUID, String serverAddress,
String file) {
- super(new Path(URI.create(file)));
- this.serverAddress = new Text(serverAddress);
- uuid = new Text(serverLockUUID.toString());
- }
-
public ScanServerRefTabletFile(String file, String serverAddress, UUID
serverLockUUID) {
super(new Path(URI.create(file)));
this.serverAddress = new Text(serverAddress);
diff --git
a/core/src/main/java/org/apache/accumulo/core/metadata/StoredTabletFile.java
b/core/src/main/java/org/apache/accumulo/core/metadata/StoredTabletFile.java
index b1f80ccd75..08ab90a7b8 100644
--- a/core/src/main/java/org/apache/accumulo/core/metadata/StoredTabletFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/metadata/StoredTabletFile.java
@@ -30,7 +30,6 @@ import java.util.Objects;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.util.json.ByteArrayToBase64TypeAdapter;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.DataInputBuffer;
@@ -109,10 +108,6 @@ public class StoredTabletFile extends
AbstractTabletFile<StoredTabletFile> {
return referencedTabletFile;
}
- public TableId getTableId() {
- return referencedTabletFile.getTableId();
- }
-
@Override
public String getFileName() {
return referencedTabletFile.getFileName();
diff --git
a/core/src/main/java/org/apache/accumulo/core/metadata/schema/Ample.java
b/core/src/main/java/org/apache/accumulo/core/metadata/schema/Ample.java
index a82ac6df7f..2d78ca6d1e 100644
--- a/core/src/main/java/org/apache/accumulo/core/metadata/schema/Ample.java
+++ b/core/src/main/java/org/apache/accumulo/core/metadata/schema/Ample.java
@@ -44,6 +44,7 @@ import
org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType;
import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
import org.apache.accumulo.core.tabletserver.log.LogEntry;
import org.apache.accumulo.core.util.time.SteadyTime;
+import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
/**
@@ -636,19 +637,19 @@ public interface Ample {
/**
* Create a Bulk Load In Progress flag in the metadata table
*
- * @param path The bulk directory filepath
+ * @param bulkLoadDir The bulk directory filepath
* @param fateId The FateId of the Bulk Import Fate operation.
*/
- default void addBulkLoadInProgressFlag(String path, FateId fateId) {
+ default void addBulkLoadInProgressFlag(Path bulkLoadDir, FateId fateId) {
throw new UnsupportedOperationException();
}
/**
* Remove a Bulk Load In Progress flag from the metadata table.
*
- * @param path The bulk directory filepath
+ * @param bulkLoadDir The bulk directory filepath
*/
- default void removeBulkLoadInProgressFlag(String path) {
+ default void removeBulkLoadInProgressFlag(Path bulkLoadDir) {
throw new UnsupportedOperationException();
}
diff --git
a/core/src/test/java/org/apache/accumulo/core/metadata/schema/ReferencedTabletFileTest.java
b/core/src/test/java/org/apache/accumulo/core/metadata/schema/ReferencedTabletFileTest.java
index 04c38f9f9b..78ebe76db8 100644
---
a/core/src/test/java/org/apache/accumulo/core/metadata/schema/ReferencedTabletFileTest.java
+++
b/core/src/test/java/org/apache/accumulo/core/metadata/schema/ReferencedTabletFileTest.java
@@ -25,7 +25,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.PartialKey;
import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.metadata.ReferencedTabletFile;
import org.apache.accumulo.core.metadata.StoredTabletFile;
import org.apache.hadoop.fs.Path;
@@ -34,94 +33,46 @@ import org.junit.jupiter.api.Test;
public class ReferencedTabletFileTest {
- private ReferencedTabletFile test(String metadataFile, String volume, String
tableId,
- String tabletDir, String fileName) {
+ private ReferencedTabletFile test(String metadataFile, String fileName) {
String metadataPath = StoredTabletFile.serialize(metadataFile);
StoredTabletFile storedTabletFile = new StoredTabletFile(metadataPath);
ReferencedTabletFile tabletFile = storedTabletFile.getTabletFile();
// Make sure original file name wasn't changed when serialized
assertTrue(metadataPath.contains(metadataFile));
- assertEquals(volume, tabletFile.getVolume());
assertEquals(metadataPath, storedTabletFile.getMetadata());
- assertEquals(TableId.of(tableId), tabletFile.getTableId());
- assertEquals(tabletDir, tabletFile.getTabletDir());
assertEquals(fileName, tabletFile.getFileName());
return tabletFile;
}
@Test
public void testValidPaths() {
- test("hdfs://localhost:8020/accumulo/tables/2a/default_tablet/F0000070.rf",
- "hdfs://localhost:8020/accumulo", "2a", "default_tablet",
"F0000070.rf");
- test("hdfs://nn1:9000/accumulo/tables/5a/t-0005/C0009.rf",
"hdfs://nn1:9000/accumulo", "5a",
- "t-0005", "C0009.rf");
- test(
-
"file:/home/dude/workspace/accumulo/test/target/mini-tests/org.apache.accumulo.test.VolumeIT_test/volumes/v1/tables/1/t-0000003/F0000006.rf",
-
"file:/home/dude/workspace/accumulo/test/target/mini-tests/org.apache.accumulo.test.VolumeIT_test/volumes/v1",
- "1", "t-0000003", "F0000006.rf");
+
test("hdfs://localhost:8020/accumulo/tables/2a/default_tablet/F0000070.rf",
"F0000070.rf");
+ test("hdfs://nn1:9000/unrelated/external/location/C0009.rf", "C0009.rf");
+ test("file:/home/dude/external-data/F0000006.rf", "F0000006.rf");
}
@Test
public void testBadPaths() {
- // 2a< srv:dir
- final String message = "Failed to throw error on bad path";
-
- assertThrows(IllegalArgumentException.class,
- () -> test("C0004.rf", "", "2a", "t-0003", "C0004.rf"), message);
- assertThrows(IllegalArgumentException.class, () -> test("dir", "", "2a",
"", ""), message);
-
- assertThrows(IllegalArgumentException.class,
- () ->
test("hdfs://localhost:8020/accumulo/tablets/2a/default_tablet/F0000070.rf",
- "hdfs://localhost:8020/accumulo", "2a", "default_tablet",
"F0000070.rf"),
- message);
- assertThrows(IllegalArgumentException.class,
- () ->
test("hdfs://localhost:8020/accumulo/2a/default_tablet/F0000070.rf",
- " hdfs://localhost:8020/accumulo", "2a", "default_tablet", "
F0000070.rf"),
- message);
- assertThrows(IllegalArgumentException.class,
- () -> test("/accumulo/tables/2a/default_tablet/F0000070.rf", "", "2a",
"default_tablet",
- "F0000070.rf"),
- message);
assertThrows(IllegalArgumentException.class,
- () -> test("hdfs://localhost:8020/accumulo/tables/2a/F0000070.rf",
- "hdfs://localhost:8020/accumulo", "2a", "", "F0000070.rf"),
- message);
- assertThrows(IllegalArgumentException.class,
- () -> test("hdfs://localhost:8020/accumulo/tables/F0000070.rf",
- "hdfs://localhost:8020/accumulo", null, "", "F0000070.rf"),
- message);
-
- }
-
- private final String id = "2a";
- private final String dir = "t-0003";
- private final String filename = "C0004.rf";
-
- @Test
- public void testFullPathWithVolume() {
- String volume = "hdfs://1.2.3.4/accumulo";
- String metadataEntry = volume + "/tables/" + id + "/" + dir + "/" +
filename;
- test(metadataEntry, volume, id, dir, filename);
+ () -> new ReferencedTabletFile(new Path("C0004.rf")));
+ assertThrows(IllegalArgumentException.class, () -> new
ReferencedTabletFile(new Path("dir")));
}
@Test
public void testNormalizePath() {
- String uglyVolume =
"hdfs://nn.somewhere.com:86753/accumulo/blah/.././/bad/bad2/../.././/////";
- String metadataEntry = uglyVolume + "/tables/" + id + "/" + dir + "/" +
filename;
- ReferencedTabletFile uglyFile =
- test(metadataEntry, "hdfs://nn.somewhere.com:86753/accumulo", id, dir,
filename);
+ String uglyPath =
+
"hdfs://nn.somewhere.com:86753/external/blah/.././/bad/bad2/../.././/////file.rf";
+ ReferencedTabletFile uglyFile = test(uglyPath, "file.rf");
ReferencedTabletFile niceFile = StoredTabletFile
- .of(new Path(
- "hdfs://nn.somewhere.com:86753/accumulo/tables/" + id + "/" + dir
+ "/" + filename))
- .getTabletFile();
+ .of(new
Path("hdfs://nn.somewhere.com:86753/external/file.rf")).getTabletFile();
assertEquals(niceFile, uglyFile);
assertEquals(niceFile.hashCode(), uglyFile.hashCode());
}
@Test
public void testNonRowRange() {
- Path testPath = new
Path("hdfs://localhost:8020/accumulo/tables/2a/default_tablet/F0000070.rf");
+ Path testPath = new Path("hdfs://localhost:8020/outside/F0000070.rf");
// range where start key is not a row key
Range r1 = new Range(new Key("r1", "f1"), true, null, false);
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java
b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java
index d56a434a9c..4413526905 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java
@@ -64,12 +64,40 @@ public class VolumeUtil {
public static Path switchVolume(Path path, FileType ft, Map<Path,Path>
replacements) {
Path replacement = null;
if (!replacements.isEmpty()) {
- // removing trailing slash for exact match comparison on the volume
itself
- Path volume = removeTrailingSlash(ft.getVolume(requireNonNull(path)));
- replacement = replacements.entrySet().stream()
- .filter(entry -> removeTrailingSlash(entry.getKey()).equals(volume))
- .map(entry -> new Path(entry.getValue(),
requireNonNull(ft.removeVolume(path))))
- .findFirst().orElse(null);
+ Path inputPath = requireNonNull(path);
+ if (inputPath.toString().indexOf(ft.getDirectory()) > 0) {
+ // removing trailing slash for exact match comparison on the volume
itself
+ Path volume = removeTrailingSlash(ft.getVolume(inputPath));
+ replacement = replacements.entrySet().stream()
+ .filter(entry ->
removeTrailingSlash(entry.getKey()).equals(volume))
+ .map(entry -> new Path(entry.getValue(),
requireNonNull(ft.removeVolume(inputPath))))
+ .findFirst().orElse(null);
+ } else {
+ // The directory for the file type is not in the path
+ // which means this is an external file. Handle volume replacement
+ // differently
+ final String src = inputPath.toString();
+ int matchingLength = 0;
+ Entry<Path,Path> matchingEntry = null;
+ for (Entry<Path,Path> entry : replacements.entrySet()) {
+ // Since the path is not in a volume, we need to use a
+ // trailing slash on the replacement volume to ensure
+ // an exact match.
+ String replacementKey = entry.getKey().toString().endsWith("/")
+ ? entry.getKey().toString() : entry.getKey().toString() + "/";
+ if (src.regionMatches(0, replacementKey, 0,
replacementKey.length())) {
+ if (replacementKey.length() > matchingLength) {
+ matchingLength = replacementKey.length();
+ matchingEntry = entry;
+ }
+ }
+ }
+ if (matchingEntry != null) {
+ // subtract one from the matching length for the slash we added above
+ replacement =
+ new Path(matchingEntry.getValue().toString() +
src.substring(matchingLength - 1));
+ }
+ }
}
if (replacement != null) {
log.trace("Replacing {} with {} for {}", path, replacement, ft);
@@ -79,6 +107,24 @@ public class VolumeUtil {
return null;
}
+ /*
+ * public static Path switchVolume(Path path, FileType ft, Map<Path,Path>
replacements) {
+ * requireNonNull(path); for (Entry<Path,Path> entry :
replacements.entrySet()) { Path source =
+ * removeTrailingSlash(entry.getKey()); Path relative =
getRelativePath(source, path); if
+ * (relative != null) { Path replacement = relative.toString().equals(".") ?
entry.getValue() :
+ * new Path(entry.getValue(), relative); log.trace("Replacing {} with {} for
{}", path,
+ * replacement, ft); return replacement; } } log.trace("No replacement
available for {} at {}",
+ * ft, path); return null; }
+ *
+ * private static Path getRelativePath(Path parent, Path path) {
ArrayList<String> names = new
+ * ArrayList<>(); Path current = path; while (current != null &&
!current.equals(parent)) {
+ * names.add(current.getName()); current = current.getParent(); } if
(current == null) { return
+ * null; }
+ *
+ * Path relative = null; for (int i = names.size() - 1; i >= 0; i--) {
relative = relative == null
+ * ? new Path(names.get(i)) : new Path(relative, names.get(i)); } return
relative == null ? new
+ * Path(".") : relative; }
+ */
public static LogEntry switchVolume(LogEntry le, Map<Path,Path>
replacements) {
Path switchedPath = switchVolume(le.getPath(), FileType.WAL, replacements);
return switchedPath == null ? null : LogEntry.withSwitchedVolume(le,
switchedPath);
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/metadata/ServerAmpleImpl.java
b/server/base/src/main/java/org/apache/accumulo/server/metadata/ServerAmpleImpl.java
index 03829c7869..ae5b010fcf 100644
---
a/server/base/src/main/java/org/apache/accumulo/server/metadata/ServerAmpleImpl.java
+++
b/server/base/src/main/java/org/apache/accumulo/server/metadata/ServerAmpleImpl.java
@@ -50,6 +50,7 @@ import
org.apache.accumulo.core.metadata.schema.MetadataSchema.BlipSection;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.DeletesSection;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.server.ServerContext;
+import org.apache.hadoop.fs.Path;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -166,11 +167,11 @@ public class ServerAmpleImpl extends AmpleImpl implements
Ample {
}
@Override
- public void addBulkLoadInProgressFlag(String path, FateId fateId) {
+ public void addBulkLoadInProgressFlag(Path bulkLoadDir, FateId fateId) {
// Bulk Import operations are not supported on the metadata table, so no
entries will ever be
// required on the root table.
- Mutation m = new Mutation(BlipSection.getRowPrefix() + path);
+ Mutation m = new Mutation(BlipSection.getRowPrefix() +
bulkLoadDir.toString());
m.put(EMPTY_TEXT, EMPTY_TEXT, new Value(fateId.canonical()));
try (BatchWriter bw =
context.createBatchWriter(SystemTables.METADATA.tableName())) {
@@ -181,11 +182,11 @@ public class ServerAmpleImpl extends AmpleImpl implements
Ample {
}
@Override
- public void removeBulkLoadInProgressFlag(String path) {
+ public void removeBulkLoadInProgressFlag(Path bulkLoadDir) {
// Bulk Import operations are not supported on the metadata table, so no
entries will ever be
// required on the root table.
- Mutation m = new Mutation(BlipSection.getRowPrefix() + path);
+ Mutation m = new Mutation(BlipSection.getRowPrefix() +
bulkLoadDir.toString());
m.putDelete(EMPTY_TEXT, EMPTY_TEXT);
try (BatchWriter bw =
context.createBatchWriter(SystemTables.METADATA.tableName())) {
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java
b/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java
index b0aebbb228..93136c11d2 100644
---
a/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java
+++
b/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java
@@ -194,7 +194,7 @@ public class TableDiskUsage {
// read the metadata
try (var tabletsMetadata = ((ClientContext)
client).getAmple().readTablets().forTable(tableId)
.fetch(FILES).build()) {
- final Set<StoredTabletFile> allFiles = new HashSet<>();
+ final Set<String> allFiles = new HashSet<>();
for (var tm : tabletsMetadata) {
final Map<StoredTabletFile,DataFileValue> tmFiles = tm.getFilesMap();
@@ -202,27 +202,17 @@ public class TableDiskUsage {
for (var file : tmFiles.entrySet()) {
final var stf = file.getKey();
final var dataFileValue = file.getValue();
-
- // get the table referenced by the file which may not be the same
as the current
- // table we are scanning if the file is shared between multiple
tables
- final TableId fileTableRef = stf.getTableId();
-
- // if this is a ref to a different table than the one we are
scanning then we need
- // to make sure the table is also linked for this shared file if
the table is
- // part of the set of tables we are running du on so we can track
shared usages
- if (!fileTableRef.equals(tableId) &&
tableIds.contains(fileTableRef)) {
- // link the table and the shared file for computing shared sizes
- tdu.linkFileAndTable(fileTableRef, stf.getFileName());
- }
-
- // link the file to the table we are scanning for
- tdu.linkFileAndTable(tableId, stf.getFileName());
+ // The metadata row identifies the table that references this
file. Use the full path
+ // to identify shared files because their URI does not encode a
table ID and basenames
+ // are not necessarily unique.
+ final String filePath = stf.getNormalizedPathStr();
+ tdu.linkFileAndTable(tableId, filePath);
// add the file size for the table if not already seen for this
scan
- if (allFiles.add(stf)) {
+ if (allFiles.add(filePath)) {
// This tracks the file size for individual files for computing
shared file statistics
// later
- tdu.addFileSize(stf.getFileName(), dataFileValue.getSize());
+ tdu.addFileSize(filePath, dataFileValue.getSize());
}
}
}
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/util/adminCommand/ListVolumesUsed.java
b/server/base/src/main/java/org/apache/accumulo/server/util/adminCommand/ListVolumesUsed.java
index 7a13db610a..90cab9155e 100644
---
a/server/base/src/main/java/org/apache/accumulo/server/util/adminCommand/ListVolumesUsed.java
+++
b/server/base/src/main/java/org/apache/accumulo/server/util/adminCommand/ListVolumesUsed.java
@@ -72,11 +72,18 @@ public class ListVolumesUsed extends
ServerKeywordExecutable<ServerOpts> {
}
private String getTableURI(String rootTabletDir) {
- Path ret = FileType.TABLE.getVolume(new Path(rootTabletDir));
- if (ret == null) {
+ Path path = new Path(rootTabletDir);
+ try {
+ Path ret = FileType.TABLE.getVolume(path);
+ if (ret != null) {
+ return ret.toString();
+ }
return "RELATIVE";
+ } catch (IllegalArgumentException e) {
+ // External file references need not contain the Accumulo tables
directory. Include their
+ // full URI so this command remains useful without inventing a volume
root.
+ return "EXTERNAL: " + path.getParent().getParent();
}
- return ret.toString();
}
private String getLogURI(Path logEntry) {
diff --git
a/server/base/src/test/java/org/apache/accumulo/server/constraints/MetadataConstraintsTest.java
b/server/base/src/test/java/org/apache/accumulo/server/constraints/MetadataConstraintsTest.java
index c9beb51c06..ca46797556 100644
---
a/server/base/src/test/java/org/apache/accumulo/server/constraints/MetadataConstraintsTest.java
+++
b/server/base/src/test/java/org/apache/accumulo/server/constraints/MetadataConstraintsTest.java
@@ -315,14 +315,15 @@ public class MetadataConstraintsTest {
new Value(fateId1.canonical()));
assertViolation(mc, m, (short) 3100);
- // Missing tables directory in path
+ // External files do not need to be in the tables directory
m = new Mutation(new Text("0;foo"));
- m.put(BulkFileColumnFamily.NAME,
+ Text externalFileMetadata =
new Text(StoredTabletFile.of(new
Path("hdfs://1.2.3.4/accumulo/tables/2a/t-0003/someFile"))
.getMetadata().replace("hdfs://1.2.3.4/accumulo/tables/2a/t-0003/someFile",
- "hdfs://1.2.3.4/accumulo/2a/t-0003/someFile")),
- new Value(fateId1.canonical()));
- assertViolation(mc, m, (short) 3100);
+ "hdfs://1.2.3.4/accumulo/2a/t-0003/someFile"));
+ m.put(BulkFileColumnFamily.NAME, externalFileMetadata, new
Value(fateId1.canonical()));
+ m.put(DataFileColumnFamily.NAME, externalFileMetadata, new
DataFileValue(1, 1).encodeAsValue());
+ assertTrue(mc.check(createEnv(), m).isEmpty());
m = new Mutation(new Text("0;foo"));
m.put(
@@ -477,14 +478,14 @@ public class MetadataConstraintsTest {
value);
assertViolation(mc, m, (short) 3100);
- // Missing tables directory in path
+ // External files do not need to be in the tables directory
m = new Mutation(new Text("0;foo"));
m.put(columnFamily,
new Text(StoredTabletFile.of(new
Path("hdfs://1.2.3.4/accumulo/tables/2a/t-0003/someFile"))
.getMetadata().replace("hdfs://1.2.3.4/accumulo/tables/2a/t-0003/someFile",
"hdfs://1.2.3.4/accumulo/2a/t-0003/someFile")),
new DataFileValue(1, 1).encodeAsValue());
- assertViolation(mc, m, (short) 3100);
+ assertTrue(mc.check(createEnv(), m).isEmpty());
// Should pass validation (inf range)
m = new Mutation(new Text("0;foo"));
diff --git
a/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeUtilTest.java
b/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeUtilTest.java
index 51c2b94e0f..ef74cc9b7f 100644
---
a/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeUtilTest.java
+++
b/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeUtilTest.java
@@ -52,6 +52,15 @@ public class VolumeUtilTest {
FileType.TABLE, replacements));
assertNull(VolumeUtil.switchVolume(new
Path("file:/nn1/a/accumulo/tables/t-00000/C000.rf"),
FileType.TABLE, replacements));
+ assertEquals(new Path("viewfs:/a/accumulo/external/C000.rf"),
VolumeUtil.switchVolume(
+ new Path("hdfs://nn1/accumulo/external/C000.rf"), FileType.TABLE,
replacements));
+ assertNull(VolumeUtil.switchVolume(new
Path("hdfs://nn1/accumulo-sibling/external/C000.rf"),
+ FileType.TABLE, replacements));
+ assertEquals(new Path("viewfs:/a/accumulo/dir/C000.rf"),
+ VolumeUtil.switchVolume(new
Path("hdfs://nn1:9000/accumulo/ext/dir/C000.rf"),
+ FileType.TABLE,
+ Map.of(new Path("hdfs://nn1:9000/accumulo"), new
Path("viewfs:/b/accumulo"),
+ new Path("hdfs://nn1:9000/accumulo/ext"), new
Path("viewfs:/a/accumulo"))));
replacements.clear();
replacements.put(new Path("hdfs://nn1/d1/accumulo"), new
Path("viewfs:/a/accumulo"));
diff --git
a/server/base/src/test/java/org/apache/accumulo/server/util/TableDiskUsageTest.java
b/server/base/src/test/java/org/apache/accumulo/server/util/TableDiskUsageTest.java
index cab48d722f..822e31a5d0 100644
---
a/server/base/src/test/java/org/apache/accumulo/server/util/TableDiskUsageTest.java
+++
b/server/base/src/test/java/org/apache/accumulo/server/util/TableDiskUsageTest.java
@@ -78,11 +78,11 @@ public class TableDiskUsageTest {
final TabletsMetadata mockTabletsMetadata = mockTabletsMetadata(client,
tableId1);
List<TabletMetadata> realTabletsMetadata = new ArrayList<>();
- appendFileMetadata(realTabletsMetadata,
+ appendFileMetadata(realTabletsMetadata, tableId1,
getTabletFile(volume1, tableId1, tabletName1, "C0001.rf"), 1024);
- appendFileMetadata(realTabletsMetadata,
+ appendFileMetadata(realTabletsMetadata, tableId1,
getTabletFile(volume1, tableId1, tabletName1, "C0002.rf"), 1024);
- appendFileMetadata(realTabletsMetadata,
+ appendFileMetadata(realTabletsMetadata, tableId1,
getTabletFile(volume1, tableId1, tabletName2, "C0003.rf"), 2048);
mockTabletsMetadataIter(mockTabletsMetadata,
realTabletsMetadata.iterator());
@@ -108,13 +108,13 @@ public class TableDiskUsageTest {
final TabletsMetadata mockTabletsMetadata = mockTabletsMetadata(client,
tableId1);
List<TabletMetadata> realTabletsMetadata = new ArrayList<>();
- appendFileMetadata(realTabletsMetadata,
+ appendFileMetadata(realTabletsMetadata, tableId1,
getTabletFile(volume1, tableId1, tabletName1, "C0001.rf"), 1024);
- appendFileMetadata(realTabletsMetadata,
+ appendFileMetadata(realTabletsMetadata, tableId1,
getTabletFile(volume1, tableId1, tabletName1, "C0002.rf"), 1024);
- appendFileMetadata(realTabletsMetadata,
+ appendFileMetadata(realTabletsMetadata, tableId1,
getTabletFile(volume2, tableId1, tabletName2, "C0003.rf"), 2048);
- appendFileMetadata(realTabletsMetadata,
+ appendFileMetadata(realTabletsMetadata, tableId1,
getTabletFile(volume2, tableId1, tabletName2, "C0004.rf"), 10000);
mockTabletsMetadataIter(mockTabletsMetadata,
realTabletsMetadata.iterator());
@@ -140,8 +140,8 @@ public class TableDiskUsageTest {
mockTabletsMetadata(client, SystemTables.METADATA.tableId());
List<TabletMetadata> realTabletsMetadata = new ArrayList<>();
- appendFileMetadata(realTabletsMetadata, getTabletFile(volume1,
SystemTables.METADATA.tableId(),
- SystemTables.METADATA.tableName(), "C0001.rf"), 1024);
+ appendFileMetadata(realTabletsMetadata, SystemTables.METADATA.tableId(),
getTabletFile(volume1,
+ SystemTables.METADATA.tableId(), SystemTables.METADATA.tableName(),
"C0001.rf"), 1024);
mockTabletsMetadataIter(mockTabletsMetadata,
realTabletsMetadata.iterator());
EasyMock.replay(client, mockTabletsMetadata);
@@ -165,9 +165,9 @@ public class TableDiskUsageTest {
final TabletsMetadata mockTabletsMetadata = mockTabletsMetadata(client,
tableId1);
List<TabletMetadata> realTabletsMetadata = new ArrayList<>();
- appendFileMetadata(realTabletsMetadata,
+ appendFileMetadata(realTabletsMetadata, tableId1,
getTabletFile(volume1, tableId1, tabletName1, "C0001.rf"), 1024);
- appendFileMetadata(realTabletsMetadata,
+ appendFileMetadata(realTabletsMetadata, tableId1,
getTabletFile(volume1, tableId1, tabletName1, "C0001.rf"), 1024);
mockTabletsMetadataIter(mockTabletsMetadata,
realTabletsMetadata.iterator());
@@ -216,30 +216,30 @@ public class TableDiskUsageTest {
final TabletsMetadata mockTabletsMetadata1 = mockTabletsMetadata(client,
tableId1);
List<TabletMetadata> realTabletsMetadata1 = new ArrayList<>();
- appendFileMetadata(realTabletsMetadata1,
+ appendFileMetadata(realTabletsMetadata1, tableId1,
getTabletFile(volume1, tableId1, tabletName1, "C0001.rf"), 1024);
- appendFileMetadata(realTabletsMetadata1,
+ appendFileMetadata(realTabletsMetadata1, tableId1,
getTabletFile(volume1, tableId1, tabletName1, "C0002.rf"), 4096);
mockTabletsMetadataIter(mockTabletsMetadata1,
realTabletsMetadata1.iterator());
final TabletsMetadata mockTabletsMetadata2 = mockTabletsMetadata(client,
tableId2);
List<TabletMetadata> realTabletsMetadata2 = new ArrayList<>();
- appendFileMetadata(realTabletsMetadata2,
+ appendFileMetadata(realTabletsMetadata2, tableId2,
getTabletFile(volume1, tableId2, tabletName2, "C0003.rf"), 2048);
- appendFileMetadata(realTabletsMetadata2,
+ appendFileMetadata(realTabletsMetadata2, tableId2,
getTabletFile(volume1, tableId2, tabletName2, "C0004.rf"), 3000);
mockTabletsMetadataIter(mockTabletsMetadata2,
realTabletsMetadata2.iterator());
final TabletsMetadata mockTabletsMetadata3 = mockTabletsMetadata(client,
tableId3);
List<TabletMetadata> realTabletsMetadata3 = new ArrayList<>();
// shared file
- appendFileMetadata(realTabletsMetadata3,
+ appendFileMetadata(realTabletsMetadata3, tableId3,
getTabletFile(volume1, tableId2, tabletName2, "C0003.rf"), 2048);
- appendFileMetadata(realTabletsMetadata3,
+ appendFileMetadata(realTabletsMetadata3, tableId3,
getTabletFile(volume1, tableId3, tabletName3, "C0005.rf"), 84520);
- appendFileMetadata(realTabletsMetadata3,
+ appendFileMetadata(realTabletsMetadata3, tableId3,
getTabletFile(volume1, tableId3, tabletName3, "C0006.rf"), 3000);
- appendFileMetadata(realTabletsMetadata3,
+ appendFileMetadata(realTabletsMetadata3, tableId3,
getTabletFile(volume1, tableId3, tabletName4, "C0007.rf"), 98456);
mockTabletsMetadataIter(mockTabletsMetadata3,
realTabletsMetadata3.iterator());
@@ -268,6 +268,44 @@ public class TableDiskUsageTest {
EasyMock.verify(client, mockTabletsMetadata1, mockTabletsMetadata2,
mockTabletsMetadata3);
}
+ @Test
+ public void testExternalFilesAreSharedByFullPath() throws Exception {
+ final ClientContext client = EasyMock.createMock(ClientContext.class);
+
EasyMock.expect(client.createTableIdToQualifiedNameMap()).andReturn(tableIdToNameMap);
+
+ final TabletsMetadata mockTabletsMetadata1 = mockTabletsMetadata(client,
tableId1);
+ final List<TabletMetadata> table1Metadata = new ArrayList<>();
+ appendFileMetadata(table1Metadata, tableId1,
+ new
StoredTabletFile(StoredTabletFile.serialize("hdfs://nn/external/files/shared.rf")),
+ 100);
+ mockTabletsMetadataIter(mockTabletsMetadata1, table1Metadata.iterator());
+
+ final TabletsMetadata mockTabletsMetadata2 = mockTabletsMetadata(client,
tableId2);
+ final List<TabletMetadata> table2Metadata = new ArrayList<>();
+ appendFileMetadata(table2Metadata, tableId2,
+ new
StoredTabletFile(StoredTabletFile.serialize("hdfs://nn/external/files/shared.rf")),
+ 100);
+ mockTabletsMetadataIter(mockTabletsMetadata2, table2Metadata.iterator());
+
+ final TabletsMetadata mockTabletsMetadata3 = mockTabletsMetadata(client,
tableId3);
+ final List<TabletMetadata> table3Metadata = new ArrayList<>();
+ appendFileMetadata(table3Metadata, tableId3,
+ new
StoredTabletFile(StoredTabletFile.serialize("hdfs://other/external/files/shared.rf")),
+ 200);
+ mockTabletsMetadataIter(mockTabletsMetadata3, table3Metadata.iterator());
+
+ EasyMock.replay(client, mockTabletsMetadata1, mockTabletsMetadata2,
mockTabletsMetadata3);
+
+ Map<SortedSet<String>,Long> result =
+ TableDiskUsage.getDiskUsage(tableSet(tableId1, tableId2, tableId3),
client);
+
+ assertEquals(100, result.get(tableNameSet(tableId1, tableId2)));
+ assertEquals(200, result.get(tableNameSet(tableId3)));
+ assertEquals(2, result.size());
+
+ EasyMock.verify(client, mockTabletsMetadata1, mockTabletsMetadata2,
mockTabletsMetadata3);
+ }
+
private static TreeSet<String> tableNameSet(TableId... tableIds) {
return Set.of(tableIds).stream().map(TableDiskUsageTest::getTableName)
.collect(Collectors.toCollection(TreeSet::new));
@@ -289,9 +327,9 @@ public class TableDiskUsageTest {
return tableIdToNameMap.get(tableId);
}
- private static void appendFileMetadata(List<TabletMetadata>
realTabletsMetadata,
+ private static void appendFileMetadata(List<TabletMetadata>
realTabletsMetadata, TableId tableId,
StoredTabletFile file, long size) {
- TabletMetadata tm = TabletMetadata.builder(new
KeyExtent(file.getTableId(), null, null))
+ TabletMetadata tm = TabletMetadata.builder(new KeyExtent(tableId, null,
null))
.putFile(file, new DataFileValue(size, 1)).build();
realTabletsMetadata.add(tm);
}
diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
index 78df80d7fc..c98d2f8b2e 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
@@ -202,8 +202,8 @@ public class GCRun implements GarbageCollectionEnvironment {
refConsumer.accept(ReferenceFile.forDirectory(tableId, tm.getDirName()));
});
- var scanServerRefs = context.getAmple().scanServerRefs().list()
- .map(sfr -> ReferenceFile.forScan(sfr.getTableId(), sfr));
+ Stream<ReferenceFile> scanServerRefs =
+ context.getAmple().scanServerRefs().list().map(sfr ->
ReferenceFile.forScan(sfr));
return Stream.concat(tabletReferences, scanServerRefs);
}
@@ -329,21 +329,7 @@ public class GCRun implements GarbageCollectionEnvironment
{
// this failure, we still want to remove the metadata entry
removeFlag = true;
errors.increment();
- String[] parts =
pathToDel.toString().split(Constants.HDFS_TABLES_DIR)[1].split("/");
- if (parts.length > 2) {
- TableId tableId = TableId.of(parts[1]);
- String tabletDir = parts[2];
- TableState tableState =
context.getTableManager().getTableState(tableId);
- if (tableState != TableState.UNKNOWN && tableState !=
TableState.DELETING) {
- // clone directories don't always exist
- if (!tabletDir.startsWith(Constants.CLONE_PREFIX)) {
- log.debug("{} File doesn't exist: {}", fileActionPrefix,
pathToDel);
- }
- }
- } else {
- log.warn("{} Delete failed due to invalid file path format:
{}", fileActionPrefix,
- delete.getPath());
- }
+ log.debug("{} File doesn't exist: {}", fileActionPrefix,
pathToDel);
}
}
diff --git
a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java
b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java
index 6dfdd1c57b..2a0596c8e5 100644
---
a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java
+++
b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java
@@ -53,8 +53,10 @@ public class GarbageCollectionAlgorithm {
Set<TableId> tableIdsSeen = new HashSet<>(tableIdsBefore.size());
try (Stream<Reference> references = gce.getReferences()) {
references.forEach(ref -> {
- if (ref.isDirectory()) {
- tableIdsSeen.add(ref.getTableId());
+ log.trace("Removing candidates for live reference {}", ref);
+ TableId tid = ref.getTableId();
+ if (tid != null) {
+ tableIdsSeen.add(tid);
}
candidates.remove(ref, candidate -> {
diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GcCandidates.java
b/server/gc/src/main/java/org/apache/accumulo/gc/GcCandidates.java
index 8f9a3d0f2a..a6e8bc2618 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/GcCandidates.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/GcCandidates.java
@@ -129,7 +129,7 @@ public class GcCandidates extends
AbstractCollection<GcCandidate> {
public int removeBlip(String blip) {
var lastThree = lastThree(blip, false, 2, 2);
- String blipPrefix = "/" + lastThree.name;
+ String blipPrefix = "/" + lastThree.name + "/";
bulkDirCandidates.remove(lastThree.name);
diff --git
a/server/gc/src/test/java/org/apache/accumulo/gc/GarbageCollectionTest.java
b/server/gc/src/test/java/org/apache/accumulo/gc/GarbageCollectionTest.java
index 21b8cdaa49..dcf22beced 100644
--- a/server/gc/src/test/java/org/apache/accumulo/gc/GarbageCollectionTest.java
+++ b/server/gc/src/test/java/org/apache/accumulo/gc/GarbageCollectionTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.gc;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -400,7 +401,7 @@ public class GarbageCollectionTest {
}
@Test
- public void testAbsoluteReferencesWithRelativeCandidates() throws Exception {
+ public void testReferencesAndCandidates() throws Exception {
TestGCE gce = new TestGCE();
var candOne =
gce.addCandidate("hdfs://foo.com:6000/accumulo/tables/4/t0/F000.rf");
@@ -444,7 +445,6 @@ public class GarbageCollectionTest {
assertFileDeleted(gce, candThree);
assertNoCandidatesRemoved(gce);
- // add an absolute candidate for file that already has a relative candidate
var candFour =
gce.addCandidate("hdfs://foo.com:6000/accumulo/tables/4/t0/F002.rf");
gca.collect(gce);
assertFileDeleted(gce);
@@ -457,7 +457,6 @@ public class GarbageCollectionTest {
assertFileDeleted(gce, candFour);
assertNoCandidatesRemoved(gce);
- // Finally re-add the relative candidate to remove the last file
candTwo =
gce.addCandidate("hdfs://foo.com:6000/accumulo/tables/4/t0/F002.rf");
gca.collect(gce);
assertFileDeleted(gce, candTwo);
@@ -491,8 +490,7 @@ public class GarbageCollectionTest {
// Remove the first blip
gce.blips.remove("/4/B-0");
- // And we should lose all files in that blip and the blip directory itself
-- relative and
- // absolute
+ // And we should lose all files in that blip and the blip directory itself
gca.collect(gce);
assertFileDeleted(gce,
GcCandidate.forBulkDir("hdfs://foo.com:6000/accumulo/tables/4/B-0"),
GcCandidate.forTabletFile("hdfs://foo.com:6000/accumulo/tables/4/B-0/F002.rf",
0L),
@@ -500,7 +498,6 @@ public class GarbageCollectionTest {
gce.blips.remove("/5/b-1");
- // Same as above, we should lose relative and absolute for a relative or
absolute blip
gca.collect(gce);
assertFileDeleted(gce,
GcCandidate.forBulkDir("hdfs://foo.com:6000/accumulo/tables/5/b-1"),
GcCandidate.forTabletFile("hdfs://foo.com:6000/accumulo/tables/5/b-1/F002.rf",
2L),
@@ -724,12 +721,15 @@ public class GarbageCollectionTest {
gce.addCandidate("//");
gce.addCandidate("///");
gce.addCandidate("////");
+ gce.addCandidate("/1/2/3/4");
gce.addCandidate("/a");
+ gce.addCandidate("hdfs://foo.com:6000/accumulo/tbls/5/F00.rf");
gce.addCandidate("hdfs://foo.com:6000/");
gca.collect(gce);
System.out.println(gce.fileDeletions);
- assertFileDeleted(gce);
+ assertFileDeleted(gce,
+
GcCandidate.forTabletFile("hdfs://foo.com:6000/accumulo/tbls/5/F00.rf", 8L));
}
@Test
@@ -1150,4 +1150,89 @@ public class GarbageCollectionTest {
assertTrue(msg.startsWith("Saw table IDs in ZK that were not in metadata
table: [3]"));
}
+
+ @Test
+ public void externalFilesAreNotMatchedByFullUri() throws Exception {
+ TestGCE gce = new TestGCE();
+
+ var sameNameDifferentLocation =
gce.addCandidate("hdfs://nn1/external/b/shared.rf");
+ var referencedCandidate =
gce.addCandidate("hdfs://nn2/external/b/shared.rf");
+ gce.addFileReference("4", null, referencedCandidate.getPath());
+
+ new GarbageCollectionAlgorithm().collect(gce);
+
+ assertFileDeleted(gce);
+ assertCandidateRemoved(gce, GcCandidateType.INUSE, referencedCandidate);
+ }
+
+ @Test
+ public void externalFileUrisAreNormalizedForMatching() throws Exception {
+ TestGCE gce = new TestGCE();
+
+ var candidate =
gce.addCandidate("hdfs://nn//external///rfiles//source.rf");
+ gce.addFileReference("4", null, "hdfs://nn/external/rfiles/source.rf");
+
+ new GarbageCollectionAlgorithm().collect(gce);
+
+ assertFileDeleted(gce);
+ assertCandidateRemoved(gce, GcCandidateType.INUSE, candidate);
+ }
+
+ @Test
+ public void externalScanReferenceProtectsCandidate() throws Exception {
+ TestGCE gce = new TestGCE();
+ var candidate = gce.addCandidate("hdfs://nn/external/rfiles/source.rf");
+ gce.addScanReference("4", null, candidate.getPath());
+
+ new GarbageCollectionAlgorithm().collect(gce);
+
+ assertFileDeleted(gce);
+ assertNoCandidatesRemoved(gce);
+ }
+
+ @Test
+ public void blipPrefixDoesNotMatchSiblingDirectory() throws Exception {
+ TestGCE gce = new TestGCE();
+ var protectedCandidate =
gce.addCandidate("hdfs://foo:6000/accumulo/tables/4/b-0/F000.rf");
+ var siblingCandidate =
gce.addCandidate("hdfs://foo:6000/accumulo/tables/4/b-01/F001.rf");
+ gce.blips.add("/4/b-0");
+
+ new GarbageCollectionAlgorithm().collect(gce);
+
+ assertFileDeleted(gce, siblingCandidate);
+ assertTrue(gce.candidates.contains(protectedCandidate));
+ }
+
+ @Test
+ public void externalBlipProtectsOnlyDescendants() throws Exception {
+
+ // In this test the file in directory B-01 is deleted, but not the files
+ // in either B-0 directory. The Bulk Load In-Progress marker in
+ // hdfs://nn1/external/B-0 protects the files in hdfs://nn2/external/B-0
+ // because GcCandidates only looks at the last dir and file name in the
+ // path.
+
+ TestGCE gce = new TestGCE();
+ var protectedCandidate =
gce.addCandidate("hdfs://nn1/external/B-0/F000.rf");
+ var siblingCandidate =
gce.addCandidate("hdfs://nn1/external/B-01/F000.rf");
+ var otherVolume = gce.addCandidate("hdfs://nn2/external/B-0/F000.rf");
+ gce.blips.add("hdfs://nn1/external/B-0");
+
+ new GarbageCollectionAlgorithm().collect(gce);
+
+ assertFileDeleted(gce, siblingCandidate);
+ assertNoCandidatesRemoved(gce);
+ assertEquals(Set.of(protectedCandidate, otherVolume), gce.candidates);
+ }
+
+ @Test
+ public void testExternalFileReferenceDoesNotNeedTabletPathLayout() {
+ assertDoesNotThrow(() ->
badRefTest("hdfs://foo.com:6000/accumulo/F00.rf"));
+ }
+
+ @Test
+ public void testExternalFileReferenceCanHaveArbitraryPath() {
+ assertDoesNotThrow(() ->
badRefTest("hdfs://foo.com:6000/accumulo/tbls/5/F00.rf"));
+ }
+
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/BulkImportMove.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/BulkImportMove.java
index dd1d78faac..cdaa8780be 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/BulkImportMove.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/BulkImportMove.java
@@ -93,8 +93,7 @@ class BulkImportMove extends AbstractBulkFateOperation {
*/
private void moveFiles(FateId fateId, Path sourceDir, Path bulkDir, FateEnv
env,
final VolumeManager fs, Map<String,String> renames) throws Exception {
- env.getContext().getAmple().addBulkLoadInProgressFlag(
- "/" + bulkDir.getParent().getName() + "/" + bulkDir.getName(), fateId);
+ env.getContext().getAmple().addBulkLoadInProgressFlag(bulkDir, fateId);
Map<Path,Path> oldToNewMap = new HashMap<>(renames.size(), 1.0f);
for (Map.Entry<String,String> renameEntry : renames.entrySet()) {
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/CleanUpBulkImport.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/CleanUpBulkImport.java
index 56bddcba71..b8c90caeae 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/CleanUpBulkImport.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/CleanUpBulkImport.java
@@ -61,8 +61,7 @@ public class CleanUpBulkImport extends
AbstractBulkFateOperation {
log.debug("{} removing the bulkDir processing flag file in {}", fateId,
bulkInfo.bulkDir);
Ample ample = env.getContext().getAmple();
Path bulkDir = new Path(bulkInfo.bulkDir);
- ample.removeBulkLoadInProgressFlag(
- "/" + bulkDir.getParent().getName() + "/" + bulkDir.getName());
+ ample.removeBulkLoadInProgressFlag(bulkDir);
ample.putGcFileAndDirCandidates(bulkInfo.tableId,
Collections.singleton(GcCandidate.forBulkDir(bulkInfo.bulkDir)));
diff --git
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js
index dd9314a58b..a5ef988461 100644
---
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js
+++
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js
@@ -257,10 +257,10 @@ function timeDuration(time) {
if (Math.round(time) === 0) {
var microsecs = Math.round(time * 1000)
- if(microsecs == 0){
+ if (microsecs == 0) {
return '0μs';
- }else{
- return microsecs+'μs';
+ } else {
+ return microsecs + 'μs';
}
}
diff --git
a/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java
index 28fc3574c7..465726ac6e 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java
@@ -750,8 +750,8 @@ public class ScanServer extends AbstractServer
for (StoredTabletFile file : allFiles.keySet()) {
if (!reservedFiles.containsKey(file)) {
- refs.add(new ScanServerRefTabletFile(serverLockUUID, serverAddress,
- file.getNormalizedPathStr()));
+ refs.add(new ScanServerRefTabletFile(file.getNormalizedPathStr(),
serverAddress,
+ serverLockUUID));
filesToReserve.add(file);
tabletsToCheck.add(Objects.requireNonNull(allFiles.get(file)));
LOG.trace("RFFS {} need to add scan ref for file {}",
myReservationId, file);
diff --git
a/test/src/main/java/org/apache/accumulo/test/ExternalTabletFileIT.java
b/test/src/main/java/org/apache/accumulo/test/ExternalTabletFileIT.java
new file mode 100644
index 0000000000..37484d25e5
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/ExternalTabletFileIT.java
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.time.Duration;
+import java.util.TreeSet;
+
+import org.apache.accumulo.core.client.Accumulo;
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.admin.CompactionConfig;
+import org.apache.accumulo.core.client.rfile.RFile;
+import org.apache.accumulo.core.client.rfile.RFileWriter;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.dataImpl.KeyExtent;
+import org.apache.accumulo.core.gc.GcCandidate;
+import org.apache.accumulo.core.metadata.StoredTabletFile;
+import org.apache.accumulo.core.metadata.schema.Ample;
+import org.apache.accumulo.core.metadata.schema.DataFileValue;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.minicluster.ServerType;
+import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
+import org.apache.accumulo.test.functional.ConfigurableMacBase;
+import org.apache.accumulo.test.util.Wait;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Text;
+import org.junit.jupiter.api.Test;
+
+/** Exercises tablet files stored outside Accumulo's configured table
directories. */
+public class ExternalTabletFileIT extends ConfigurableMacBase {
+
+ private static final Duration GC_WAIT = Duration.ofSeconds(45);
+ private static final long GC_POLL_MS = 100;
+
+ @Override
+ public void configure(MiniAccumuloConfigImpl cfg, Configuration
hadoopCoreSite) {
+ cfg.useMiniDFS(true);
+ cfg.setProperty(Property.GC_CYCLE_START, "1s");
+ cfg.setProperty(Property.GC_CYCLE_DELAY, "1s");
+ super.configure(cfg, hadoopCoreSite);
+ }
+
+ @Override
+ protected Duration defaultTimeout() {
+ return Duration.ofMinutes(3);
+ }
+
+ @Test
+ public void scanAndCompactExternalFile() throws Exception {
+ try (AccumuloClient client =
Accumulo.newClient().from(getClientProperties()).build()) {
+ FileSystem fs = getCluster().getMiniDfs().getFileSystem();
+ String table = getUniqueNames(1)[0];
+ client.tableOperations().create(table);
+
+ Path externalFile = writeRFile(fs, "scan-compact");
+ addFileReference(client, table, externalFile,
fs.getFileStatus(externalFile).getLen(), 2);
+
+ assertRows(client, table);
+
+ client.tableOperations().compact(table, new
CompactionConfig().setWait(true));
+
+ assertRows(client, table);
+ assertEquals(0, countExternalFileReferences(client, table));
+ Wait.waitFor(() -> !fs.exists(externalFile), GC_WAIT.toMillis(),
GC_POLL_MS,
+ "GC did not remove compacted external RFile " + externalFile);
+ }
+ }
+
+ @Test
+ public void splitAndMerge() throws Exception {
+ try (AccumuloClient client =
Accumulo.newClient().from(getClientProperties()).build()) {
+ FileSystem fs = getCluster().getMiniDfs().getFileSystem();
+ String table = getUniqueNames(1)[0];
+ client.tableOperations().create(table);
+
+ Path externalFile = writeRFile(fs, "split-merge");
+ addFileReference(client, table, externalFile,
fs.getFileStatus(externalFile).getLen(), 2);
+
+ assertRows(client, table);
+
+ TreeSet<Text> splits = new TreeSet<>();
+ splits.add(new Text("r1"));
+ client.tableOperations().addSplits(table, splits);
+
+ assertRows(client, table);
+ assertEquals(2, countExternalFileReferences(client, table));
+
+ client.tableOperations().merge(table, new Text(), new Text());
+ assertRows(client, table);
+ // There are still two files because they have non-overlapping
+ // ranges from the split operation
+ assertEquals(2, countExternalFileReferences(client, table));
+
+ }
+ }
+
+ @Test
+ public void deleteGcExternalFileAfterLastReference() throws Exception {
+ try (AccumuloClient client =
Accumulo.newClient().from(getClientProperties()).build()) {
+ FileSystem fs = getCluster().getMiniDfs().getFileSystem();
+ String[] tables = getUniqueNames(2);
+ client.tableOperations().create(tables[0]);
+ client.tableOperations().create(tables[1]);
+
+ Path externalFile = writeRFile(fs, "delete-shared");
+ long fileSize = fs.getFileStatus(externalFile).getLen();
+ addFileReference(client, tables[0], externalFile, fileSize, 2);
+ addFileReference(client, tables[1], externalFile, fileSize, 2);
+ assertRows(client, tables[0]);
+ assertRows(client, tables[1]);
+
+ getCluster().getClusterControl().stop(ServerType.GARBAGE_COLLECTOR);
+ client.tableOperations().delete(tables[0]);
+
+ assertTrue(fs.exists(externalFile), "Deleting one table must preserve
the shared file");
+ assertTrue(hasGcCandidate(externalFile),
+ "Table deletion must enqueue an external-file GC candidate");
+
+ getCluster().getClusterControl().start(ServerType.GARBAGE_COLLECTOR);
+ Wait.waitFor(() -> !hasGcCandidate(externalFile), GC_WAIT.toMillis(),
GC_POLL_MS,
+ "GC did not clear the in-use external-file candidate");
+ assertTrue(fs.exists(externalFile), "GC deleted a file still referenced
by another table");
+ assertRows(client, tables[1]);
+
+ getCluster().getClusterControl().stop(ServerType.GARBAGE_COLLECTOR);
+ client.tableOperations().delete(tables[1]);
+ assertTrue(hasGcCandidate(externalFile),
+ "Deleting the last referencing table must enqueue a GC candidate");
+
+ getCluster().getClusterControl().start(ServerType.GARBAGE_COLLECTOR);
+ Wait.waitFor(() -> !fs.exists(externalFile), GC_WAIT.toMillis(),
GC_POLL_MS,
+ "GC did not delete the external RFile after its last reference was
removed");
+ }
+ }
+
+ private Path writeRFile(FileSystem fs, String name) throws Exception {
+ Path externalFile = fs.makeQualified(new Path("/external-rfiles/" + name +
".rf"));
+ fs.mkdirs(externalFile.getParent());
+ try (RFileWriter writer =
+
RFile.newWriter().to(externalFile.toString()).withFileSystem(fs).build()) {
+ writer.startDefaultLocalityGroup();
+ writer.append(new Key("r1", "cf", "cq"), new Value("v1"));
+ writer.append(new Key("r2", "cf", "cq"), new Value("v2"));
+ }
+ return externalFile;
+ }
+
+ private void addFileReference(AccumuloClient client, String table, Path
file, long size,
+ long entries) throws Exception {
+ client.tableOperations().offline(table, true);
+ TableId tableId =
TableId.of(client.tableOperations().tableIdMap().get(table));
+ getCluster().getServerContext().getAmple().mutateTablet(new
KeyExtent(tableId, null, null))
+ .putFile(StoredTabletFile.of(file), new DataFileValue(size,
entries)).mutate();
+ client.tableOperations().online(table, true);
+ }
+
+ private void assertRows(AccumuloClient client, String table) throws
Exception {
+ try (Scanner scanner = client.createScanner(table, Authorizations.EMPTY)) {
+ int count = 0;
+ for (var entry : scanner) {
+ String row = entry.getKey().getRow().toString();
+ assertEquals("r" + (count + 1), row);
+ assertEquals("v" + (count + 1), entry.getValue().toString());
+ count++;
+ }
+ assertEquals(2, count);
+ }
+ }
+
+ private int countExternalFileReferences(AccumuloClient client, String table)
throws Exception {
+ int count = 0;
+ TableId tableId =
TableId.of(client.tableOperations().tableIdMap().get(table));
+ try (var tablets =
getCluster().getServerContext().getAmple().readTablets().forTable(tableId)
+ .fetch(TabletMetadata.ColumnType.FILES).build()) {
+ for (var tablet : tablets) {
+ for (StoredTabletFile file : tablet.getFilesMap().keySet()) {
+ if (file.getPath().toString().contains("/external-rfiles/")) {
+ count++;
+ }
+ }
+ }
+ }
+ return count;
+ }
+
+ private boolean hasGcCandidate(Path path) {
+ var candidates =
+
getCluster().getServerContext().getAmple().getGcCandidates(Ample.DataLevel.USER);
+ while (candidates.hasNext()) {
+ GcCandidate candidate = candidates.next();
+ if (new Path(candidate.getPath()).equals(path)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git
a/test/src/main/java/org/apache/accumulo/test/ScanServerMetadataEntriesIT.java
b/test/src/main/java/org/apache/accumulo/test/ScanServerMetadataEntriesIT.java
index 4bf1aa54ab..14696bba98 100644
---
a/test/src/main/java/org/apache/accumulo/test/ScanServerMetadataEntriesIT.java
+++
b/test/src/main/java/org/apache/accumulo/test/ScanServerMetadataEntriesIT.java
@@ -43,7 +43,6 @@ import
org.apache.accumulo.core.client.ScannerBase.ConsistencyLevel;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.gc.Reference;
import org.apache.accumulo.core.lock.ServiceLockPaths.AddressSelector;
@@ -212,7 +211,6 @@ public class ScanServerMetadataEntriesIT extends
SharedMiniClusterBase {
final String tableName = getUniqueNames(1)[0];
client.tableOperations().create(tableName);
- TableId tid =
TableId.of(ctx.tableOperations().tableIdMap().get(tableName));
// Make multiple files
final int fileCount = 3;
@@ -250,10 +248,9 @@ public class ScanServerMetadataEntriesIT extends
SharedMiniClusterBase {
refs = references.collect(Collectors.toList());
}
assertTrue(refs.size() > fileCount * 2);
- List<Reference> tableRefs =
- refs.stream().filter(r -> r.getTableId().equals(tid) &&
!r.isDirectory())
- .peek(r ->
assertTrue(metadataScanFileRefs.contains(r.getMetadataPath())))
- .collect(Collectors.toList());
+ List<Reference> tableRefs = refs.stream().filter(r -> !r.isDirectory())
+ .peek(r ->
assertTrue(metadataScanFileRefs.contains(r.getMetadataPath())))
+ .collect(Collectors.toList());
log.info("Reference List:{}", tableRefs);
// There should be 6 references here. 3 for the table file entries, and
3 for the scan
// server references
diff --git
a/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java
b/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java
index 5bec14ad87..b984a0222b 100644
---
a/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java
+++
b/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java
@@ -627,15 +627,14 @@ public class ExternalCompaction_1_IT extends
SharedMiniClusterBase {
@Override
public Overrides override(InputParameters params) {
- // This will validate the paths looks like a tablet file path and throw
an exception if it
- // does not
+ // Validate the output file's URI and the generated RFile name.
var parts = ReferencedTabletFile.of(new Path(params.getOutputFile()));
// For this test should be producing A files
Preconditions.checkArgument(
parts.getFileName().startsWith(FilePrefix.FULL_COMPACTION.getPrefix() + ""));
Preconditions.checkArgument(parts.getFileName().endsWith(RFile.EXTENSION));
- if (parts.getTabletDir()
+ if (parts.getPath().getParent().getName()
.equals(MetadataSchema.TabletsSection.ServerColumnFamily.DEFAULT_TABLET_DIR_NAME))
{
return new
Overrides(Map.of(Property.TABLE_FILE_COMPRESSION_TYPE.getKey(), "gz"));
} else {
diff --git
a/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorTrashBase.java
b/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorTrashBase.java
index 8904dadd67..0cef282d05 100644
---
a/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorTrashBase.java
+++
b/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorTrashBase.java
@@ -28,9 +28,9 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.stream.Collectors;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.data.TableId;
-import org.apache.accumulo.core.metadata.ReferencedTabletFile;
import org.apache.accumulo.core.metadata.StoredTabletFile;
import org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType;
import org.apache.accumulo.core.metadata.schema.TabletsMetadata;
@@ -113,9 +113,9 @@ public class GarbageCollectorTrashBase extends
ConfigurableMacBase {
if (lfs.isDirectory()) {
continue;
}
- ReferencedTabletFile tf = new ReferencedTabletFile(lfs.getPath());
- LOG.debug("File in trash: {}, tableId: {}", lfs.getPath(),
tf.getTableId());
- if (tid.equals(tf.getTableId())) {
+ String tablePath = Constants.HDFS_TABLES_DIR + "/" + tid + "/";
+ LOG.debug("File in trash: {}, looking for table path {}",
lfs.getPath(), tablePath);
+ if (lfs.getPath().toString().contains(tablePath)) {
count++;
}
}
diff --git
a/test/src/main/java/org/apache/accumulo/test/upgrade/ScanServerUpgrade11to12TestIT.java
b/test/src/main/java/org/apache/accumulo/test/upgrade/ScanServerUpgrade11to12TestIT.java
index 345b90da81..2d372456c2 100644
---
a/test/src/main/java/org/apache/accumulo/test/upgrade/ScanServerUpgrade11to12TestIT.java
+++
b/test/src/main/java/org/apache/accumulo/test/upgrade/ScanServerUpgrade11to12TestIT.java
@@ -101,7 +101,7 @@ public class ScanServerUpgrade11to12TestIT extends
SharedMiniClusterBase {
Set<ScanServerRefTabletFile> scanRefs = Stream.of("F0000070.rf",
"F0000071.rf", "F0000072.rf")
.map(f -> "hdfs://localhost:8020/accumulo/tables/2a/default_tablet/" +
f)
- .map(f -> new ScanServerRefTabletFile(serverLockUUID,
server.toString(), f))
+ .map(f -> new ScanServerRefTabletFile(f, server.toString(),
serverLockUUID))
.collect(Collectors.toSet());
ServerContext ctx = getCluster().getServerContext();