Skip to content

Commit

Permalink
Deprecation flag, build all_ext list
Browse files Browse the repository at this point in the history
Signed-off-by: David Zane <[email protected]>
  • Loading branch information
dzane17 committed Aug 8, 2023
1 parent 47adabc commit 543e590
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 33 deletions.
5 changes: 3 additions & 2 deletions server/src/main/java/org/opensearch/index/IndexModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public final class IndexModule {
* This is an expert setting.
* @see <a href="https://lucene.apache.org/core/9_5_0/core/org/apache/lucene/codecs/lucene95/package-summary.html#file-names">Lucene File Extensions</a>.
*
* @deprecated This setting will be removed in OpenSearch 4.x. Use {@link #INDEX_STORE_HYBRID_NIO_EXTENSIONS} instead.
* @deprecated This setting will be removed in OpenSearch 3.x. Use {@link #INDEX_STORE_HYBRID_NIO_EXTENSIONS} instead.
*/
@Deprecated
public static final Setting<List<String>> INDEX_STORE_HYBRID_MMAP_EXTENSIONS = Setting.listSetting(
Expand Down Expand Up @@ -196,7 +196,8 @@ public Iterator<Setting<?>> settings() {
}
},
Property.IndexScope,
Property.NodeScope
Property.NodeScope,
Property.Deprecated
);

/** Which lucene file extensions to load with nio. All others will default to mmap. Takes precedence over {@link #INDEX_STORE_HYBRID_MMAP_EXTENSIONS}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Factory for a filesystem directory
Expand Down Expand Up @@ -102,7 +103,10 @@ protected Directory newFSDirectory(Path location, LockFactory lockFactory, Index
Set<String> nioExtensions = new HashSet<>(indexSettings.getValue(IndexModule.INDEX_STORE_HYBRID_NIO_EXTENSIONS));
if (indexSettings.getValue(IndexModule.INDEX_STORE_HYBRID_MMAP_EXTENSIONS)
.equals(IndexModule.INDEX_STORE_HYBRID_MMAP_EXTENSIONS.getDefault(Settings.EMPTY)) == false) {
nioExtensions = new HashSet<>(INDEX_STORE_HYBRID_ALL_EXTENSIONS);
nioExtensions = Stream.concat(
IndexModule.INDEX_STORE_HYBRID_NIO_EXTENSIONS.getDefault(Settings.EMPTY).stream(),
IndexModule.INDEX_STORE_HYBRID_MMAP_EXTENSIONS.getDefault(Settings.EMPTY).stream()
).collect(Collectors.toSet());
nioExtensions.removeAll(indexSettings.getValue(IndexModule.INDEX_STORE_HYBRID_MMAP_EXTENSIONS));
}
if (primaryDirectory instanceof MMapDirectory) {
Expand Down Expand Up @@ -239,33 +243,4 @@ MMapDirectory getDelegate() {
return delegate;
}
}

private static List<String> INDEX_STORE_HYBRID_ALL_EXTENSIONS = List.of(
"nvd", // mmap defaults start
"dvd",
"tim",
"tip",
"dim",
"kdd",
"kdi",
"cfs",
"doc", // mmap defaults end
"segments_N", // nio defaults start
"write.lock",
"si",
"cfe",
"fnm",
"fdx",
"fdt",
"pos",
"pay",
"nvm",
"dvm",
"tvx",
"tvd",
"liv",
"dii",
"vec",
"vem" // nio defaults end
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public void testPreload() throws IOException {
assertFalse(hybridDirectory.useDelegate("foo.doc"));
MMapDirectory delegate = hybridDirectory.getDelegate();
assertThat(delegate, Matchers.instanceOf(FsDirectoryFactory.PreLoadMMapDirectory.class));
assertWarnings(
"[index.store.hybrid.mmap.extensions] setting was deprecated in OpenSearch and will be removed in a future release!"
+ " See the breaking changes documentation for the next major version."
);
}
build = Settings.builder()
.put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), IndexModule.Type.HYBRIDFS.name().toLowerCase(Locale.ROOT))
Expand Down

0 comments on commit 543e590

Please sign in to comment.