This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.1 by this push:
     new 684810b0a0 Updated TABLE_COMPACTION_INPUT_DROP_CACHE_BEHIND options 
(#5485)
684810b0a0 is described below

commit 684810b0a020d348b6ebfbe4a236023d9f69b00e
Author: Dave Marion <dlmar...@apache.org>
AuthorDate: Thu Apr 17 14:20:49 2025 -0400

    Updated TABLE_COMPACTION_INPUT_DROP_CACHE_BEHIND options (#5485)
    
    This is a follow-on to #5473 that changes the property options
    to named values instead of using the internal file prefixes.
    This commit also renames FileTypePrefix to FilePrefix to
    match the main branch and make it possible to parse the
    property to an EnumSet using the ConfigurationTypeHelper.
    
    
    
    Co-authored-by: Christopher Tubbs <ctubb...@apache.org>
---
 .../core/conf/ConfigurationTypeHelper.java         |  25 +++++
 .../org/apache/accumulo/core/conf/Property.java    |  17 +--
 .../apache/accumulo/core/conf/PropertyType.java    |   3 +
 .../org/apache/accumulo/core/file/FilePrefix.java  |  96 +++++++++++++++++
 .../core/conf/ConfigurationTypeHelperTest.java     |  17 +++
 .../accumulo/core/conf/PropertyTypeTest.java       |   6 ++
 .../apache/accumulo/core/file/FilePrefixTest.java  |  78 ++++++++++++++
 .../accumulo/server/compaction/FileCompactor.java  |  22 ++--
 .../apache/accumulo/server/fs/FileTypePrefix.java  | 114 ---------------------
 .../accumulo/server/fs/FileTypePrefixTest.java     |  95 -----------------
 .../manager/tableOps/bulkVer2/PrepBulkImport.java  |   4 +-
 .../tableOps/tableImport/MapImportFileNames.java   |   4 +-
 .../tserver/tablet/MinorCompactionTask.java        |   4 +-
 .../org/apache/accumulo/tserver/tablet/Tablet.java |   7 +-
 14 files changed, 255 insertions(+), 237 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationTypeHelper.java 
b/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationTypeHelper.java
index 19f464fb19..cd286c1cd7 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationTypeHelper.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationTypeHelper.java
@@ -26,11 +26,13 @@ import static java.util.concurrent.TimeUnit.SECONDS;
 
 import java.io.IOException;
 import java.util.Collections;
+import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.accumulo.core.classloader.ClassLoaderUtil;
+import org.apache.accumulo.core.file.FilePrefix;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -223,4 +225,27 @@ public class ConfigurationTypeHelper {
     }
     return nThreads;
   }
+
+  /**
+   * Convert the value of the TABLE_COMPACTION_INPUT_DROP_CACHE_BEHIND 
property to a set of
+   * FilePrefix.
+   */
+  public static EnumSet<FilePrefix> getDropCacheBehindFilePrefixes(String 
propertyValue) {
+    final EnumSet<FilePrefix> filePrefixes;
+    if (propertyValue.equalsIgnoreCase("ALL")) {
+      filePrefixes = EnumSet.allOf(FilePrefix.class);
+    } else if (propertyValue.equalsIgnoreCase("NON-IMPORT")) {
+      filePrefixes = EnumSet.of(FilePrefix.FLUSH, FilePrefix.FULL_COMPACTION, 
FilePrefix.COMPACTION,
+          FilePrefix.MERGING_MINOR_COMPACTION);
+    } else if (propertyValue.equalsIgnoreCase("NONE")) {
+      filePrefixes = EnumSet.noneOf(FilePrefix.class);
+    } else {
+      // This should not happen, PropertyType.DROP_CACHE_SELECTION should
+      // catch an invalid property value before anything can call this code.
+      throw new IllegalArgumentException(
+          "Invalid value for property " + 
Property.TABLE_COMPACTION_INPUT_DROP_CACHE_BEHIND.getKey()
+              + " expected one of ALL, NONE, or NON-IMPORT");
+    }
+    return filePrefixes;
+  }
 }
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/Property.java 
b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
index eedd4c9970..97cc0319ec 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/Property.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
@@ -1063,13 +1063,16 @@ public enum Property {
       "1.3.5"),
   TABLE_ARBITRARY_PROP_PREFIX("table.custom.", null, PropertyType.PREFIX,
       "Prefix to be used for user defined arbitrary properties.", "1.7.0"),
