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 c311947400 Added FilePrefix enum for assigning and evaluating filenames (#3148) c311947400 is described below commit c31194740080a1f12c65aec82fe46731f9da2069 Author: Dave Marion <dlmar...@apache.org> AuthorDate: Fri Jan 6 10:47:09 2023 -0500 Added FilePrefix enum for assigning and evaluating filenames (#3148) --- .../org/apache/accumulo/core/file/FilePrefix.java | 50 ++++++++++++++++++++++ .../manager/tableOps/bulkVer2/PrepBulkImport.java | 5 ++- .../tserver/tablet/MinorCompactionTask.java | 3 +- .../org/apache/accumulo/tserver/tablet/Tablet.java | 9 ++-- 4 files changed, 61 insertions(+), 6 deletions(-) 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..5f42877859 --- /dev/null +++ b/core/src/main/java/org/apache/accumulo/core/file/FilePrefix.java @@ -0,0 +1,50 @@ +/* + * 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; + +public enum FilePrefix { + + BULK_IMPORT("I"), MINOR_COMPACTION("F"), MAJOR_COMPACTION("C"), MAJOR_COMPACTION_ALL_FILES("A"); + + String prefix; + + FilePrefix(String prefix) { + this.prefix = prefix; + } + + public static FilePrefix fromPrefix(String prefix) { + switch (prefix) { + case "I": + return BULK_IMPORT; + case "F": + return MINOR_COMPACTION; + case "C": + return MAJOR_COMPACTION; + case "A": + return MAJOR_COMPACTION_ALL_FILES; + default: + throw new IllegalArgumentException("Unknown prefix type: " + prefix); + } + } + + public String toPrefix() { + return this.prefix; + } + +} 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 1940c64002..62e4315d87 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 @@ -42,6 +42,7 @@ import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.dataImpl.KeyExtent; 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.manager.Manager; @@ -220,8 +221,8 @@ public class PrepBulkImport extends ManagerRepo { for (FileStatus file : files) { // since these are only valid files we know it has an extension - String newName = - "I" + namer.getNextName() + "." + FilenameUtils.getExtension(file.getPath().getName()); + String newName = FilePrefix.BULK_IMPORT + namer.getNextName() + "." + + FilenameUtils.getExtension(file.getPath().getName()); oldToNewNameMap.put(file.getPath().getName(), new Path(bulkDir, newName).getName()); } 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 f666fb96e9..58a2f3717b 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 @@ -20,6 +20,7 @@ package org.apache.accumulo.tserver.tablet; import java.io.IOException; +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; @@ -76,7 +77,7 @@ class MinorCompactionTask implements Runnable { while (true) { try { if (newFile == null) { - newFile = tablet.getNextMapFilename("F"); + newFile = tablet.getNextMapFilename(FilePrefix.MINOR_COMPACTION); 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 578b01df40..2ec3ad4707 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 @@ -63,6 +63,7 @@ import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.dataImpl.KeyExtent; import org.apache.accumulo.core.dataImpl.thrift.MapFileInfo; 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.TabletLogger; @@ -248,14 +249,16 @@ public class Tablet extends TabletBase { return dirUri; } - TabletFile getNextMapFilename(String prefix) throws IOException { + TabletFile getNextMapFilename(FilePrefix prefix) throws IOException { String extension = FileOperations.getNewFileExtension(tableConfiguration); - return new TabletFile(new Path(chooseTabletDir() + "/" + prefix + return new TabletFile(new Path(chooseTabletDir() + "/" + prefix.toPrefix() + context.getUniqueNameAllocator().getNextName() + "." + extension)); } TabletFile getNextMapFilenameForMajc(boolean propagateDeletes) throws IOException { - String tmpFileName = getNextMapFilename(!propagateDeletes ? "A" : "C").getMetaInsert() + "_tmp"; + String tmpFileName = getNextMapFilename( + !propagateDeletes ? FilePrefix.MAJOR_COMPACTION_ALL_FILES : FilePrefix.MAJOR_COMPACTION) + .getMetaInsert() + "_tmp"; return new TabletFile(new Path(tmpFileName)); }