forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid regular indices in frozen tier (elastic#70141) (elastic#70313)
The frozen tier will be dedicated for partially cached searchable snapshots. This PR ensures that we do not allow allocating regular indices (including fully cached searchable snapshots) to the frozen tier.
- Loading branch information
1 parent
366e2f4
commit 3baaed2
Showing
18 changed files
with
316 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...t/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsConstantsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 org.elasticsearch.common.collect.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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...ava/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotDataTierIntegTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* 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.action.admin.indices.settings.put.UpdateSettingsRequest; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.test.ESIntegTestCase; | ||
import org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider; | ||
import org.elasticsearch.xpack.core.DataTier; | ||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest; | ||
|
||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST) | ||
public class SearchableSnapshotDataTierIntegTests extends BaseSearchableSnapshotsIntegTestCase { | ||
|
||
private static final String repoName = "test-repo"; | ||
private static final String indexName = "test-index"; | ||
private static final String snapshotName = "test-snapshot"; | ||
private static final String mountedIndexName = "test-index-mounted"; | ||
private static final Settings frozenSettings = Settings.builder() | ||
.put(DataTierAllocationDecider.INDEX_ROUTING_PREFER, DataTier.DATA_FROZEN) | ||
.build(); | ||
|
||
public void testPartialLegalOnFrozen() throws Exception { | ||
createRepository(repoName, "fs"); | ||
createIndex(indexName); | ||
createFullSnapshot(repoName, snapshotName); | ||
Settings mountSettings = randomFrom(Settings.EMPTY, frozenSettings); | ||
mountSnapshot( | ||
repoName, | ||
snapshotName, | ||
indexName, | ||
mountedIndexName, | ||
mountSettings, | ||
MountSearchableSnapshotRequest.Storage.SHARED_CACHE | ||
); | ||
|
||
updatePreference(DataTier.DATA_FROZEN); | ||
} | ||
|
||
public void testFullIllegalOnFrozen() throws Exception { | ||
createRepository(repoName, "fs"); | ||
createIndex(indexName); | ||
createFullSnapshot(repoName, snapshotName); | ||
expectThrows( | ||
IllegalArgumentException.class, | ||
() -> mountSnapshot( | ||
repoName, | ||
snapshotName, | ||
indexName, | ||
mountedIndexName, | ||
frozenSettings, | ||
MountSearchableSnapshotRequest.Storage.FULL_COPY | ||
) | ||
); | ||
Settings mountSettings = randomFrom( | ||
Settings.EMPTY, | ||
Settings.builder() | ||
.put( | ||
DataTierAllocationDecider.INDEX_ROUTING_PREFER, | ||
randomValueOtherThan(DataTier.DATA_FROZEN, () -> randomFrom(DataTier.ALL_DATA_TIERS)) | ||
) | ||
.build() | ||
); | ||
mountSnapshot(repoName, snapshotName, indexName, mountedIndexName, mountSettings, MountSearchableSnapshotRequest.Storage.FULL_COPY); | ||
|
||
expectThrows(IllegalArgumentException.class, () -> updatePreference(DataTier.DATA_FROZEN)); | ||
} | ||
|
||
private void updatePreference(String tier) { | ||
client().admin() | ||
.indices() | ||
.updateSettings( | ||
new UpdateSettingsRequest(mountedIndexName).settings( | ||
org.elasticsearch.common.collect.Map.of(DataTierAllocationDecider.INDEX_ROUTING_PREFER, tier) | ||
) | ||
) | ||
.actionGet(); | ||
} | ||
} |
Oops, something went wrong.