Skip to content

Commit b1b7bf3

Browse files
authored
Make data streams a basic licensed feature. (#59392)
Backport of #59293 to 7.x branch. * Create new data-stream xpack module. * Move TimestampFieldMapper to the new module, this results in storing a composable index template with data stream definition only to work with default distribution. This way data streams can only be used with default distribution, since a data stream can currently only be created if a matching composable index template exists with a data stream definition. * Renamed `_timestamp` meta field mapper to `_data_stream_timestamp` meta field mapper. * Add logic to put composable index template api to fail if `_data_stream_timestamp` meta field mapper isn't registered. So that a more understandable error is returned when attempting to store a template with data stream definition via the oss distribution. In a follow up the data stream transport and rest actions can be moved to the xpack data-stream module.
1 parent cc9166a commit b1b7bf3

File tree

63 files changed

+2542
-1743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2542
-1743
lines changed

modules/rank-eval/src/test/resources/rest-api-spec/test/rank_eval/50_data_streams.yml

Lines changed: 0 additions & 100 deletions
This file was deleted.

qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,19 @@
1919

2020
package org.elasticsearch.upgrades;
2121

22-
import org.apache.http.entity.ContentType;
23-
import org.apache.http.entity.StringEntity;
2422
import org.apache.http.util.EntityUtils;
2523
import org.elasticsearch.Version;
2624
import org.elasticsearch.client.Request;
2725
import org.elasticsearch.client.Response;
2826
import org.elasticsearch.client.ResponseException;
2927
import org.elasticsearch.client.RestClient;
3028
import org.elasticsearch.client.WarningFailureException;
31-
import org.elasticsearch.cluster.metadata.DataStream;
3229
import org.elasticsearch.cluster.metadata.IndexMetadata;
3330
import org.elasticsearch.cluster.metadata.MetadataIndexStateService;
34-
import org.elasticsearch.cluster.metadata.Template;
3531
import org.elasticsearch.common.Booleans;
3632
import org.elasticsearch.common.CheckedFunction;
3733
import org.elasticsearch.common.Strings;
38-
import org.elasticsearch.common.compress.CompressedXContent;
3934
import org.elasticsearch.common.settings.Settings;
40-
import org.elasticsearch.common.xcontent.ToXContent;
4135
import org.elasticsearch.common.xcontent.XContentBuilder;
4236
import org.elasticsearch.common.xcontent.json.JsonXContent;
4337
import org.elasticsearch.common.xcontent.support.XContentMapValues;
@@ -56,7 +50,6 @@
5650
import java.util.ArrayList;
5751
import java.util.Base64;
5852
import java.util.Collection;
59-
import java.util.Date;
6053
import java.util.HashMap;
6154
import java.util.HashSet;
6255
import java.util.List;
@@ -1464,55 +1457,12 @@ public void testRecoveryWithTranslogRetentionDisabled() throws Exception {
14641457
assertTotalHits(numDocs, entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_search"))));
14651458
}
14661459

1467-
@SuppressWarnings("unchecked")
1468-
public void testDataStreams() throws Exception {
1469-
assumeTrue("no data streams in versions before " + Version.V_7_9_0, getOldClusterVersion().onOrAfter(Version.V_7_9_0));
1470-
if (isRunningAgainstOldCluster()) {
1471-
String mapping = "{\n" +
1472-
" \"properties\": {\n" +
1473-
" \"@timestamp\": {\n" +
1474-
" \"type\": \"date\"\n" +
1475-
" }\n" +
1476-
" }\n" +
1477-
" }";
1478-
Template template = new Template(null, new CompressedXContent(mapping), null);
1479-
createComposableTemplate(client(), "dst", "ds", template);
1480-
1481-
Request indexRequest = new Request("POST", "/ds/_doc/1?op_type=create&refresh");
1482-
XContentBuilder builder = JsonXContent.contentBuilder().startObject()
1483-
.field("f", "v")
1484-
.field("@timestamp", new Date())
1485-
.endObject();
1486-
indexRequest.setJsonEntity(Strings.toString(builder));
1487-
assertOK(client().performRequest(indexRequest));
1488-
}
1489-
1490-
Request getDataStream = new Request("GET", "/_data_stream/ds");
1491-
Response response = client().performRequest(getDataStream);
1492-
assertOK(response);
1493-
List<Object> dataStreams = (List<Object>) entityAsMap(response).get("data_streams");
1494-
assertEquals(1, dataStreams.size());
1495-
Map<String, Object> ds = (Map<String, Object>) dataStreams.get(0);
1496-
List<Map<String, String>> indices = (List<Map<String, String>>) ds.get("indices");
1497-
assertEquals("ds", ds.get("name"));
1498-
assertEquals(1, indices.size());
1499-
assertEquals(DataStream.getDefaultBackingIndexName("ds", 1), indices.get(0).get("index_name"));
1500-
assertTotalHits(1, entityAsMap(client().performRequest(new Request("GET", "/ds/_search"))));
1460+
public static void assertNumHits(String index, int numHits, int totalShards) throws IOException {
1461+
Map<String, Object> resp = entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_search")));
1462+
assertNoFailures(resp);
1463+
assertThat(XContentMapValues.extractValue("_shards.total", resp), equalTo(totalShards));
1464+
assertThat(XContentMapValues.extractValue("_shards.successful", resp), equalTo(totalShards));
1465+
assertThat(extractTotalHits(resp), equalTo(numHits));
15011466
}
15021467

1503-
private static void createComposableTemplate(RestClient client, String templateName, String indexPattern, Template template)
1504-
throws IOException {
1505-
XContentBuilder builder = jsonBuilder();
1506-
template.toXContent(builder, ToXContent.EMPTY_PARAMS);
1507-
StringEntity templateJSON = new StringEntity(
1508-
String.format(Locale.ROOT, "{\n" +
1509-
" \"index_patterns\": \"%s\",\n" +
1510-
" \"data_stream\": { \"timestamp_field\": \"@timestamp\" },\n" +
1511-
" \"template\": %s\n" +
1512-
"}", indexPattern, Strings.toString(builder)),
1513-
ContentType.APPLICATION_JSON);
1514-
Request createIndexTemplateRequest = new Request("PUT", "_index_template/" + templateName);
1515-
createIndexTemplateRequest.setEntity(templateJSON);
1516-
client.performRequest(createIndexTemplateRequest);
1517-
}
15181468
}

qa/multi-cluster-search/src/test/resources/rest-api-spec/test/remote_cluster/10_basic.yml

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,6 @@
33
- skip:
44
features: allowed_warnings
55

6-
- do:
7-
allowed_warnings:
8-
- "index template [my-template1] has index patterns [simple-data-stream1] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template1] will take precedence during new index creation"
9-
indices.put_index_template:
10-
name: my-template1
11-
body:
12-
index_patterns: [simple-data-stream1]
13-
template:
14-
mappings:
15-
properties:
16-
'@timestamp':
17-
type: date
18-
data_stream:
19-
timestamp_field: '@timestamp'
20-
- do:
21-
allowed_warnings:
22-
- "index template [my-template2] has index patterns [simple-data-stream2] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template2] will take precedence during new index creation"
23-
indices.put_index_template:
24-
name: my-template2
25-
body:
26-
index_patterns: [simple-data-stream2]
27-
template:
28-
mappings:
29-
properties:
30-
'@timestamp':
31-
type: date
32-
data_stream:
33-
timestamp_field: '@timestamp'
34-
35-
- do:
36-
indices.create_data_stream:
37-
name: simple-data-stream1
38-
39-
- do:
40-
indices.create_data_stream:
41-
name: simple-data-stream2
42-
43-
- do:
44-
indices.rollover:
45-
alias: "simple-data-stream2"
46-
476
- do:
487
indices.create:
498
index: single_doc_index
@@ -123,18 +82,6 @@
12382
nested2:
12483
type: keyword
12584
doc_values: false
126-
127-
- do:
128-
indices.create:
129-
index: closed_index
130-
body:
131-
aliases:
132-
aliased_closed_index: {}
133-
134-
- do:
135-
indices.close:
136-
index: closed_index
137-
13885
- do:
13986
indices.create:
14087
index: test_index

rest-api-spec/src/main/resources/rest-api-spec/test/indices.clone/10_basic.yml

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -109,47 +109,3 @@ setup:
109109
settings:
110110
index.number_of_replicas: 0
111111
index.number_of_shards: 6
112-
113-
---
114-
"Prohibit clone on data stream's write index":
115-
- skip:
116-
version: " - 7.8.99"
117-
reason: "data streams only supported in 7.9+"
118-
features: allowed_warnings
119-
120-
- do:
121-
allowed_warnings:
122-
- "index template [my-template1] has index patterns [simple-data-stream1] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template1] will take precedence during new index creation"
123-
indices.put_index_template:
124-
name: my-template1
125-
body:
126-
index_patterns: [simple-data-stream1]
127-
template:
128-
mappings:
129-
properties:
130-
'@timestamp':
131-
type: date
132-
data_stream:
133-
timestamp_field: '@timestamp'
134-
135-
- do:
136-
indices.create_data_stream:
137-
name: simple-data-stream1
138-
- is_true: acknowledged
139-
140-
- do:
141-
catch: bad_request
142-
indices.clone:
143-
index: ".ds-simple-data-stream1-000001"
144-
target: "target"
145-
wait_for_active_shards: 1
146-
master_timeout: 10s
147-
body:
148-
settings:
149-
index.number_of_replicas: 0
150-
index.number_of_shards: 2
151-
152-
- do:
153-
indices.delete_data_stream:
154-
name: simple-data-stream1
155-
- is_true: acknowledged

rest-api-spec/src/main/resources/rest-api-spec/test/indices.data_stream/20_unsupported_apis.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)