Enable prewarming by default for searchable snapshots ()

Now searchable snapshots directories respect the repository 
rate limitations () we can enable prewarming by default 
for shards.
This commit is contained in:
Tanguy Leroux 2020-05-06 10:17:19 +02:00
parent b8b4ebd089
commit 07ad742b60
3 changed files with 14 additions and 5 deletions
x-pack/plugin/searchable-snapshots/src
main/java/org/elasticsearch/xpack/searchablesnapshots
test/java/org/elasticsearch/index/store

@ -106,7 +106,7 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Eng
);
public static final Setting<Boolean> SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING = Setting.boolSetting(
"index.store.snapshot.cache.prewarm.enabled",
false,
true,
Setting.Property.IndexScope
);
// The file extensions that are excluded from the cache

@ -37,6 +37,7 @@ import static org.elasticsearch.index.store.cache.TestUtils.assertCounter;
import static org.elasticsearch.index.store.cache.TestUtils.createCacheService;
import static org.elasticsearch.index.store.cache.TestUtils.singleBlobContainer;
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING;
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshots.SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING;
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshots.SNAPSHOT_UNCACHED_CHUNK_SIZE_SETTING;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.equalTo;
@ -520,7 +521,10 @@ public class SearchableSnapshotDirectoryStatsTests extends ESIndexInputTestCase
private static void executeTestCase(final TriConsumer<String, byte[], SearchableSnapshotDirectory> test) {
executeTestCase(
createCacheService(random()),
Settings.builder().put(SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), randomBoolean()).build(),
Settings.builder()
.put(SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), randomBoolean())
.put(SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING.getKey(), false) // disable prewarming as it impacts the stats
.build(),
test
);
}
@ -554,7 +558,10 @@ public class SearchableSnapshotDirectoryStatsTests extends ESIndexInputTestCase
) {
executeTestCase(
new CacheService(cacheSize, cacheRangeSize),
Settings.builder().put(SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true).build(),
Settings.builder()
.put(SNAPSHOT_CACHE_ENABLED_SETTING.getKey(), true)
.put(SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING.getKey(), false) // disable prewarming as it impacts the stats
.build(),
test
);
}

@ -157,7 +157,7 @@ public class CachedBlobContainerIndexInputTests extends ESIndexInputTestCase {
);
final BlobContainer blobContainer = singleBlobContainer(blobName, input);
final ThreadPool threadPool = new TestThreadPool(getTestName(), SearchableSnapshots.executorBuilder());
final Path cacheDir = createTempDir();
try (
SearchableSnapshotDirectory searchableSnapshotDirectory = new SearchableSnapshotDirectory(
@ -170,7 +170,7 @@ public class CachedBlobContainerIndexInputTests extends ESIndexInputTestCase {
() -> 0L,
cacheService,
cacheDir,
null
threadPool
)
) {
final boolean loaded = searchableSnapshotDirectory.loadSnapshot();
@ -185,6 +185,8 @@ public class CachedBlobContainerIndexInputTests extends ESIndexInputTestCase {
throw new AssertionError("inner EOFException not thrown", exception);
}
}
} finally {
terminate(threadPool);
}
}
}