|
@@ -81,8 +81,6 @@ import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsCon
|
|
|
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants.CACHE_FETCH_ASYNC_THREAD_POOL_SETTING;
|
|
|
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants.CACHE_PREWARMING_THREAD_POOL_NAME;
|
|
|
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants.CACHE_PREWARMING_THREAD_POOL_SETTING;
|
|
|
-import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants.SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED;
|
|
|
-import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants.CACHE_FETCH_ASYNC_THREAD_POOL_NAME;
|
|
|
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants.SNAPSHOT_BLOB_CACHE_INDEX;
|
|
|
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants.SNAPSHOT_DIRECTORY_FACTORY_KEY;
|
|
|
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants.SNAPSHOT_RECOVERY_STATE_FACTORY_KEY;
|
|
@@ -170,23 +168,19 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Eng
|
|
|
|
|
|
@Override
|
|
|
public List<Setting<?>> getSettings() {
|
|
|
- if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
|
|
- return List.of(
|
|
|
- SNAPSHOT_REPOSITORY_SETTING,
|
|
|
- SNAPSHOT_SNAPSHOT_NAME_SETTING,
|
|
|
- SNAPSHOT_SNAPSHOT_ID_SETTING,
|
|
|
- SNAPSHOT_INDEX_NAME_SETTING,
|
|
|
- SNAPSHOT_INDEX_ID_SETTING,
|
|
|
- SNAPSHOT_CACHE_ENABLED_SETTING,
|
|
|
- SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING,
|
|
|
- SNAPSHOT_CACHE_EXCLUDED_FILE_TYPES_SETTING,
|
|
|
- SNAPSHOT_UNCACHED_CHUNK_SIZE_SETTING,
|
|
|
- CacheService.SNAPSHOT_CACHE_SIZE_SETTING,
|
|
|
- CacheService.SNAPSHOT_CACHE_RANGE_SIZE_SETTING
|
|
|
- );
|
|
|
- } else {
|
|
|
- return List.of();
|
|
|
- }
|
|
|
+ return List.of(
|
|
|
+ SNAPSHOT_REPOSITORY_SETTING,
|
|
|
+ SNAPSHOT_SNAPSHOT_NAME_SETTING,
|
|
|
+ SNAPSHOT_SNAPSHOT_ID_SETTING,
|
|
|
+ SNAPSHOT_INDEX_NAME_SETTING,
|
|
|
+ SNAPSHOT_INDEX_ID_SETTING,
|
|
|
+ SNAPSHOT_CACHE_ENABLED_SETTING,
|
|
|
+ SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING,
|
|
|
+ SNAPSHOT_CACHE_EXCLUDED_FILE_TYPES_SETTING,
|
|
|
+ SNAPSHOT_UNCACHED_CHUNK_SIZE_SETTING,
|
|
|
+ CacheService.SNAPSHOT_CACHE_SIZE_SETTING,
|
|
|
+ CacheService.SNAPSHOT_CACHE_RANGE_SIZE_SETTING
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -203,29 +197,19 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Eng
|
|
|
final IndexNameExpressionResolver resolver,
|
|
|
final Supplier<RepositoriesService> repositoriesServiceSupplier
|
|
|
) {
|
|
|
- if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
|
|
- final CacheService cacheService = new CacheService(new NodeEnvironmentCacheCleaner(nodeEnvironment), settings);
|
|
|
- this.cacheService.set(cacheService);
|
|
|
- this.repositoriesServiceSupplier = repositoriesServiceSupplier;
|
|
|
- this.threadPool.set(threadPool);
|
|
|
- final BlobStoreCacheService blobStoreCacheService = new BlobStoreCacheService(
|
|
|
- clusterService,
|
|
|
- threadPool,
|
|
|
- client,
|
|
|
- SNAPSHOT_BLOB_CACHE_INDEX
|
|
|
- );
|
|
|
- this.blobStoreCacheService.set(blobStoreCacheService);
|
|
|
- this.failShardsListener.set(
|
|
|
- new FailShardsOnInvalidLicenseClusterListener(getLicenseState(), clusterService.getRerouteService())
|
|
|
- );
|
|
|
- return List.of(cacheService, blobStoreCacheService);
|
|
|
- } else {
|
|
|
- this.repositoriesServiceSupplier = () -> {
|
|
|
- assert false : "searchable snapshots are disabled";
|
|
|
- return null;
|
|
|
- };
|
|
|
- return List.of();
|
|
|
- }
|
|
|
+ final CacheService cacheService = new CacheService(new NodeEnvironmentCacheCleaner(nodeEnvironment), settings);
|
|
|
+ this.cacheService.set(cacheService);
|
|
|
+ this.repositoriesServiceSupplier = repositoriesServiceSupplier;
|
|
|
+ this.threadPool.set(threadPool);
|
|
|
+ final BlobStoreCacheService blobStoreCacheService = new BlobStoreCacheService(
|
|
|
+ clusterService,
|
|
|
+ threadPool,
|
|
|
+ client,
|
|
|
+ SNAPSHOT_BLOB_CACHE_INDEX
|
|
|
+ );
|
|
|
+ this.blobStoreCacheService.set(blobStoreCacheService);
|
|
|
+ this.failShardsListener.set(new FailShardsOnInvalidLicenseClusterListener(getLicenseState(), clusterService.getRerouteService()));
|
|
|
+ return List.of(cacheService, blobStoreCacheService);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -243,29 +227,25 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Eng
|
|
|
|
|
|
@Override
|
|
|
public Map<String, DirectoryFactory> getDirectoryFactories() {
|
|
|
- if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
|
|
- return Map.of(SNAPSHOT_DIRECTORY_FACTORY_KEY, (indexSettings, shardPath) -> {
|
|
|
- final RepositoriesService repositories = repositoriesServiceSupplier.get();
|
|
|
- assert repositories != null;
|
|
|
- final CacheService cache = cacheService.get();
|
|
|
- assert cache != null;
|
|
|
- final ThreadPool threadPool = this.threadPool.get();
|
|
|
- assert threadPool != null;
|
|
|
- final BlobStoreCacheService blobCache = blobStoreCacheService.get();
|
|
|
- assert blobCache != null;
|
|
|
- return SearchableSnapshotDirectory.create(
|
|
|
- repositories,
|
|
|
- cache,
|
|
|
- indexSettings,
|
|
|
- shardPath,
|
|
|
- System::nanoTime,
|
|
|
- threadPool,
|
|
|
- blobCache
|
|
|
- );
|
|
|
- });
|
|
|
- } else {
|
|
|
- return Map.of();
|
|
|
- }
|
|
|
+ return Map.of(SNAPSHOT_DIRECTORY_FACTORY_KEY, (indexSettings, shardPath) -> {
|
|
|
+ final RepositoriesService repositories = repositoriesServiceSupplier.get();
|
|
|
+ assert repositories != null;
|
|
|
+ final CacheService cache = cacheService.get();
|
|
|
+ assert cache != null;
|
|
|
+ final ThreadPool threadPool = this.threadPool.get();
|
|
|
+ assert threadPool != null;
|
|
|
+ final BlobStoreCacheService blobCache = blobStoreCacheService.get();
|
|
|
+ assert blobCache != null;
|
|
|
+ return SearchableSnapshotDirectory.create(
|
|
|
+ repositories,
|
|
|
+ cache,
|
|
|
+ indexSettings,
|
|
|
+ shardPath,
|
|
|
+ System::nanoTime,
|
|
|
+ threadPool,
|
|
|
+ blobCache
|
|
|
+ );
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -281,18 +261,14 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Eng
|
|
|
|
|
|
@Override
|
|
|
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
|
|
|
- if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
|
|
- return List.of(
|
|
|
- new ActionHandler<>(SearchableSnapshotsStatsAction.INSTANCE, TransportSearchableSnapshotsStatsAction.class),
|
|
|
- new ActionHandler<>(ClearSearchableSnapshotsCacheAction.INSTANCE, TransportClearSearchableSnapshotsCacheAction.class),
|
|
|
- new ActionHandler<>(MountSearchableSnapshotAction.INSTANCE, TransportMountSearchableSnapshotAction.class),
|
|
|
- new ActionHandler<>(RepositoryStatsAction.INSTANCE, TransportRepositoryStatsAction.class),
|
|
|
- new ActionHandler<>(XPackUsageFeatureAction.SEARCHABLE_SNAPSHOTS, SearchableSnapshotsUsageTransportAction.class),
|
|
|
- new ActionHandler<>(XPackInfoFeatureAction.SEARCHABLE_SNAPSHOTS, SearchableSnapshotsInfoTransportAction.class)
|
|
|
- );
|
|
|
- } else {
|
|
|
- return List.of();
|
|
|
- }
|
|
|
+ return List.of(
|
|
|
+ new ActionHandler<>(SearchableSnapshotsStatsAction.INSTANCE, TransportSearchableSnapshotsStatsAction.class),
|
|
|
+ new ActionHandler<>(ClearSearchableSnapshotsCacheAction.INSTANCE, TransportClearSearchableSnapshotsCacheAction.class),
|
|
|
+ new ActionHandler<>(MountSearchableSnapshotAction.INSTANCE, TransportMountSearchableSnapshotAction.class),
|
|
|
+ new ActionHandler<>(RepositoryStatsAction.INSTANCE, TransportRepositoryStatsAction.class),
|
|
|
+ new ActionHandler<>(XPackUsageFeatureAction.SEARCHABLE_SNAPSHOTS, SearchableSnapshotsUsageTransportAction.class),
|
|
|
+ new ActionHandler<>(XPackInfoFeatureAction.SEARCHABLE_SNAPSHOTS, SearchableSnapshotsInfoTransportAction.class)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public List<RestHandler> getRestHandlers(
|
|
@@ -304,25 +280,17 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Eng
|
|
|
IndexNameExpressionResolver indexNameExpressionResolver,
|
|
|
Supplier<DiscoveryNodes> nodesInCluster
|
|
|
) {
|
|
|
- if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
|
|
- return List.of(
|
|
|
- new RestSearchableSnapshotsStatsAction(),
|
|
|
- new RestClearSearchableSnapshotsCacheAction(),
|
|
|
- new RestMountSearchableSnapshotAction(),
|
|
|
- new RestRepositoryStatsAction()
|
|
|
- );
|
|
|
- } else {
|
|
|
- return List.of();
|
|
|
- }
|
|
|
+ return List.of(
|
|
|
+ new RestSearchableSnapshotsStatsAction(),
|
|
|
+ new RestClearSearchableSnapshotsCacheAction(),
|
|
|
+ new RestMountSearchableSnapshotAction(),
|
|
|
+ new RestRepositoryStatsAction()
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, ExistingShardsAllocator> getExistingShardsAllocators() {
|
|
|
- if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
|
|
- return Collections.singletonMap(SearchableSnapshotAllocator.ALLOCATOR_NAME, new SearchableSnapshotAllocator());
|
|
|
- } else {
|
|
|
- return Collections.emptyMap();
|
|
|
- }
|
|
|
+ return Map.of(SearchableSnapshotAllocator.ALLOCATOR_NAME, new SearchableSnapshotAllocator());
|
|
|
}
|
|
|
|
|
|
// overridable by tests
|
|
@@ -332,30 +300,18 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Eng
|
|
|
|
|
|
@Override
|
|
|
public Collection<AllocationDecider> createAllocationDeciders(Settings settings, ClusterSettings clusterSettings) {
|
|
|
- if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
|
|
- return List.of(
|
|
|
- new SearchableSnapshotAllocationDecider(() -> getLicenseState().isAllowed(XPackLicenseState.Feature.SEARCHABLE_SNAPSHOTS))
|
|
|
- );
|
|
|
- } else {
|
|
|
- return Collections.emptyList();
|
|
|
- }
|
|
|
+ return List.of(
|
|
|
+ new SearchableSnapshotAllocationDecider(() -> getLicenseState().isAllowed(XPackLicenseState.Feature.SEARCHABLE_SNAPSHOTS))
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) {
|
|
|
- if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
|
|
- return List.of(executorBuilders());
|
|
|
- } else {
|
|
|
- return List.of();
|
|
|
- }
|
|
|
+ return List.of(executorBuilders());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String, RecoveryStateFactory> getRecoveryStateFactories() {
|
|
|
- if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
|
|
- return Map.of(SNAPSHOT_RECOVERY_STATE_FACTORY_KEY, SearchableSnapshotRecoveryState::new);
|
|
|
- } else {
|
|
|
- return Map.of();
|
|
|
- }
|
|
|
+ return Map.of(SNAPSHOT_RECOVERY_STATE_FACTORY_KEY, SearchableSnapshotRecoveryState::new);
|
|
|
}
|
|
|
|
|
|
public static ScalingExecutorBuilder[] executorBuilders() {
|