Add tier preference when mounting (#63204)

This commit adds a tier preference when mounting a searchable
snapshot. This sets a preference that a searchable snapshot is mounted
to a node with the cold role if one exists, then the warm role, then the
hot role, assuming that no other allocation rules are in place. This
means that by default, searchable snapshots are mounted to a node with
the cold role.

Note that depending on how we implement frozen functionality of
searchable snapshots (not pre-cached/not fully-cached), we might need to
adjust this to prefer frozen if mounting a not pre-cached/fully-cached
searchable snapshot versus mounting a pre-cached/fully-cached searchable
snapshot. This is a later concern since neither this nor the frozen role
are implemented currently.
This commit is contained in:
Jason Tedor 2020-10-03 07:32:53 -04:00
parent 4ef8673fdd
commit 1c136bb7fc
No known key found for this signature in database
GPG Key ID: FA89F05560F16BC5
1 changed files with 7 additions and 0 deletions

View File

@ -33,6 +33,8 @@ import org.elasticsearch.repositories.RepositoryData;
import org.elasticsearch.snapshots.SnapshotId;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider;
import org.elasticsearch.xpack.core.DataTier;
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
import org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotAllocator;
@ -182,6 +184,11 @@ public class TransportMountSearchableSnapshotAction extends TransportMasterNodeA
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) // can be overridden
.put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, false) // can be overridden
// prefer to allocate to the cold tier, then the warm tier, then the hot tier
.put(
DataTierAllocationDecider.INDEX_ROUTING_PREFER,
String.join(",", DataTier.DATA_COLD, DataTier.DATA_WARM, DataTier.DATA_HOT)
)
.put(request.indexSettings())
.put(buildIndexSettings(request.repositoryName(), snapshotId, indexId))
.build()