-  
TABLE_COMPACTION_INPUT_DROP_CACHE_BEHIND("table.compaction.input.drop.cache", 
"*",
-      PropertyType.STRING,
-      "Sets FSDataInputStream.setDropBehind(true) is set on compaction"
-          + " input streams for the specified type of files. The value of this 
property is a comma-separated list of Accumulo"
-          + " file type prefixes ('A', 'C', 'F', 'I', and 'M'). The value '*' 
can be used to"
-          + " specify all file types (default). When the input file prefix 
matches a value in this list,"
-          + " then setDropBehind will not be set on the FSDataInputStream.",
+  
TABLE_COMPACTION_INPUT_DROP_CACHE_BEHIND("table.compaction.input.drop.cache", 
"ALL",
+      PropertyType.DROP_CACHE_SELECTION,
+      "FSDataInputStream.setDropBehind(true) is set on compaction input 
streams"
+          + " for the specified type of files. This tells the DataNode to 
advise the OS"
+          + " that it does not need to keep blocks for the associated file in 
the page cache."
+          + " 'ALL', the default, will call setDropBehind on all file types. 
'NONE' will call"
+          + " setDropBehind on none of the files, which can be useful when a 
table is cloned."
+          + " 'NON-IMPORT' will call setDropBehind on all file types except 
those that are"
+          + " bulk imported, which is useful when bulk import files are mapped 
to many tablets"
+          + " and will be compacted at different times.",
       "2.1.4"),
   TABLE_MINC_OUTPUT_DROP_CACHE("table.compaction.minor.output.drop.cache", 
"false",
       PropertyType.BOOLEAN,
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java 
b/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java
index a0c7f55c25..9286381782 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java
@@ -112,6 +112,9 @@ public enum PropertyType {
           + "Substitutions of the ACCUMULO_HOME environment variable can be 
done in the system "
           + "config file using '${env:ACCUMULO_HOME}' or similar."),
 
+  DROP_CACHE_SELECTION("drop cache option", in(false, "NONE", "ALL", 
"NON-IMPORT"),
+      "One of 'ALL', 'NONE', or 'NON-IMPORT'"),
+
   // VFS_CLASSLOADER_CACHE_DIR's default value is a special case, for 
documentation purposes
   @SuppressWarnings("removal")
   ABSOLUTEPATH("absolute path",
diff --git a/core/src/main/java/org/apache/accumulo/core/file/FilePrefix.java 
b/core/src/main/java/org/apache/accumulo/core/file/FilePrefix.java
new file mode 100644
index 0000000000..e29047b4f7
--- /dev/null
+++ b/core/src/main/java/org/apache/accumulo/core/file/FilePrefix.java
@@ -0,0 +1,96 @@
+/*
+ * 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.core.file;
+
+import java.util.Objects;
+
+import com.google.common.base.Preconditions;
+
+public enum FilePrefix {
+
+  /**
+   * The prefix used when an RFile is first written from memory as the result 
of a minor compaction
+   * (a.k.a. 'flush')
+   */
+  FLUSH('F'),
+
+  /**
+   * The prefix for imported files as the result of a bulk import
+   */
+  BULK_IMPORT('I'),
+
+  /**
+   * The prefix used for files created as the result of a routine major 
compaction
+   */
+  COMPACTION('C'),
+
+  /**
+   * The prefix used for files created as the result of a major compaction 
that included all files
+   * for a tablet
+   */
+  FULL_COMPACTION('A'),
+
+  /**
+   * The prefix used for files created as the result of a merging minor 
compaction (a removed
+   * feature, but files may still be present with the name)
+   */
+  MERGING_MINOR_COMPACTION('M');
+
+  private final char filePrefix;
+
+  private FilePrefix(char prefix) {
+    this.filePrefix = prefix;
+  }
+
+  public char getPrefix() {
+    return filePrefix;
+  }
+
+  public String createFileName(String fileSuffix) {
+    Objects.requireNonNull(fileSuffix, "fileSuffix must be supplied");
+    Preconditions.checkArgument(!fileSuffix.isBlank(), "Empty fileSuffix 
supplied");
+    if (this == MERGING_MINOR_COMPACTION) {
+      throw new IllegalStateException(
+          "Unable to create filename for MERGING_MINOR_COMPACTION file type");
+    }
+    return filePrefix + fileSuffix;
+  }
+
+  public static FilePrefix fromPrefix(char prefix) {
+    for (FilePrefix fp : values()) {
+      if (fp.filePrefix == prefix) {
+        return fp;
+      }
+    }
+    throw new IllegalArgumentException("Unknown prefix type: " + prefix);
+
+  }
+
+  public static FilePrefix fromFileName(String fileName) {
+    Objects.requireNonNull(fileName, "file name must be supplied");
+    Preconditions.checkArgument(!fileName.isBlank(), "Empty filename 
supplied");
+    char firstChar = fileName.charAt(0);
+    if (!Character.isUpperCase(firstChar)) {
+      throw new IllegalArgumentException(
+          "Expected first character of file name to be upper case, name: " + 
fileName);
+    }
+    return fromPrefix(firstChar);
+  }
+
+}
diff --git 
a/core/src/test/java/org/apache/accumulo/core/conf/ConfigurationTypeHelperTest.java
 
b/core/src/test/java/org/apache/accumulo/core/conf/ConfigurationTypeHelperTest.java
index 627f21c450..66fdd51c6b 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/conf/ConfigurationTypeHelperTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/conf/ConfigurationTypeHelperTest.java
@@ -25,9 +25,11 @@ import static java.util.concurrent.TimeUnit.SECONDS;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
+import java.util.EnumSet;
 import java.util.function.Function;
 import java.util.stream.Stream;
 
+import org.apache.accumulo.core.file.FilePrefix;
 import org.junit.jupiter.api.Test;
 
 public class ConfigurationTypeHelperTest {
@@ -132,4 +134,19 @@ public class ConfigurationTypeHelperTest {
   public void testGetFractionFailureCase3() {
     assertThrows(IllegalArgumentException.class, () -> 
ConfigurationTypeHelper.getFraction(".%"));
   }
+
+  @Test
+  public void testGetDropCacheBehindFilePrefixes() {
+    assertEquals(EnumSet.noneOf(FilePrefix.class),
+        ConfigurationTypeHelper.getDropCacheBehindFilePrefixes("NONE"));
+    assertEquals(EnumSet.allOf(FilePrefix.class),
+        ConfigurationTypeHelper.getDropCacheBehindFilePrefixes("ALL"));
+    assertEquals(
+        EnumSet.of(FilePrefix.FLUSH, FilePrefix.FULL_COMPACTION, 
FilePrefix.COMPACTION,
+            FilePrefix.MERGING_MINOR_COMPACTION),
+        ConfigurationTypeHelper.getDropCacheBehindFilePrefixes("NON-IMPORT"));
+    assertThrows(IllegalArgumentException.class,
+        () -> ConfigurationTypeHelper.getDropCacheBehindFilePrefixes("A"));
+
+  }
 }
diff --git 
a/core/src/test/java/org/apache/accumulo/core/conf/PropertyTypeTest.java 
b/core/src/test/java/org/apache/accumulo/core/conf/PropertyTypeTest.java
index 315543ade9..af2fa3ab1b 100644
--- a/core/src/test/java/org/apache/accumulo/core/conf/PropertyTypeTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/conf/PropertyTypeTest.java
@@ -225,4 +225,10 @@ public class PropertyTypeTest extends WithTestNames {
     invalid(null, "RF", "map", "", "MAP", "rF", "Rf", " rf ");
   }
 
+  @Test
+  public void testTypeDROP_CACHE_SELECTION() {
+    valid("all", "ALL", "NON-import", "NON-IMPORT", "non-import", "none", 
"NONE", "nOnE");
+    invalid(null, "", "AL L", " ALL", "non import", "     ");
+  }
+
 }
diff --git 
a/core/src/test/java/org/apache/accumulo/core/file/FilePrefixTest.java 
b/core/src/test/java/org/apache/accumulo/core/file/FilePrefixTest.java
new file mode 100644
index 0000000000..5e2c4ec8b8
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/file/FilePrefixTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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.core.file;
+
+import static org.apache.accumulo.core.file.FilePrefix.BULK_IMPORT;
+import static org.apache.accumulo.core.file.FilePrefix.COMPACTION;
+import static org.apache.accumulo.core.file.FilePrefix.FLUSH;
+import static org.apache.accumulo.core.file.FilePrefix.FULL_COMPACTION;
+import static 
org.apache.accumulo.core.file.FilePrefix.MERGING_MINOR_COMPACTION;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
+
+public class FilePrefixTest {
+
+  @Test
+  public void testCreateFileName() {
+    assertThrows(NullPointerException.class, () -> FLUSH.createFileName(null));
+    assertThrows(IllegalArgumentException.class, () -> 
FLUSH.createFileName(""));
+    assertThrows(IllegalStateException.class,
+        () -> MERGING_MINOR_COMPACTION.createFileName("file.rf"));
+    assertEquals("Afile.rf", FULL_COMPACTION.createFileName("file.rf"));
+    assertEquals("Cfile.rf", COMPACTION.createFileName("file.rf"));
+    assertEquals("Ffile.rf", FLUSH.createFileName("file.rf"));
+    assertEquals("Ifile.rf", BULK_IMPORT.createFileName("file.rf"));
+  }
+
+  @Test
+  public void testFromPrefix() {
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromPrefix('*'));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromPrefix('c'));
+    assertEquals(COMPACTION, FilePrefix.fromPrefix('C'));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromPrefix('a'));
+    assertEquals(FULL_COMPACTION, FilePrefix.fromPrefix('A'));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromPrefix('f'));
+    assertEquals(FLUSH, FilePrefix.fromPrefix('F'));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromPrefix('i'));
+    assertEquals(BULK_IMPORT, FilePrefix.fromPrefix('I'));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromPrefix('m'));
+    assertEquals(MERGING_MINOR_COMPACTION, FilePrefix.fromPrefix('M'));
+  }
+
+  @Test
+  public void fromFileName() {
+    assertThrows(NullPointerException.class, () -> 
FilePrefix.fromFileName(null));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromFileName(""));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromFileName("*file.rf"));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromFileName("cfile.rf"));
+    assertEquals(COMPACTION, FilePrefix.fromFileName("Cfile.rf"));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromFileName("afile.rf"));
+    assertEquals(FULL_COMPACTION, FilePrefix.fromFileName("Afile.rf"));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromFileName("ffile.rf"));
+    assertEquals(FLUSH, FilePrefix.fromFileName("Ffile.rf"));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromFileName("ifile.rf"));
+    assertEquals(BULK_IMPORT, FilePrefix.fromFileName("Ifile.rf"));
+    assertThrows(IllegalArgumentException.class, () -> 
FilePrefix.fromFileName("mfile.rf"));
+    assertEquals(MERGING_MINOR_COMPACTION, 
FilePrefix.fromFileName("Mfile.rf"));
+
+  }
+
+}
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/compaction/FileCompactor.java
 
