-
Notifications
You must be signed in to change notification settings - Fork 24.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid regular indices in frozen tier #70141
Changes from 14 commits
da7aec3
0d99c4d
55d4178
98bf727
fc7503a
8734624
7259e89
2831e28
4460f20
16fde1f
af02126
20087bd
db7e7e6
771d616
39506a5
7ca4286
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,19 +7,41 @@ | |
package org.elasticsearch.xpack.searchablesnapshots; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.common.settings.Setting; | ||
import org.elasticsearch.common.settings.Settings; | ||
|
||
import java.util.Map; | ||
|
||
import static org.elasticsearch.index.IndexModule.INDEX_STORE_TYPE_SETTING; | ||
|
||
public class SearchableSnapshotsConstants { | ||
public static final String SNAPSHOT_DIRECTORY_FACTORY_KEY = "snapshot"; | ||
|
||
public static final String SNAPSHOT_RECOVERY_STATE_FACTORY_KEY = "snapshot_prewarm"; | ||
public static final Setting<Boolean> SNAPSHOT_PARTIAL_SETTING = Setting.boolSetting( | ||
"index.store.snapshot.partial", | ||
false, | ||
Setting.Property.IndexScope, | ||
Setting.Property.PrivateIndex, | ||
Setting.Property.NotCopyableOnResize | ||
); | ||
|
||
public static boolean isSearchableSnapshotStore(Settings indexSettings) { | ||
return SNAPSHOT_DIRECTORY_FACTORY_KEY.equals(INDEX_STORE_TYPE_SETTING.get(indexSettings)); | ||
} | ||
|
||
/** | ||
* Based on a map from setting to value, do the settings represent a partial searchable snapshot index? | ||
* | ||
* Both index.store.type and index.store.snapshot.partial must be supplied. | ||
*/ | ||
public static boolean isPartialSearchableSnapshotIndex(Map<Setting<?>, Object> indexSettings) { | ||
assert indexSettings.containsKey(INDEX_STORE_TYPE_SETTING) : "must include store type in map"; | ||
assert indexSettings.get(SNAPSHOT_PARTIAL_SETTING) != null : "partial setting must be non-null in map (has default value)"; | ||
return SNAPSHOT_DIRECTORY_FACTORY_KEY.equals(indexSettings.get(INDEX_STORE_TYPE_SETTING)) | ||
&& (boolean) indexSettings.get(SNAPSHOT_PARTIAL_SETTING); | ||
Comment on lines
+41
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would be better as: return SNAPSHOT_DIRECTORY_FACTORY_KEY.equals(INDEX_STORE_TYPE_SETTING.get(indexSettings)) && SNAPSHOT_PARTIAL_SETTING.get(indexSettings); Because then it uses the default value rather than casting to a boolean. We can then remove the assertions and the method can be used on any index without worrying about tripping any errors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh nevermind, I missed that it was a |
||
} | ||
|
||
public static final String CACHE_FETCH_ASYNC_THREAD_POOL_NAME = "searchable_snapshots_cache_fetch_async"; | ||
public static final String CACHE_FETCH_ASYNC_THREAD_POOL_SETTING = "xpack.searchable_snapshots.cache_fetch_async_thread_pool"; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.searchablesnapshots; | ||
|
||
import org.elasticsearch.index.IndexModule; | ||
import org.elasticsearch.test.ESTestCase; | ||
|
||
import java.util.Map; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
|
||
public class SearchableSnapshotsConstantsTests extends ESTestCase { | ||
|
||
public void testIsPartialSearchableSnapshotIndex() { | ||
assertThat(SearchableSnapshotsConstants.isPartialSearchableSnapshotIndex( | ||
Map.of(IndexModule.INDEX_STORE_TYPE_SETTING, SearchableSnapshotsConstants.SNAPSHOT_DIRECTORY_FACTORY_KEY, | ||
SearchableSnapshotsConstants.SNAPSHOT_PARTIAL_SETTING, false)), | ||
is(false)); | ||
|
||
assertThat(SearchableSnapshotsConstants.isPartialSearchableSnapshotIndex( | ||
Map.of(IndexModule.INDEX_STORE_TYPE_SETTING, "abc", | ||
SearchableSnapshotsConstants.SNAPSHOT_PARTIAL_SETTING, randomBoolean())), | ||
is(false)); | ||
|
||
assertThat(SearchableSnapshotsConstants.isPartialSearchableSnapshotIndex( | ||
Map.of(IndexModule.INDEX_STORE_TYPE_SETTING, SearchableSnapshotsConstants.SNAPSHOT_DIRECTORY_FACTORY_KEY, | ||
SearchableSnapshotsConstants.SNAPSHOT_PARTIAL_SETTING, true)), | ||
is(true)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this method throw a NPE if indexSettings does not contain SNAPSHOT_PARTIAL_SETTING?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it could, but the expectation is that the map contains the two settings. I have added assertions to enforce this.