From 485f90414098b984ffb6649fcee24696d0e85e7e Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 24 Sep 2010 11:46:41 +0200 Subject: [PATCH] Default to not using compound file format for the index (increases number of open files, but faster indexing and recovery), closes #384. --- .../main/java/org/elasticsearch/index/store/fs/FsStore.java | 2 ++ .../java/org/elasticsearch/index/store/fs/MmapFsStore.java | 6 +++--- .../java/org/elasticsearch/index/store/fs/NioFsStore.java | 6 +++--- .../org/elasticsearch/index/store/fs/SimpleFsStore.java | 6 +++--- .../elasticsearch/index/store/support/AbstractStore.java | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/FsStore.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/FsStore.java index 8e93d848bc7..6474914d7a6 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/FsStore.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/FsStore.java @@ -40,6 +40,8 @@ import java.io.IOException; */ public abstract class FsStore extends AbstractStore { + public static final boolean DEFAULT_SUGGEST_USE_COMPOUND_FILE = false; + public FsStore(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore) { super(shardId, indexSettings, indexStore); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/MmapFsStore.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/MmapFsStore.java index c0a2f78f178..be8b262027e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/MmapFsStore.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/MmapFsStore.java @@ -60,12 +60,12 @@ public class MmapFsStore extends FsStore { if (switchDirectory.v2() != null) { suggestUseCompoundFile = switchDirectory.v2(); } - logger.debug("Using [mmap_fs] Store with path [{}], cache [true] with extensions [{}]", fsDirectory.getFile(), switchDirectory.v1().primaryExtensions()); + logger.debug("using [mmap_fs] store with path [{}], cache [true] with extensions [{}]", fsDirectory.getFile(), switchDirectory.v1().primaryExtensions()); directory = wrapDirectory(switchDirectory.v1()); } else { - suggestUseCompoundFile = true; + suggestUseCompoundFile = DEFAULT_SUGGEST_USE_COMPOUND_FILE; directory = wrapDirectory(fsDirectory); - logger.debug("Using [mmap_fs] Store with path [{}]", fsDirectory.getFile()); + logger.debug("using [mmap_fs] store with path [{}]", fsDirectory.getFile()); } this.suggestUseCompoundFile = suggestUseCompoundFile; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/NioFsStore.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/NioFsStore.java index 49de22d2964..238fcc23e22 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/NioFsStore.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/NioFsStore.java @@ -60,12 +60,12 @@ public class NioFsStore extends FsStore { if (switchDirectory.v2() != null) { suggestUseCompoundFile = switchDirectory.v2(); } - logger.debug("Using [nio_fs] Store with path [{}], cache [true] with extensions [{}]", fsDirectory.getFile(), switchDirectory.v1().primaryExtensions()); + logger.debug("using [nio_fs] store with path [{}], cache [true] with extensions [{}]", fsDirectory.getFile(), switchDirectory.v1().primaryExtensions()); directory = wrapDirectory(switchDirectory.v1()); } else { - suggestUseCompoundFile = true; + suggestUseCompoundFile = DEFAULT_SUGGEST_USE_COMPOUND_FILE; directory = wrapDirectory(fsDirectory); - logger.debug("Using [nio_fs] Store with path [{}]", fsDirectory.getFile()); + logger.debug("using [nio_fs] store with path [{}]", fsDirectory.getFile()); } this.suggestUseCompoundFile = suggestUseCompoundFile; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/SimpleFsStore.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/SimpleFsStore.java index 68f0d5c5914..4b3f898fa27 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/SimpleFsStore.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/fs/SimpleFsStore.java @@ -60,12 +60,12 @@ public class SimpleFsStore extends FsStore { if (switchDirectory.v2() != null) { suggestUseCompoundFile = switchDirectory.v2(); } - logger.debug("Using [simple_fs] Store with path [{}], cache [true] with extensions [{}]", fsDirectory.getFile(), switchDirectory.v1().primaryExtensions()); + logger.debug("using [simple_fs] store with path [{}], cache [true] with extensions [{}]", fsDirectory.getFile(), switchDirectory.v1().primaryExtensions()); directory = wrapDirectory(switchDirectory.v1()); } else { - suggestUseCompoundFile = true; + suggestUseCompoundFile = DEFAULT_SUGGEST_USE_COMPOUND_FILE; directory = wrapDirectory(fsDirectory); - logger.debug("Using [simple_fs] Store with path [{}]", fsDirectory.getFile()); + logger.debug("using [simple_fs] store with path [{}]", fsDirectory.getFile()); } this.suggestUseCompoundFile = suggestUseCompoundFile; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/support/AbstractStore.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/support/AbstractStore.java index ac4b5fd4502..047b2b8a0f2 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/support/AbstractStore.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/support/AbstractStore.java @@ -55,7 +55,7 @@ public abstract class AbstractStore extends AbstractIndexShardComponent implemen protected AbstractStore(ShardId shardId, @IndexSettings Settings indexSettings, IndexStore indexStore) { super(shardId, indexSettings); this.indexStore = indexStore; - this.sync = componentSettings.getAsBoolean("sync", false); + this.sync = componentSettings.getAsBoolean("sync", true); // TODO we don't really need to fsync when using shared gateway... } protected Directory wrapDirectory(Directory dir) throws IOException {