b/server/base/src/main/java/org/apache/accumulo/server/compaction/FileCompactor.java
index b09050c1fb..1f655dd304 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/compaction/FileCompactor.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/compaction/FileCompactor.java
@@ -39,6 +39,7 @@ import java.util.concurrent.atomic.LongAdder;
 
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.ConfigurationTypeHelper;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.ByteSequence;
 import org.apache.accumulo.core.data.Key;
@@ -48,6 +49,7 @@ import org.apache.accumulo.core.dataImpl.KeyExtent;
 import org.apache.accumulo.core.file.FileOperations;
 import org.apache.accumulo.core.file.FileOperations.ReaderBuilder;
 import org.apache.accumulo.core.file.FileOperations.WriterBuilder;
+import org.apache.accumulo.core.file.FilePrefix;
 import org.apache.accumulo.core.file.FileSKVIterator;
 import org.apache.accumulo.core.file.FileSKVWriter;
 import org.apache.accumulo.core.iterators.IteratorUtil;
@@ -71,7 +73,6 @@ import org.apache.accumulo.core.util.LocalityGroupUtil;
 import 
org.apache.accumulo.core.util.LocalityGroupUtil.LocalityGroupConfigurationError;
 import org.apache.accumulo.core.util.ratelimit.RateLimiter;
 import org.apache.accumulo.server.ServerContext;
