mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-30 02:13:33 -04:00
Fix stuff after cherry-picking
This commit is contained in:
parent
f108eb118a
commit
6f50c92d69
20 changed files with 85 additions and 62 deletions
|
@ -43,7 +43,7 @@ public class ESIndexInputTestCase extends ESTestCase {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void createExecutor() {
|
public static void createExecutor() {
|
||||||
final String name = "TEST-" + getTestClass().getSimpleName() + "#randomReadAndSlice";
|
final String name = "TEST-" + getTestClass().getSimpleName() + "#randomReadAndSlice";
|
||||||
executor = EsExecutors.newFixed(name, 10, 0, EsExecutors.daemonThreadFactory(name), new ThreadContext(Settings.EMPTY), false);
|
executor = EsExecutors.newFixed(name, 10, 0, EsExecutors.daemonThreadFactory(name), new ThreadContext(Settings.EMPTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class CleanupSnapshotStep extends AsyncRetryDuringSnapshotActionStep {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DeleteSnapshotRequest deleteSnapshotRequest = new DeleteSnapshotRequest(repositoryName, snapshotName);
|
DeleteSnapshotRequest deleteSnapshotRequest = new DeleteSnapshotRequest(repositoryName, snapshotName);
|
||||||
getClient().admin().cluster().deleteSnapshot(deleteSnapshotRequest, new ActionListener<>() {
|
getClient().admin().cluster().deleteSnapshot(deleteSnapshotRequest, new ActionListener<AcknowledgedResponse>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(AcknowledgedResponse acknowledgedResponse) {
|
public void onResponse(AcknowledgedResponse acknowledgedResponse) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class DeleteAction implements LifecycleAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteAction(StreamInput in) throws IOException {
|
public DeleteAction(StreamInput in) throws IOException {
|
||||||
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
|
if (in.getVersion().onOrAfter(Version.V_7_8_0)) {
|
||||||
this.deleteSearchableSnapshot = in.readBoolean();
|
this.deleteSearchableSnapshot = in.readBoolean();
|
||||||
} else {
|
} else {
|
||||||
this.deleteSearchableSnapshot = true;
|
this.deleteSearchableSnapshot = true;
|
||||||
|
@ -59,7 +59,7 @@ public class DeleteAction implements LifecycleAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
|
if (out.getVersion().onOrAfter(Version.V_7_8_0)) {
|
||||||
out.writeBoolean(deleteSearchableSnapshot);
|
out.writeBoolean(deleteSearchableSnapshot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ public class IndexLifecycleExplainResponse implements ToXContentObject, Writeabl
|
||||||
isAutoRetryableError = null;
|
isAutoRetryableError = null;
|
||||||
failedStepRetryCount = null;
|
failedStepRetryCount = null;
|
||||||
}
|
}
|
||||||
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
|
if (in.getVersion().onOrAfter(Version.V_7_8_0)) {
|
||||||
repositoryName = in.readOptionalString();
|
repositoryName = in.readOptionalString();
|
||||||
snapshotName = in.readOptionalString();
|
snapshotName = in.readOptionalString();
|
||||||
} else {
|
} else {
|
||||||
|
@ -240,7 +240,7 @@ public class IndexLifecycleExplainResponse implements ToXContentObject, Writeabl
|
||||||
out.writeOptionalBoolean(isAutoRetryableError);
|
out.writeOptionalBoolean(isAutoRetryableError);
|
||||||
out.writeOptionalVInt(failedStepRetryCount);
|
out.writeOptionalVInt(failedStepRetryCount);
|
||||||
}
|
}
|
||||||
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
|
if (out.getVersion().onOrAfter(Version.V_7_8_0)) {
|
||||||
out.writeOptionalString(repositoryName);
|
out.writeOptionalString(repositoryName);
|
||||||
out.writeOptionalString(snapshotName);
|
out.writeOptionalString(snapshotName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,12 @@ public class MountSearchableSnapshotRequest extends MasterNodeRequest<MountSearc
|
||||||
public static final ConstructingObjectParser<MountSearchableSnapshotRequest, RestRequest> PARSER = new ConstructingObjectParser<>(
|
public static final ConstructingObjectParser<MountSearchableSnapshotRequest, RestRequest> PARSER = new ConstructingObjectParser<>(
|
||||||
"mount_searchable_snapshot", true,
|
"mount_searchable_snapshot", true,
|
||||||
(a, request) -> new MountSearchableSnapshotRequest(
|
(a, request) -> new MountSearchableSnapshotRequest(
|
||||||
Objects.requireNonNullElse((String)a[1], (String)a[0]),
|
(String) ((a[1] != null) ? a[1] : Objects.requireNonNull(a[0])),
|
||||||
request.param("repository"),
|
request.param("repository"),
|
||||||
request.param("snapshot"),
|
request.param("snapshot"),
|
||||||
(String)a[0],
|
(String) a[0],
|
||||||
Objects.requireNonNullElse((Settings)a[2], Settings.EMPTY),
|
(Settings) ((a[2] != null) ? a[2] : Settings.EMPTY),
|
||||||
Objects.requireNonNullElse((String[])a[3], Strings.EMPTY_ARRAY),
|
(String[]) ((a[3] != null) ? a[3] : Strings.EMPTY_ARRAY),
|
||||||
request.paramAsBoolean("wait_for_completion", false)));
|
request.paramAsBoolean("wait_for_completion", false)));
|
||||||
|
|
||||||
private static final ParseField INDEX_FIELD = new ParseField("index");
|
private static final ParseField INDEX_FIELD = new ParseField("index");
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class CleanupSnapshotStepTests extends AbstractStepTestCase<CleanupSnapsh
|
||||||
IndexMetadata.Builder indexMetadataBuilder =
|
IndexMetadata.Builder indexMetadataBuilder =
|
||||||
IndexMetadata.builder(indexName).settings(settings(Version.CURRENT).put(LifecycleSettings.LIFECYCLE_NAME, policyName))
|
IndexMetadata.builder(indexName).settings(settings(Version.CURRENT).put(LifecycleSettings.LIFECYCLE_NAME, policyName))
|
||||||
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5));
|
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5));
|
||||||
Map<String, String> ilmCustom = Map.of("snapshot_repository", "repository_name");
|
Map<String, String> ilmCustom = org.elasticsearch.common.collect.Map.of("snapshot_repository", "repository_name");
|
||||||
indexMetadataBuilder.putCustom(LifecycleExecutionState.ILM_CUSTOM_METADATA_KEY, ilmCustom);
|
indexMetadataBuilder.putCustom(LifecycleExecutionState.ILM_CUSTOM_METADATA_KEY, ilmCustom);
|
||||||
|
|
||||||
IndexMetadata indexMetaData = indexMetadataBuilder.build();
|
IndexMetadata indexMetaData = indexMetadataBuilder.build();
|
||||||
|
@ -116,7 +116,7 @@ public class CleanupSnapshotStepTests extends AbstractStepTestCase<CleanupSnapsh
|
||||||
String indexName = randomAlphaOfLength(10);
|
String indexName = randomAlphaOfLength(10);
|
||||||
String policyName = "test-ilm-policy";
|
String policyName = "test-ilm-policy";
|
||||||
String snapshotName = indexName + "-" + policyName;
|
String snapshotName = indexName + "-" + policyName;
|
||||||
Map<String, String> ilmCustom = Map.of("snapshot_name", snapshotName);
|
Map<String, String> ilmCustom = org.elasticsearch.common.collect.Map.of("snapshot_name", snapshotName);
|
||||||
|
|
||||||
IndexMetadata.Builder indexMetadataBuilder =
|
IndexMetadata.Builder indexMetadataBuilder =
|
||||||
IndexMetadata.builder(indexName).settings(settings(Version.CURRENT).put(LifecycleSettings.LIFECYCLE_NAME, policyName))
|
IndexMetadata.builder(indexName).settings(settings(Version.CURRENT).put(LifecycleSettings.LIFECYCLE_NAME, policyName))
|
||||||
|
|
|
@ -21,9 +21,9 @@ import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotA
|
||||||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
|
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static java.util.Collections.emptyList;
|
||||||
import static org.elasticsearch.xpack.core.ilm.AbstractStepMasterTimeoutTestCase.emptyClusterState;
|
import static org.elasticsearch.xpack.core.ilm.AbstractStepMasterTimeoutTestCase.emptyClusterState;
|
||||||
import static org.hamcrest.Matchers.instanceOf;
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
@ -179,7 +179,7 @@ public class MountSnapshotStepTests extends AbstractStepTestCase<MountSnapshotSt
|
||||||
ClusterState.builder(emptyClusterState()).metadata(Metadata.builder().put(indexMetaData, true).build()).build();
|
ClusterState.builder(emptyClusterState()).metadata(Metadata.builder().put(indexMetaData, true).build()).build();
|
||||||
|
|
||||||
{
|
{
|
||||||
RestoreSnapshotResponse responseWithOKStatus = new RestoreSnapshotResponse(new RestoreInfo("test", List.of(), 1, 1));
|
RestoreSnapshotResponse responseWithOKStatus = new RestoreSnapshotResponse(new RestoreInfo("test", emptyList(), 1, 1));
|
||||||
try (NoOpClient clientPropagatingOKResponse = getClientTriggeringResponse(responseWithOKStatus)) {
|
try (NoOpClient clientPropagatingOKResponse = getClientTriggeringResponse(responseWithOKStatus)) {
|
||||||
MountSnapshotStep step = new MountSnapshotStep(randomStepKey(), randomStepKey(), clientPropagatingOKResponse,
|
MountSnapshotStep step = new MountSnapshotStep(randomStepKey(), randomStepKey(), clientPropagatingOKResponse,
|
||||||
RESTORED_INDEX_PREFIX);
|
RESTORED_INDEX_PREFIX);
|
||||||
|
|
|
@ -1593,7 +1593,7 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
||||||
|
|
||||||
// create policy with cold and delete phases
|
// create policy with cold and delete phases
|
||||||
Map<String, LifecycleAction> coldActions =
|
Map<String, LifecycleAction> coldActions =
|
||||||
Map.of(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo));
|
singletonMap(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo));
|
||||||
Map<String, Phase> phases = new HashMap<>();
|
Map<String, Phase> phases = new HashMap<>();
|
||||||
phases.put("cold", new Phase("cold", TimeValue.ZERO, coldActions));
|
phases.put("cold", new Phase("cold", TimeValue.ZERO, coldActions));
|
||||||
phases.put("delete", new Phase("delete", TimeValue.timeValueMillis(10000), singletonMap(DeleteAction.NAME,
|
phases.put("delete", new Phase("delete", TimeValue.timeValueMillis(10000), singletonMap(DeleteAction.NAME,
|
||||||
|
@ -1649,7 +1649,7 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
||||||
|
|
||||||
// create policy with cold and delete phases
|
// create policy with cold and delete phases
|
||||||
Map<String, LifecycleAction> coldActions =
|
Map<String, LifecycleAction> coldActions =
|
||||||
Map.of(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo));
|
singletonMap(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo));
|
||||||
Map<String, Phase> phases = new HashMap<>();
|
Map<String, Phase> phases = new HashMap<>();
|
||||||
phases.put("cold", new Phase("cold", TimeValue.ZERO, coldActions));
|
phases.put("cold", new Phase("cold", TimeValue.ZERO, coldActions));
|
||||||
phases.put("delete", new Phase("delete", TimeValue.timeValueMillis(10000), singletonMap(DeleteAction.NAME,
|
phases.put("delete", new Phase("delete", TimeValue.timeValueMillis(10000), singletonMap(DeleteAction.NAME,
|
||||||
|
|
|
@ -174,7 +174,7 @@ public class SearchableSnapshotDirectory extends BaseDirectory {
|
||||||
|
|
||||||
private List<BlobStoreIndexShardSnapshot.FileInfo> files() {
|
private List<BlobStoreIndexShardSnapshot.FileInfo> files() {
|
||||||
if (loaded == false) {
|
if (loaded == false) {
|
||||||
return List.of();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
final List<BlobStoreIndexShardSnapshot.FileInfo> files = snapshot().indexFiles();
|
final List<BlobStoreIndexShardSnapshot.FileInfo> files = snapshot().indexFiles();
|
||||||
assert files != null;
|
assert files != null;
|
||||||
|
|
|
@ -66,6 +66,12 @@ import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
import static java.util.Collections.emptyList;
|
||||||
|
import static java.util.Collections.emptyMap;
|
||||||
|
import static java.util.Collections.singletonList;
|
||||||
|
import static java.util.Collections.singletonMap;
|
||||||
|
import static java.util.Collections.unmodifiableList;
|
||||||
import static org.elasticsearch.index.IndexModule.INDEX_STORE_TYPE_SETTING;
|
import static org.elasticsearch.index.IndexModule.INDEX_STORE_TYPE_SETTING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,7 +124,7 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Rep
|
||||||
// The file extensions that are excluded from the cache
|
// The file extensions that are excluded from the cache
|
||||||
public static final Setting<List<String>> SNAPSHOT_CACHE_EXCLUDED_FILE_TYPES_SETTING = Setting.listSetting(
|
public static final Setting<List<String>> SNAPSHOT_CACHE_EXCLUDED_FILE_TYPES_SETTING = Setting.listSetting(
|
||||||
"index.store.snapshot.cache.excluded_file_types",
|
"index.store.snapshot.cache.excluded_file_types",
|
||||||
Collections.emptyList(),
|
emptyList(),
|
||||||
Function.identity(),
|
Function.identity(),
|
||||||
Setting.Property.IndexScope,
|
Setting.Property.IndexScope,
|
||||||
Setting.Property.NodeScope
|
Setting.Property.NodeScope
|
||||||
|
@ -151,19 +157,21 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Rep
|
||||||
@Override
|
@Override
|
||||||
public List<Setting<?>> getSettings() {
|
public List<Setting<?>> getSettings() {
|
||||||
if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
||||||
return List.of(
|
return unmodifiableList(
|
||||||
SNAPSHOT_REPOSITORY_SETTING,
|
asList(
|
||||||
SNAPSHOT_SNAPSHOT_NAME_SETTING,
|
SNAPSHOT_REPOSITORY_SETTING,
|
||||||
SNAPSHOT_SNAPSHOT_ID_SETTING,
|
SNAPSHOT_SNAPSHOT_NAME_SETTING,
|
||||||
SNAPSHOT_INDEX_ID_SETTING,
|
SNAPSHOT_SNAPSHOT_ID_SETTING,
|
||||||
SNAPSHOT_CACHE_ENABLED_SETTING,
|
SNAPSHOT_INDEX_ID_SETTING,
|
||||||
SNAPSHOT_CACHE_EXCLUDED_FILE_TYPES_SETTING,
|
SNAPSHOT_CACHE_ENABLED_SETTING,
|
||||||
SNAPSHOT_UNCACHED_CHUNK_SIZE_SETTING,
|
SNAPSHOT_CACHE_EXCLUDED_FILE_TYPES_SETTING,
|
||||||
CacheService.SNAPSHOT_CACHE_SIZE_SETTING,
|
SNAPSHOT_UNCACHED_CHUNK_SIZE_SETTING,
|
||||||
CacheService.SNAPSHOT_CACHE_RANGE_SIZE_SETTING
|
CacheService.SNAPSHOT_CACHE_SIZE_SETTING,
|
||||||
|
CacheService.SNAPSHOT_CACHE_RANGE_SIZE_SETTING
|
||||||
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return List.of();
|
return emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,9 +191,9 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Rep
|
||||||
if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
||||||
final CacheService cacheService = new CacheService(settings);
|
final CacheService cacheService = new CacheService(settings);
|
||||||
this.cacheService.set(cacheService);
|
this.cacheService.set(cacheService);
|
||||||
return List.of(cacheService);
|
return singletonList(cacheService);
|
||||||
} else {
|
} else {
|
||||||
return List.of();
|
return emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +213,7 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Rep
|
||||||
@Override
|
@Override
|
||||||
public Map<String, DirectoryFactory> getDirectoryFactories() {
|
public Map<String, DirectoryFactory> getDirectoryFactories() {
|
||||||
if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
||||||
return Map.of(SNAPSHOT_DIRECTORY_FACTORY_KEY, (indexSettings, shardPath) -> {
|
return singletonMap(SNAPSHOT_DIRECTORY_FACTORY_KEY, (indexSettings, shardPath) -> {
|
||||||
final RepositoriesService repositories = repositoriesService.get();
|
final RepositoriesService repositories = repositoriesService.get();
|
||||||
assert repositories != null;
|
assert repositories != null;
|
||||||
final CacheService cache = cacheService.get();
|
final CacheService cache = cacheService.get();
|
||||||
|
@ -213,7 +221,7 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Rep
|
||||||
return SearchableSnapshotDirectory.create(repositories, cache, indexSettings, shardPath, System::nanoTime);
|
return SearchableSnapshotDirectory.create(repositories, cache, indexSettings, shardPath, System::nanoTime);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return Map.of();
|
return emptyMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,13 +238,13 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Rep
|
||||||
@Override
|
@Override
|
||||||
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
|
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
|
||||||
if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
||||||
return List.of(
|
return org.elasticsearch.common.collect.List.of(
|
||||||
new ActionHandler<>(SearchableSnapshotsStatsAction.INSTANCE, TransportSearchableSnapshotsStatsAction.class),
|
new ActionHandler<>(SearchableSnapshotsStatsAction.INSTANCE, TransportSearchableSnapshotsStatsAction.class),
|
||||||
new ActionHandler<>(ClearSearchableSnapshotsCacheAction.INSTANCE, TransportClearSearchableSnapshotsCacheAction.class),
|
new ActionHandler<>(ClearSearchableSnapshotsCacheAction.INSTANCE, TransportClearSearchableSnapshotsCacheAction.class),
|
||||||
new ActionHandler<>(MountSearchableSnapshotAction.INSTANCE, TransportMountSearchableSnapshotAction.class)
|
new ActionHandler<>(MountSearchableSnapshotAction.INSTANCE, TransportMountSearchableSnapshotAction.class)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return List.of();
|
return emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,13 +258,15 @@ public class SearchableSnapshots extends Plugin implements IndexStorePlugin, Rep
|
||||||
Supplier<DiscoveryNodes> nodesInCluster
|
Supplier<DiscoveryNodes> nodesInCluster
|
||||||
) {
|
) {
|
||||||
if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
if (SEARCHABLE_SNAPSHOTS_FEATURE_ENABLED) {
|
||||||
return List.of(
|
return unmodifiableList(
|
||||||
new RestSearchableSnapshotsStatsAction(),
|
asList(
|
||||||
new RestClearSearchableSnapshotsCacheAction(),
|
new RestSearchableSnapshotsStatsAction(),
|
||||||
new RestMountSearchableSnapshotAction()
|
new RestClearSearchableSnapshotsCacheAction(),
|
||||||
|
new RestMountSearchableSnapshotAction()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return List.of();
|
return emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.elasticsearch.repositories.RepositoriesService;
|
||||||
import org.elasticsearch.repositories.Repository;
|
import org.elasticsearch.repositories.Repository;
|
||||||
import org.elasticsearch.repositories.RepositoryData;
|
import org.elasticsearch.repositories.RepositoryData;
|
||||||
import org.elasticsearch.snapshots.SnapshotId;
|
import org.elasticsearch.snapshots.SnapshotId;
|
||||||
import org.elasticsearch.tasks.Task;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
||||||
|
@ -121,7 +120,6 @@ public class TransportMountSearchableSnapshotAction extends TransportMasterNodeA
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void masterOperation(
|
protected void masterOperation(
|
||||||
Task task,
|
|
||||||
final MountSearchableSnapshotRequest request,
|
final MountSearchableSnapshotRequest request,
|
||||||
final ClusterState state,
|
final ClusterState state,
|
||||||
final ActionListener<RestoreSnapshotResponse> listener
|
final ActionListener<RestoreSnapshotResponse> listener
|
||||||
|
@ -148,7 +146,7 @@ public class TransportMountSearchableSnapshotAction extends TransportMasterNodeA
|
||||||
.stream()
|
.stream()
|
||||||
.filter(s -> snapName.equals(s.getName()))
|
.filter(s -> snapName.equals(s.getName()))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
if (matchingSnapshotId.isEmpty()) {
|
if (matchingSnapshotId.isPresent() == false) {
|
||||||
throw new ElasticsearchException("snapshot [" + snapName + "] not found in repository [" + repoName + "]");
|
throw new ElasticsearchException("snapshot [" + snapName + "] not found in repository [" + repoName + "]");
|
||||||
}
|
}
|
||||||
final SnapshotId snapshotId = matchingSnapshotId.get();
|
final SnapshotId snapshotId = matchingSnapshotId.get();
|
||||||
|
|
|
@ -16,13 +16,18 @@ import org.elasticsearch.xpack.searchablesnapshots.action.ClearSearchableSnapsho
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
import static java.util.Collections.unmodifiableList;
|
||||||
|
|
||||||
public class RestClearSearchableSnapshotsCacheAction extends BaseRestHandler {
|
public class RestClearSearchableSnapshotsCacheAction extends BaseRestHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Route> routes() {
|
public List<Route> routes() {
|
||||||
return List.of(
|
return unmodifiableList(
|
||||||
new Route(RestRequest.Method.POST, "/_searchable_snapshots/cache/clear"),
|
asList(
|
||||||
new Route(RestRequest.Method.POST, "/{index}/_searchable_snapshots/cache/clear")
|
new Route(RestRequest.Method.POST, "/_searchable_snapshots/cache/clear"),
|
||||||
|
new Route(RestRequest.Method.POST, "/{index}/_searchable_snapshots/cache/clear")
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,18 @@ import org.elasticsearch.xpack.searchablesnapshots.action.SearchableSnapshotsSta
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
import static java.util.Collections.unmodifiableList;
|
||||||
|
|
||||||
public class RestSearchableSnapshotsStatsAction extends BaseRestHandler {
|
public class RestSearchableSnapshotsStatsAction extends BaseRestHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Route> routes() {
|
public List<Route> routes() {
|
||||||
return List.of(
|
return unmodifiableList(
|
||||||
new Route(RestRequest.Method.GET, "/_searchable_snapshots/stats"),
|
asList(
|
||||||
new Route(RestRequest.Method.GET, "/{index}/_searchable_snapshots/stats")
|
new Route(RestRequest.Method.GET, "/_searchable_snapshots/stats"),
|
||||||
|
new Route(RestRequest.Method.GET, "/{index}/_searchable_snapshots/stats")
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.xpack.searchablesnapshots.cache.CacheService;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.function.LongSupplier;
|
import java.util.function.LongSupplier;
|
||||||
|
@ -566,7 +567,7 @@ public class SearchableSnapshotDirectoryStatsTests extends ESIndexInputTestCase
|
||||||
final String blobName = randomUnicodeOfLength(10);
|
final String blobName = randomUnicodeOfLength(10);
|
||||||
final BlobContainer blobContainer = singleBlobContainer(blobName, fileContent);
|
final BlobContainer blobContainer = singleBlobContainer(blobName, fileContent);
|
||||||
final StoreFileMetadata metadata = new StoreFileMetadata(fileName, fileContent.length, "_checksum", Version.CURRENT.luceneVersion);
|
final StoreFileMetadata metadata = new StoreFileMetadata(fileName, fileContent.length, "_checksum", Version.CURRENT.luceneVersion);
|
||||||
final List<FileInfo> files = List.of(new FileInfo(blobName, metadata, new ByteSizeValue(fileContent.length)));
|
final List<FileInfo> files = Collections.singletonList(new FileInfo(blobName, metadata, new ByteSizeValue(fileContent.length)));
|
||||||
final BlobStoreIndexShardSnapshot snapshot = new BlobStoreIndexShardSnapshot(snapshotId.getName(), 0L, files, 0L, 0L, 0, 0L);
|
final BlobStoreIndexShardSnapshot snapshot = new BlobStoreIndexShardSnapshot(snapshotId.getName(), 0L, files, 0L, 0L, 0, 0L);
|
||||||
|
|
||||||
try (
|
try (
|
||||||
|
|
|
@ -90,6 +90,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Collections.emptyMap;
|
import static java.util.Collections.emptyMap;
|
||||||
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING;
|
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshots.SNAPSHOT_CACHE_ENABLED_SETTING;
|
||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
@ -153,7 +154,7 @@ public class SearchableSnapshotDirectoryTests extends ESTestCase {
|
||||||
CheckHits.checkEqual(query, snapshotSearcher.search(query, 10).scoreDocs, searcher.search(query, 10).scoreDocs);
|
CheckHits.checkEqual(query, snapshotSearcher.search(query, 10).scoreDocs, searcher.search(query, 10).scoreDocs);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Query query = new TermInSetQuery("text", List.of(new BytesRef("quick"), new BytesRef("lazy")));
|
Query query = new TermInSetQuery("text", asList(new BytesRef("quick"), new BytesRef("lazy")));
|
||||||
assertThat(snapshotSearcher.count(query), equalTo(searcher.count(query)));
|
assertThat(snapshotSearcher.count(query), equalTo(searcher.count(query)));
|
||||||
CheckHits.checkEqual(query, snapshotSearcher.search(query, 10).scoreDocs, searcher.search(query, 10).scoreDocs);
|
CheckHits.checkEqual(query, snapshotSearcher.search(query, 10).scoreDocs, searcher.search(query, 10).scoreDocs);
|
||||||
}
|
}
|
||||||
|
@ -328,7 +329,7 @@ public class SearchableSnapshotDirectoryTests extends ESTestCase {
|
||||||
final IndexWriterConfig indexWriterConfig = newIndexWriterConfig();
|
final IndexWriterConfig indexWriterConfig = newIndexWriterConfig();
|
||||||
try (IndexWriter writer = new IndexWriter(directory, indexWriterConfig)) {
|
try (IndexWriter writer = new IndexWriter(directory, indexWriterConfig)) {
|
||||||
final int nbDocs = scaledRandomIntBetween(0, 1_000);
|
final int nbDocs = scaledRandomIntBetween(0, 1_000);
|
||||||
final List<String> words = List.of("the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog");
|
final List<String> words = asList("the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog");
|
||||||
for (int i = 0; i < nbDocs; i++) {
|
for (int i = 0; i < nbDocs; i++) {
|
||||||
final Document doc = new Document();
|
final Document doc = new Document();
|
||||||
doc.add(new StringField("id", "" + i, Field.Store.YES));
|
doc.add(new StringField("id", "" + i, Field.Store.YES));
|
||||||
|
@ -460,7 +461,7 @@ public class SearchableSnapshotDirectoryTests extends ESTestCase {
|
||||||
|
|
||||||
private void testIndexInputs(final CheckedBiConsumer<IndexInput, IndexInput, Exception> consumer) throws Exception {
|
private void testIndexInputs(final CheckedBiConsumer<IndexInput, IndexInput, Exception> consumer) throws Exception {
|
||||||
testDirectories((directory, snapshotDirectory) -> {
|
testDirectories((directory, snapshotDirectory) -> {
|
||||||
for (String fileName : randomSubsetOf(Arrays.asList(snapshotDirectory.listAll()))) {
|
for (String fileName : randomSubsetOf(asList(snapshotDirectory.listAll()))) {
|
||||||
final IOContext context = newIOContext(random());
|
final IOContext context = newIOContext(random());
|
||||||
try (IndexInput indexInput = directory.openInput(fileName, context)) {
|
try (IndexInput indexInput = directory.openInput(fileName, context)) {
|
||||||
final List<Closeable> closeables = new ArrayList<>();
|
final List<Closeable> closeables = new ArrayList<>();
|
||||||
|
|
|
@ -27,10 +27,10 @@ import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.atomic.LongAdder;
|
import java.util.concurrent.atomic.LongAdder;
|
||||||
|
|
||||||
|
import static java.util.Collections.singletonList;
|
||||||
import static org.elasticsearch.index.store.cache.TestUtils.createCacheService;
|
import static org.elasticsearch.index.store.cache.TestUtils.createCacheService;
|
||||||
import static org.elasticsearch.index.store.cache.TestUtils.singleBlobContainer;
|
import static org.elasticsearch.index.store.cache.TestUtils.singleBlobContainer;
|
||||||
import static org.elasticsearch.index.store.cache.TestUtils.singleSplitBlobContainer;
|
import static org.elasticsearch.index.store.cache.TestUtils.singleSplitBlobContainer;
|
||||||
|
@ -61,7 +61,7 @@ public class CachedBlobContainerIndexInputTests extends ESIndexInputTestCase {
|
||||||
final BlobStoreIndexShardSnapshot snapshot = new BlobStoreIndexShardSnapshot(
|
final BlobStoreIndexShardSnapshot snapshot = new BlobStoreIndexShardSnapshot(
|
||||||
snapshotId.getName(),
|
snapshotId.getName(),
|
||||||
0L,
|
0L,
|
||||||
List.of(new BlobStoreIndexShardSnapshot.FileInfo(blobName, metaData, new ByteSizeValue(partSize))),
|
singletonList(new BlobStoreIndexShardSnapshot.FileInfo(blobName, metaData, new ByteSizeValue(partSize))),
|
||||||
0L,
|
0L,
|
||||||
0L,
|
0L,
|
||||||
0,
|
0,
|
||||||
|
@ -136,7 +136,7 @@ public class CachedBlobContainerIndexInputTests extends ESIndexInputTestCase {
|
||||||
final BlobStoreIndexShardSnapshot snapshot = new BlobStoreIndexShardSnapshot(
|
final BlobStoreIndexShardSnapshot snapshot = new BlobStoreIndexShardSnapshot(
|
||||||
snapshotId.getName(),
|
snapshotId.getName(),
|
||||||
0L,
|
0L,
|
||||||
List.of(new BlobStoreIndexShardSnapshot.FileInfo(blobName, metadata, new ByteSizeValue(input.length + 1))),
|
singletonList(new BlobStoreIndexShardSnapshot.FileInfo(blobName, metadata, new ByteSizeValue(input.length + 1))),
|
||||||
0L,
|
0L,
|
||||||
0L,
|
0L,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -195,7 +195,7 @@ public class SparseFileTrackerTests extends ESTestCase {
|
||||||
final AtomicBoolean listenerCalled = new AtomicBoolean();
|
final AtomicBoolean listenerCalled = new AtomicBoolean();
|
||||||
listenerCalledConsumer.accept(listenerCalled);
|
listenerCalledConsumer.accept(listenerCalled);
|
||||||
|
|
||||||
final List<SparseFileTracker.Gap> gaps = sparseFileTracker.waitForRange(start, end, new ActionListener<>() {
|
final List<SparseFileTracker.Gap> gaps = sparseFileTracker.waitForRange(start, end, new ActionListener<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Void aVoid) {
|
public void onResponse(Void aVoid) {
|
||||||
for (long i = start; i < end; i++) {
|
for (long i = start; i < end; i++) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import static com.carrotsearch.randomizedtesting.generators.RandomNumbers.randomIntBetween;
|
import static com.carrotsearch.randomizedtesting.generators.RandomNumbers.randomIntBetween;
|
||||||
import static com.carrotsearch.randomizedtesting.generators.RandomPicks.randomFrom;
|
import static com.carrotsearch.randomizedtesting.generators.RandomPicks.randomFrom;
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ public final class TestUtils {
|
||||||
public static CacheService createCacheService(final Random random) {
|
public static CacheService createCacheService(final Random random) {
|
||||||
final ByteSizeValue cacheSize = new ByteSizeValue(
|
final ByteSizeValue cacheSize = new ByteSizeValue(
|
||||||
randomIntBetween(random, 1, 100),
|
randomIntBetween(random, 1, 100),
|
||||||
randomFrom(random, List.of(ByteSizeUnit.BYTES, ByteSizeUnit.KB, ByteSizeUnit.MB, ByteSizeUnit.GB))
|
randomFrom(random, asList(ByteSizeUnit.BYTES, ByteSizeUnit.KB, ByteSizeUnit.MB, ByteSizeUnit.GB))
|
||||||
);
|
);
|
||||||
return new CacheService(cacheSize, randomCacheRangeSize(random));
|
return new CacheService(cacheSize, randomCacheRangeSize(random));
|
||||||
}
|
}
|
||||||
|
@ -42,7 +43,7 @@ public final class TestUtils {
|
||||||
public static ByteSizeValue randomCacheRangeSize(final Random random) {
|
public static ByteSizeValue randomCacheRangeSize(final Random random) {
|
||||||
return new ByteSizeValue(
|
return new ByteSizeValue(
|
||||||
randomIntBetween(random, 1, 100),
|
randomIntBetween(random, 1, 100),
|
||||||
randomFrom(random, List.of(ByteSizeUnit.BYTES, ByteSizeUnit.KB, ByteSizeUnit.MB))
|
randomFrom(random, asList(ByteSizeUnit.BYTES, ByteSizeUnit.KB, ByteSizeUnit.MB))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,9 @@ import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin;
|
||||||
import org.elasticsearch.xpack.searchablesnapshots.cache.CacheService;
|
import org.elasticsearch.xpack.searchablesnapshots.cache.CacheService;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
import static java.util.Collections.unmodifiableList;
|
||||||
|
|
||||||
public abstract class BaseSearchableSnapshotsIntegTestCase extends ESIntegTestCase {
|
public abstract class BaseSearchableSnapshotsIntegTestCase extends ESIntegTestCase {
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,7 +46,7 @@ public abstract class BaseSearchableSnapshotsIntegTestCase extends ESIntegTestCa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||||
return List.of(SearchableSnapshots.class, LocalStateCompositeXPackPlugin.class);
|
return unmodifiableList(asList(SearchableSnapshots.class, LocalStateCompositeXPackPlugin.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT
|
||||||
createIndex(indexName);
|
createIndex(indexName);
|
||||||
final List<IndexRequestBuilder> indexRequestBuilders = new ArrayList<>();
|
final List<IndexRequestBuilder> indexRequestBuilders = new ArrayList<>();
|
||||||
for (int i = between(10, 10_000); i >= 0; i--) {
|
for (int i = between(10, 10_000); i >= 0; i--) {
|
||||||
indexRequestBuilders.add(client().prepareIndex(indexName).setSource("foo", randomBoolean() ? "bar" : "baz"));
|
indexRequestBuilders.add(client().prepareIndex(indexName, "_doc").setSource("foo", randomBoolean() ? "bar" : "baz"));
|
||||||
}
|
}
|
||||||
// TODO NORELEASE no dummy docs since that includes deletes, yet we always copy the .liv file in peer recovery
|
// TODO NORELEASE no dummy docs since that includes deletes, yet we always copy the .liv file in peer recovery
|
||||||
indexRandom(true, false, indexRequestBuilders);
|
indexRandom(true, false, indexRequestBuilders);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue