|
@@ -21,7 +21,6 @@ import org.apache.lucene.store.NativeFSLockFactory;
|
|
|
import org.apache.lucene.store.SimpleFSLockFactory;
|
|
|
import org.elasticsearch.common.settings.Setting;
|
|
|
import org.elasticsearch.common.settings.Setting.Property;
|
|
|
-import org.elasticsearch.common.util.FeatureFlag;
|
|
|
import org.elasticsearch.core.IOUtils;
|
|
|
import org.elasticsearch.index.IndexModule;
|
|
|
import org.elasticsearch.index.IndexSettings;
|
|
@@ -36,8 +35,6 @@ import java.util.Set;
|
|
|
|
|
|
public class FsDirectoryFactory implements IndexStorePlugin.DirectoryFactory {
|
|
|
|
|
|
- private static final FeatureFlag MADV_RANDOM_FEATURE_FLAG = new FeatureFlag("madv_random");
|
|
|
-
|
|
|
public static final Setting<LockFactory> INDEX_LOCK_FACTOR_SETTING = new Setting<>("index.store.fs.fs_lock", "native", (s) -> {
|
|
|
return switch (s) {
|
|
|
case "native" -> NativeFSLockFactory.INSTANCE;
|
|
@@ -69,20 +66,12 @@ public class FsDirectoryFactory implements IndexStorePlugin.DirectoryFactory {
|
|
|
// Use Lucene defaults
|
|
|
final FSDirectory primaryDirectory = FSDirectory.open(location, lockFactory);
|
|
|
if (primaryDirectory instanceof MMapDirectory mMapDirectory) {
|
|
|
- Directory dir = new HybridDirectory(lockFactory, setPreload(mMapDirectory, lockFactory, preLoadExtensions));
|
|
|
- if (MADV_RANDOM_FEATURE_FLAG.isEnabled() == false) {
|
|
|
- dir = disableRandomAdvice(dir);
|
|
|
- }
|
|
|
- return dir;
|
|
|
+ return new HybridDirectory(lockFactory, setPreload(mMapDirectory, lockFactory, preLoadExtensions));
|
|
|
} else {
|
|
|
return primaryDirectory;
|
|
|
}
|
|
|
case MMAPFS:
|
|
|
- Directory dir = setPreload(new MMapDirectory(location, lockFactory), lockFactory, preLoadExtensions);
|
|
|
- if (MADV_RANDOM_FEATURE_FLAG.isEnabled() == false) {
|
|
|
- dir = disableRandomAdvice(dir);
|
|
|
- }
|
|
|
- return dir;
|
|
|
+ return setPreload(new MMapDirectory(location, lockFactory), lockFactory, preLoadExtensions);
|
|
|
case SIMPLEFS:
|
|
|
case NIOFS:
|
|
|
return new NIOFSDirectory(location, lockFactory);
|
|
@@ -104,23 +93,6 @@ public class FsDirectoryFactory implements IndexStorePlugin.DirectoryFactory {
|
|
|
return mMapDirectory;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Return a {@link FilterDirectory} around the provided {@link Directory} that forcefully disables {@link IOContext#RANDOM random
|
|
|
- * access}.
|
|
|
- */
|
|
|
- static Directory disableRandomAdvice(Directory dir) {
|
|
|
- return new FilterDirectory(dir) {
|
|
|
- @Override
|
|
|
- public IndexInput openInput(String name, IOContext context) throws IOException {
|
|
|
- if (context.randomAccess) {
|
|
|
- context = IOContext.READ;
|
|
|
- }
|
|
|
- assert context.randomAccess == false;
|
|
|
- return super.openInput(name, context);
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Returns true iff the directory is a hybrid fs directory
|
|
|
*/
|