-import org.apache.accumulo.server.fs.FileTypePrefix;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.iterators.SystemIteratorEnvironment;
 import org.apache.accumulo.server.problems.ProblemReport;
@@ -346,10 +347,10 @@ public class FileCompactor implements 
Callable<CompactionStats> {
       // have compacted, or in the case of cloned tables where one
       // of the tables has compacted the input file but the other
       // has not.
-      String dropCachePrefixProperty =
+      final String dropCachePrefixProperty =
           acuTableConf.get(Property.TABLE_COMPACTION_INPUT_DROP_CACHE_BEHIND);
-      final EnumSet<FileTypePrefix> dropCacheFilePrefixes =
-          FileTypePrefix.typesFromList(dropCachePrefixProperty);
+      final EnumSet<FilePrefix> dropCacheFileTypes =
+          
ConfigurationTypeHelper.getDropCacheBehindFilePrefixes(dropCachePrefixProperty);
 
       final boolean isMinC = env.getIteratorScope() == 
IteratorUtil.IteratorScope.minc;
 
@@ -376,13 +377,13 @@ public class FileCompactor implements 
Callable<CompactionStats> {
         for (Entry<String,Set<ByteSequence>> entry : lGroups.entrySet()) {
           setLocalityGroup(entry.getKey());
           compactLocalityGroup(entry.getKey(), entry.getValue(), true, mfw, 
majCStats,
-              dropCacheFilePrefixes);
+              dropCacheFileTypes);
           allColumnFamilies.addAll(entry.getValue());
         }
       }
 
       setLocalityGroup("");
-      compactLocalityGroup(null, allColumnFamilies, false, mfw, majCStats, 
dropCacheFilePrefixes);
+      compactLocalityGroup(null, allColumnFamilies, false, mfw, majCStats, 
dropCacheFileTypes);
 
       long t2 = System.currentTimeMillis();
 
@@ -467,7 +468,7 @@ public class FileCompactor implements 
Callable<CompactionStats> {
   }
 
   private List<SortedKeyValueIterator<Key,Value>> openMapDataFiles(
-      ArrayList<FileSKVIterator> readers, EnumSet<FileTypePrefix> 
dropCacheFilePrefixes)
+      ArrayList<FileSKVIterator> readers, EnumSet<FilePrefix> 
dropCacheFilePrefixes)
       throws IOException {
 
     List<SortedKeyValueIterator<Key,Value>> iters = new 
ArrayList<>(filesToCompact.size());
@@ -480,10 +481,10 @@ public class FileCompactor implements 
Callable<CompactionStats> {
         FileSKVIterator reader;
 
         boolean dropCacheBehindCompactionInputFile = false;
-        if (dropCacheFilePrefixes.contains(FileTypePrefix.ALL)) {
+        if 
(dropCacheFilePrefixes.containsAll(EnumSet.allOf(FilePrefix.class))) {
           dropCacheBehindCompactionInputFile = true;
         } else {
-          FileTypePrefix type = 
FileTypePrefix.fromFileName(mapFile.getFileName());
+          FilePrefix type = FilePrefix.fromFileName(mapFile.getFileName());
           if (dropCacheFilePrefixes.contains(type)) {
             dropCacheBehindCompactionInputFile = true;
           }
@@ -538,8 +539,7 @@ public class FileCompactor implements 
Callable<CompactionStats> {
 
   private void compactLocalityGroup(String lgName, Set<ByteSequence> 
columnFamilies,
       boolean inclusive, FileSKVWriter mfw, CompactionStats majCStats,
-      EnumSet<FileTypePrefix> dropCacheFilePrefixes)
-      throws IOException, CompactionCanceledException {
+      EnumSet<FilePrefix> dropCacheFilePrefixes) throws IOException, 
CompactionCanceledException {
     ArrayList<FileSKVIterator> readers = new 
ArrayList<>(filesToCompact.size());
     Span compactSpan = TraceUtil.startSpan(this.getClass(), "compact");
     try (Scope span = compactSpan.makeCurrent()) {
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/fs/FileTypePrefix.java 
b/server/base/src/main/java/org/apache/accumulo/server/fs/FileTypePrefix.java
deleted file mode 100644
index 1d81796367..0000000000
--- 
a/server/base/src/main/java/org/apache/accumulo/server/fs/FileTypePrefix.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.server.fs;
-
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-public enum FileTypePrefix {
-
-  ALL("*"),
-  FLUSH("F"),
-  BULK_IMPORT("I"),
-  COMPACTION("C"),
-  FULL_COMPACTION("A"),
-  MERGING_MINOR_COMPACTION("M"),
-  UNKNOWN("?");
-
-  private static final Logger LOG = 
LoggerFactory.getLogger(FileTypePrefix.class);
-
-  private final String filePrefix;
-
-  private FileTypePrefix(String prefix) {
-    this.filePrefix = prefix;
-  }
-
-  public String getPrefix() {
-    return filePrefix;
-  }
-
-  public String createFileName(String fileName) {
-    Objects.requireNonNull(fileName, "filename must be supplied");
-    Preconditions.checkArgument(!fileName.isBlank(), "Empty filename 
supplied");
-    if (this == ALL || this == MERGING_MINOR_COMPACTION || this == UNKNOWN) {
-      throw new IllegalStateException(
-          "Unable to create filename with ALL, MERGING_MINOR_COMPACTION, or 
UNKNOWN prefix");
-    }
-    return filePrefix + fileName;
-  }
-
-  public static FileTypePrefix fromPrefix(String prefix) {
-    Objects.requireNonNull(prefix, "prefix must be supplied");
-    Preconditions.checkArgument(!prefix.isBlank(), "Empty prefix supplied");
-    Preconditions.checkArgument(prefix.length() == 1, "Invalid prefix 
supplied: " + prefix);
-    switch (prefix.toUpperCase()) {
-      case "A":
-        return FULL_COMPACTION;
-      case "C":
-        return COMPACTION;
-      case "F":
-        return FLUSH;
-      case "I":
-        return BULK_IMPORT;
-      case "M":
-        return MERGING_MINOR_COMPACTION;
-      default:
-        LOG.warn("Encountered unknown file prefix for file: {}", prefix);
-        return UNKNOWN;
-    }
-  }
-
-  public static FileTypePrefix fromFileName(String fileName) {
-    Objects.requireNonNull(fileName, "file name must be supplied");
-    Preconditions.checkArgument(!fileName.isBlank(), "Empty filename 
supplied");
-    String firstChar = fileName.substring(0, 1);
-    if (!firstChar.equals(firstChar.toUpperCase())) {
-      throw new IllegalArgumentException(
-          "Expected first character of file name to be upper case, name: " + 
fileName);
-    }
-    return fromPrefix(firstChar);
-  }
-
-  public static EnumSet<FileTypePrefix> typesFromList(String list) {
-    final EnumSet<FileTypePrefix> dropCacheFilePrefixes;
-    if (!list.isBlank()) {
-      if (list.contains("*")) {
-        dropCacheFilePrefixes = EnumSet.of(FileTypePrefix.ALL);
-      } else {
-        Set<FileTypePrefix> set = new HashSet<>();
-        String[] prefixes = list.trim().split(",");
-        for (String p : prefixes) {
-          set.add(FileTypePrefix.fromPrefix(p.trim().toUpperCase()));
-        }
-        dropCacheFilePrefixes = EnumSet.copyOf(set);
-      }
-    } else {
-      dropCacheFilePrefixes = EnumSet.noneOf(FileTypePrefix.class);
-    }
-    return dropCacheFilePrefixes;
-  }
-
-}
diff --git 
a/server/base/src/test/java/org/apache/accumulo/server/fs/FileTypePrefixTest.java
 
b/server/base/src/test/java/org/apache/accumulo/server/fs/FileTypePrefixTest.java
deleted file mode 100644
index 7085e63777..0000000000
--- 
a/server/base/src/test/java/org/apache/accumulo/server/fs/FileTypePrefixTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.server.fs;
-
-import static org.apache.accumulo.server.fs.FileTypePrefix.ALL;
-import static org.apache.accumulo.server.fs.FileTypePrefix.BULK_IMPORT;
-import static org.apache.accumulo.server.fs.FileTypePrefix.COMPACTION;
-import static org.apache.accumulo.server.fs.FileTypePrefix.FLUSH;
-import static org.apache.accumulo.server.fs.FileTypePrefix.FULL_COMPACTION;
-import static 
org.apache.accumulo.server.fs.FileTypePrefix.MERGING_MINOR_COMPACTION;
-import static org.apache.accumulo.server.fs.FileTypePrefix.UNKNOWN;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-import java.util.EnumSet;
-
-import org.junit.jupiter.api.Test;
-
-public class FileTypePrefixTest {
-
-  @Test
-  public void testCreateFileName() {
-    assertThrows(NullPointerException.class, () -> FLUSH.createFileName(null));
-    assertThrows(IllegalArgumentException.class, () -> 
FLUSH.createFileName(""));
-    assertThrows(IllegalStateException.class, () -> 
ALL.createFileName("file.rf"));
-    assertThrows(IllegalStateException.class, () -> 
UNKNOWN.createFileName("file.rf"));
-    assertThrows(IllegalStateException.class,
-        () -> MERGING_MINOR_COMPACTION.createFileName("file.rf"));
-    assertEquals("Afile.rf", FULL_COMPACTION.createFileName("file.rf"));
-    assertEquals("Cfile.rf", COMPACTION.createFileName("file.rf"));
-    assertEquals("Ffile.rf", FLUSH.createFileName("file.rf"));
-    assertEquals("Ifile.rf", BULK_IMPORT.createFileName("file.rf"));
-  }
-
-  @Test
-  public void testFromPrefix() {
-    assertThrows(NullPointerException.class, () -> 
FileTypePrefix.fromPrefix(null));
-    assertThrows(IllegalArgumentException.class, () -> 
FileTypePrefix.fromPrefix(""));
-    assertThrows(IllegalArgumentException.class, () -> 
FileTypePrefix.fromPrefix("AB"));
-    assertEquals(UNKNOWN, FileTypePrefix.fromPrefix("*"));
-    assertEquals(COMPACTION, FileTypePrefix.fromPrefix("c"));
-    assertEquals(COMPACTION, FileTypePrefix.fromPrefix("C"));
-    assertEquals(FULL_COMPACTION, FileTypePrefix.fromPrefix("a"));
-    assertEquals(FULL_COMPACTION, FileTypePrefix.fromPrefix("A"));
-    assertEquals(FLUSH, FileTypePrefix.fromPrefix("f"));
-    assertEquals(FLUSH, FileTypePrefix.fromPrefix("F"));
-    assertEquals(BULK_IMPORT, FileTypePrefix.fromPrefix("i"));
-    assertEquals(BULK_IMPORT, FileTypePrefix.fromPrefix("I"));
-    assertEquals(MERGING_MINOR_COMPACTION, FileTypePrefix.fromPrefix("m"));
-    assertEquals(MERGING_MINOR_COMPACTION, FileTypePrefix.fromPrefix("M"));
-  }
-
-  @Test
-  public void fromFileName() {
-    assertThrows(NullPointerException.class, () -> 
FileTypePrefix.fromFileName(null));
-    assertThrows(IllegalArgumentException.class, () -> 
FileTypePrefix.fromFileName(""));
-    assertEquals(UNKNOWN, FileTypePrefix.fromFileName("*file.rf"));
-    assertThrows(IllegalArgumentException.class, () -> 
FileTypePrefix.fromFileName("cfile.rf"));
-    assertEquals(COMPACTION, FileTypePrefix.fromFileName("Cfile.rf"));
-    assertThrows(IllegalArgumentException.class, () -> 
FileTypePrefix.fromFileName("afile.rf"));
-    assertEquals(FULL_COMPACTION, FileTypePrefix.fromFileName("Afile.rf"));
-    assertThrows(IllegalArgumentException.class, () -> 
FileTypePrefix.fromFileName("ffile.rf"));
-    assertEquals(FLUSH, FileTypePrefix.fromFileName("Ffile.rf"));
-    assertThrows(IllegalArgumentException.class, () -> 
FileTypePrefix.fromFileName("ifile.rf"));
-    assertEquals(BULK_IMPORT, FileTypePrefix.fromFileName("Ifile.rf"));
-    assertThrows(IllegalArgumentException.class, () -> 
FileTypePrefix.fromFileName("mfile.rf"));
-    assertEquals(MERGING_MINOR_COMPACTION, 
FileTypePrefix.fromFileName("Mfile.rf"));
-
-  }
-
-  @Test
-  public void testFromList() {
-    assertEquals(EnumSet.noneOf(FileTypePrefix.class), 
FileTypePrefix.typesFromList(""));
-    assertEquals(EnumSet.of(ALL), FileTypePrefix.typesFromList("*"));
-    assertEquals(EnumSet.of(ALL), FileTypePrefix.typesFromList("*, A"));
-    assertEquals(EnumSet.of(COMPACTION, FULL_COMPACTION), 
FileTypePrefix.typesFromList("C, A"));
-  }
-
-}
diff --git 
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/PrepBulkImport.java
 
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/PrepBulkImport.java
index 3fa2c58758..e6371628cc 100644
--- 
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/PrepBulkImport.java
+++ 
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/PrepBulkImport.java
@@ -44,6 +44,7 @@ import org.apache.accumulo.core.data.TableId;
 import org.apache.accumulo.core.dataImpl.KeyExtent;
 import org.apache.accumulo.core.fate.FateTxId;
 import org.apache.accumulo.core.fate.Repo;
+import org.apache.accumulo.core.file.FilePrefix;
 import org.apache.accumulo.core.metadata.schema.TabletMetadata;
 import org.apache.accumulo.core.metadata.schema.TabletsMetadata;
 import org.apache.accumulo.core.util.PeekingIterator;
@@ -51,7 +52,6 @@ import org.apache.accumulo.manager.Manager;
 import org.apache.accumulo.manager.tableOps.ManagerRepo;
 import org.apache.accumulo.manager.tableOps.Utils;
 import org.apache.accumulo.server.ServerContext;
-import org.apache.accumulo.server.fs.FileTypePrefix;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.tablets.UniqueNameAllocator;
 import org.apache.accumulo.server.zookeeper.TransactionWatcher;
@@ -279,7 +279,7 @@ public class PrepBulkImport extends ManagerRepo {
 
     for (FileStatus file : files) {
       // since these are only valid files we know it has an extension
-      String newName = FileTypePrefix.BULK_IMPORT.createFileName(
+      String newName = FilePrefix.BULK_IMPORT.createFileName(
           namer.getNextName() + "." + 
FilenameUtils.getExtension(file.getPath().getName()));
       oldToNewNameMap.put(file.getPath().getName(), new Path(bulkDir, 
newName).getName());
     }
diff --git 
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/MapImportFileNames.java
 
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/MapImportFileNames.java
index 7032b578c7..ee36ee6588 100644
--- 
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/MapImportFileNames.java
+++ 
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/MapImportFileNames.java
@@ -31,9 +31,9 @@ import 
org.apache.accumulo.core.clientImpl.thrift.TableOperation;
 import org.apache.accumulo.core.clientImpl.thrift.TableOperationExceptionType;
 import org.apache.accumulo.core.fate.Repo;
 import org.apache.accumulo.core.file.FileOperations;
+import org.apache.accumulo.core.file.FilePrefix;
 import org.apache.accumulo.manager.Manager;
 import org.apache.accumulo.manager.tableOps.ManagerRepo;
-import org.apache.accumulo.server.fs.FileTypePrefix;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.tablets.UniqueNameAllocator;
 import org.apache.hadoop.fs.FileStatus;
@@ -88,7 +88,7 @@ class MapImportFileNames extends ManagerRepo {
           }
 
           String newName =
-              FileTypePrefix.BULK_IMPORT.createFileName(namer.getNextName() + 
"." + extension);
+              FilePrefix.BULK_IMPORT.createFileName(namer.getNextName() + "." 
+ extension);
 
           mappingsWriter.append(fileName);
           mappingsWriter.append(':');
diff --git 
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/MinorCompactionTask.java
 
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/MinorCompactionTask.java
index addc0b93d7..db1633f17b 100644
--- 
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/MinorCompactionTask.java
+++ 
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/MinorCompactionTask.java
@@ -18,10 +18,10 @@
  */
 package org.apache.accumulo.tserver.tablet;
 
+import org.apache.accumulo.core.file.FilePrefix;
 import org.apache.accumulo.core.metadata.TabletFile;
 import org.apache.accumulo.core.metadata.schema.DataFileValue;
 import org.apache.accumulo.core.trace.TraceUtil;
-import org.apache.accumulo.server.fs.FileTypePrefix;
 import org.apache.accumulo.tserver.MinorCompactionReason;
 import org.apache.hadoop.fs.Path;
 import org.slf4j.Logger;
@@ -75,7 +75,7 @@ class MinorCompactionTask implements Runnable {
           while (true) {
             try {
               if (newFile == null) {
-                newFile = tablet.getNextMapFilename(FileTypePrefix.FLUSH);
+                newFile = tablet.getNextMapFilename(FilePrefix.FLUSH);
                 tmpFile = new TabletFile(new Path(newFile.getPathStr() + 
"_tmp"));
               }
               /*
diff --git 
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java 
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index dd599b7dcf..246622d277 100644
--- 
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++ 
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -67,6 +67,7 @@ import org.apache.accumulo.core.dataImpl.KeyExtent;
 import org.apache.accumulo.core.dataImpl.thrift.MapFileInfo;
 import org.apache.accumulo.core.fate.zookeeper.ServiceLock;
 import org.apache.accumulo.core.file.FileOperations;
+import org.apache.accumulo.core.file.FilePrefix;
 import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
 import org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator;
 import org.apache.accumulo.core.logging.ConditionalLogger.DeduplicatingLogger;
@@ -97,7 +98,6 @@ import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.core.volume.Volume;
 import org.apache.accumulo.server.ServerContext;
 import org.apache.accumulo.server.compaction.CompactionStats;
-import org.apache.accumulo.server.fs.FileTypePrefix;
 import org.apache.accumulo.server.fs.VolumeChooserEnvironmentImpl;
 import org.apache.accumulo.server.fs.VolumeUtil;
 import org.apache.accumulo.server.fs.VolumeUtil.TabletFiles;
@@ -265,15 +265,14 @@ public class Tablet extends TabletBase {
     return dirUri;
   }
 
-  TabletFile getNextMapFilename(FileTypePrefix prefix) throws IOException {
+  TabletFile getNextMapFilename(FilePrefix prefix) throws IOException {
     String extension = FileOperations.getNewFileExtension(tableConfiguration);
     return new TabletFile(new Path(chooseTabletDir() + "/"
         + prefix.createFileName(context.getUniqueNameAllocator().getNextName() 
+ "." + extension)));
   }
 
   TabletFile getNextMapFilenameForMajc(boolean propagateDeletes) throws 
IOException {
-    FileTypePrefix prefix =
-        !propagateDeletes ? FileTypePrefix.FULL_COMPACTION : 
FileTypePrefix.COMPACTION;
+    FilePrefix prefix = !propagateDeletes ? FilePrefix.FULL_COMPACTION : 
FilePrefix.COMPACTION;
     String tmpFileName = getNextMapFilename(prefix).getMetaInsert() + "_tmp";
     return new TabletFile(new Path(tmpFileName));
   }


Reply via email to