Skip to content

Commit

Permalink
Remove endpoint for freezing indices (#78918)
Browse files Browse the repository at this point in the history
  • Loading branch information
danhermann committed Oct 26, 2021
1 parent da25a35 commit 4a36d5c
Show file tree
Hide file tree
Showing 35 changed files with 205 additions and 770 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.core.ShardsAcknowledgedResponse;
import org.elasticsearch.client.indices.AnalyzeRequest;
import org.elasticsearch.client.indices.AnalyzeResponse;
import org.elasticsearch.client.indices.CloseIndexRequest;
Expand All @@ -58,7 +57,6 @@
import org.elasticsearch.client.indices.DeleteAliasRequest;
import org.elasticsearch.client.indices.DeleteComposableIndexTemplateRequest;
import org.elasticsearch.client.indices.DeleteDataStreamRequest;
import org.elasticsearch.client.indices.FreezeIndexRequest;
import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest;
import org.elasticsearch.client.indices.GetComposableIndexTemplatesResponse;
import org.elasticsearch.client.indices.GetDataStreamRequest;
Expand All @@ -80,7 +78,6 @@
import org.elasticsearch.client.indices.ReloadAnalyzersResponse;
import org.elasticsearch.client.indices.SimulateIndexTemplateRequest;
import org.elasticsearch.client.indices.SimulateIndexTemplateResponse;
import org.elasticsearch.client.indices.UnfreezeIndexRequest;
import org.elasticsearch.client.indices.rollover.RolloverRequest;
import org.elasticsearch.client.indices.rollover.RolloverResponse;
import org.elasticsearch.cluster.metadata.AliasMetadata;
Expand All @@ -95,16 +92,16 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.xcontent.json.JsonXContent;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.xcontent.json.JsonXContent;

import java.io.IOException;
import java.util.Arrays;
Expand Down Expand Up @@ -1535,24 +1532,6 @@ public void testAnalyze() throws Exception {
assertNotNull(detailsResponse.detail());
}

public void testFreezeAndUnfreeze() throws IOException {
createIndex("test", Settings.EMPTY);
RestHighLevelClient client = highLevelClient();

final RequestOptions freezeIndexOptions = RequestOptions.DEFAULT.toBuilder()
.setWarningsHandler(warnings -> List.of(FROZEN_INDICES_DEPRECATION_WARNING).equals(warnings) == false).build();

ShardsAcknowledgedResponse freeze = execute(new FreezeIndexRequest("test"), client.indices()::freeze,
client.indices()::freezeAsync, freezeIndexOptions);
assertTrue(freeze.isShardsAcknowledged());
assertTrue(freeze.isAcknowledged());

ShardsAcknowledgedResponse unfreeze = execute(new UnfreezeIndexRequest("test"), client.indices()::unfreeze,
client.indices()::unfreezeAsync, freezeIndexOptions);
assertTrue(unfreeze.isShardsAcknowledged());
assertTrue(unfreeze.isAcknowledged());
}

public void testReloadAnalyzer() throws IOException {
createIndex("test", Settings.EMPTY);
RestHighLevelClient client = highLevelClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,21 @@
import org.elasticsearch.client.indices.DeleteAliasRequest;
import org.elasticsearch.client.indices.DeleteComposableIndexTemplateRequest;
import org.elasticsearch.client.indices.DetailAnalyzeResponse;
import org.elasticsearch.client.indices.FreezeIndexRequest;
import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest;
import org.elasticsearch.client.indices.GetComposableIndexTemplatesResponse;
import org.elasticsearch.client.indices.GetFieldMappingsRequest;
import org.elasticsearch.client.indices.GetFieldMappingsResponse;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;
import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest;
import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
import org.elasticsearch.client.indices.GetIndexTemplatesResponse;
import org.elasticsearch.client.indices.GetComposableIndexTemplatesResponse;
import org.elasticsearch.client.indices.GetMappingsRequest;
import org.elasticsearch.client.indices.GetMappingsResponse;
import org.elasticsearch.client.indices.IndexTemplateMetadata;
import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
import org.elasticsearch.client.indices.PutComponentTemplateRequest;
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
import org.elasticsearch.client.indices.PutComposableIndexTemplateRequest;
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
import org.elasticsearch.client.indices.PutMappingRequest;
import org.elasticsearch.client.indices.ReloadAnalyzersRequest;
import org.elasticsearch.client.indices.ReloadAnalyzersResponse;
Expand All @@ -90,13 +89,13 @@
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
import org.elasticsearch.xcontent.XContentType;

import java.io.IOException;
import java.util.Collections;
Expand All @@ -108,7 +107,6 @@
import java.util.concurrent.TimeUnit;

import static org.elasticsearch.client.IndicesClientIT.FROZEN_INDICES_DEPRECATION_WARNING;
import static org.elasticsearch.client.IndicesClientIT.IGNORE_THROTTLED_DEPRECATION_WARNING;
import static org.elasticsearch.client.IndicesClientIT.LEGACY_TEMPLATE_OPTIONS;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -2874,89 +2872,6 @@ public void onFailure(Exception e) {

}

public void testFreezeIndex() throws Exception {
RestHighLevelClient client = highLevelClient();

{
CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"), RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());
}

{
// tag::freeze-index-request
FreezeIndexRequest request = new FreezeIndexRequest("index"); // <1>
// end::freeze-index-request

// tag::freeze-index-request-timeout
request.setTimeout(TimeValue.timeValueMinutes(2)); // <1>
// end::freeze-index-request-timeout
// tag::freeze-index-request-masterTimeout
request.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1>
// end::freeze-index-request-masterTimeout
// tag::freeze-index-request-waitForActiveShards
request.setWaitForActiveShards(ActiveShardCount.DEFAULT); // <1>
// end::freeze-index-request-waitForActiveShards

// tag::freeze-index-request-indicesOptions
request.setIndicesOptions(IndicesOptions.strictExpandOpen()); // <1>
// end::freeze-index-request-indicesOptions

final RequestOptions freezeIndexOptions = RequestOptions.DEFAULT.toBuilder()
.setWarningsHandler(
warnings -> List.of(FROZEN_INDICES_DEPRECATION_WARNING, IGNORE_THROTTLED_DEPRECATION_WARNING).equals(warnings) == false
).build();

// tag::freeze-index-execute
ShardsAcknowledgedResponse openIndexResponse = client.indices().freeze(request, freezeIndexOptions);
// end::freeze-index-execute

// tag::freeze-index-response
boolean acknowledged = openIndexResponse.isAcknowledged(); // <1>
boolean shardsAcked = openIndexResponse.isShardsAcknowledged(); // <2>
// end::freeze-index-response
assertTrue(acknowledged);
assertTrue(shardsAcked);

// tag::freeze-index-execute-listener
ActionListener<ShardsAcknowledgedResponse> listener =
new ActionListener<ShardsAcknowledgedResponse>() {
@Override
public void onResponse(ShardsAcknowledgedResponse freezeIndexResponse) {
// <1>
}

@Override
public void onFailure(Exception e) {
// <2>
}
};
// end::freeze-index-execute-listener

// Replace the empty listener by a blocking listener in test
final CountDownLatch latch = new CountDownLatch(1);
listener = new LatchedActionListener<>(listener, latch);

// tag::freeze-index-execute-async
client.indices().freezeAsync(request, RequestOptions.DEFAULT, listener); // <1>
// end::freeze-index-execute-async

assertTrue(latch.await(30L, TimeUnit.SECONDS));
}

{
// tag::freeze-index-notfound
try {
FreezeIndexRequest request = new FreezeIndexRequest("does_not_exist");
client.indices().freeze(request, RequestOptions.DEFAULT);
} catch (ElasticsearchException exception) {
if (exception.status() == RestStatus.BAD_REQUEST) {
// <1>
}
}
// end::freeze-index-notfound
}
}

public void testUnfreezeIndex() throws Exception {
RestHighLevelClient client = highLevelClient();

Expand Down
8 changes: 8 additions & 0 deletions docs/java-rest/redirects.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,11 @@ See <<java-rest-high-start-transform>>.
=== Stop {transform} API

See <<java-rest-high-stop-transform>>.

[role="exclude",id="java-rest-high-freeze-index"]
=== Freeze index API

The freeze index API was removed in 8.0. Frozen indices are no longer useful due
to
https://www.elastic.co/blog/significantly-decrease-your-elasticsearch-heap-memory-usage[recent
improvements in heap memory usage].
1 change: 0 additions & 1 deletion docs/reference/data-streams/data-streams.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ such as:

* <<indices-clone-index,Clone>>
* <<indices-delete-index,Delete>>
* <<freeze-index-api,Freeze>>
* <<indices-shrink-index,Shrink>>
* <<indices-split-index,Split>>

Expand Down
34 changes: 0 additions & 34 deletions docs/reference/ilm/actions/ilm-freeze.asciidoc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ index>> to the frozen tier. In other phases, the action mounts a
<<fully-mounted,fully mounted index>> to the corresponding data tier.

If the `searchable_snapshot` action is used in the hot phase the subsequent
phases cannot include the `shrink`, `forcemerge`, or `freeze` actions.
phases cannot include the `shrink` or `forcemerge` actions.

This action cannot be performed on a data stream's write index. Attempts to do
so will fail. To convert the index to a searchable snapshot, first
Expand Down
4 changes: 0 additions & 4 deletions docs/reference/ilm/ilm-actions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ Permanently remove the index.
Reduce the number of index segments and purge deleted documents.
Makes the index read-only.

<<ilm-freeze,Freeze>>::
Freeze the index to minimize its memory footprint.

<<ilm-migrate,Migrate>>::
Move the index shards to the <<data-tiers, data tier>> that corresponds
to the current {ilm-init} phase.
Expand Down Expand Up @@ -49,7 +46,6 @@ Ensure that a snapshot exists before deleting the index.
include::actions/ilm-allocate.asciidoc[]
include::actions/ilm-delete.asciidoc[]
include::actions/ilm-forcemerge.asciidoc[]
include::actions/ilm-freeze.asciidoc[]
include::actions/ilm-migrate.asciidoc[]
include::actions/ilm-readonly.asciidoc[]
include::actions/ilm-rollover.asciidoc[]
Expand Down
1 change: 0 additions & 1 deletion docs/reference/ilm/ilm-index-lifecycle.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ actions in the order listed.
- <<ilm-searchable-snapshot, Searchable Snapshot>>
- <<ilm-allocate,Allocate>>
- <<ilm-migrate,Migrate>>
- <<ilm-freeze,Freeze>>
* Frozen
- <<ilm-searchable-snapshot, Searchable Snapshot>>
* Delete
Expand Down
11 changes: 5 additions & 6 deletions docs/reference/ilm/ilm-overview.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<titleabbrev>Overview</titleabbrev>
++++

You can create and apply {ilm-cap} ({ilm-init}) policies to automatically manage your indices
according to your performance, resiliency, and retention requirements.
You can create and apply {ilm-cap} ({ilm-init}) policies to automatically manage your indices
according to your performance, resiliency, and retention requirements.

Index lifecycle policies can trigger actions such as:

Expand All @@ -17,7 +17,6 @@ size, number of docs, or age.
* **Shrink**: Reduces the number of primary shards in an index.
* **Force merge**: Triggers a <<indices-forcemerge,force merge>> to reduce the
number of segments in an index's shards.
* **Freeze**: <<freeze-index-api, Freezes>> an index and makes it read-only.
* **Delete**: Permanently remove an index, including all of its data and
metadata.

Expand Down Expand Up @@ -48,9 +47,9 @@ hardware.

[IMPORTANT]
===========================
To use {ilm-init}, all nodes in a cluster must run the same version.
Although it might be possible to create and apply policies in a mixed-version cluster,
To use {ilm-init}, all nodes in a cluster must run the same version.
Although it might be possible to create and apply policies in a mixed-version cluster,
there is no guarantee they will work as intended.
Attempting to use a policy that contains actions that aren't
supported on all nodes in a cluster will cause errors.
supported on all nodes in a cluster will cause errors.
===========================
8 changes: 3 additions & 5 deletions docs/reference/indices.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ index settings, aliases, mappings, and index templates.
* <<indices-split-index>>
* <<indices-clone-index>>
* <<indices-rollover-index>>
* <<freeze-index-api>>
* <<unfreeze-index-api>>
* <<indices-resolve-index-api>>

Expand Down Expand Up @@ -53,9 +52,9 @@ index settings, aliases, mappings, and index templates.
=== Index templates:

Index templates automatically apply settings, mappings, and aliases to new indices.
They are most often used to configure rolling indices for time series data to
ensure that each new index has the same configuration as the previous one.
The index template associated with a data stream configures its backing indices.
They are most often used to configure rolling indices for time series data to
ensure that each new index has the same configuration as the previous one.
The index template associated with a data stream configures its backing indices.
For more information, see <<index-templates, Index Templates>>.

* <<indices-put-template>>
Expand Down Expand Up @@ -113,7 +112,6 @@ include::indices/indices-exists.asciidoc[]
include::indices/field-usage-stats.asciidoc[]
include::indices/flush.asciidoc[]
include::indices/forcemerge.asciidoc[]
include::indices/apis/freeze.asciidoc[]
include::indices/get-alias.asciidoc[]
include::indices/get-component-template.asciidoc[]
include::indices/get-field-mapping.asciidoc[]
Expand Down

0 comments on commit 4a36d5c

Please sign in to comment.