Skip to content

Commit 3d6b985

Browse files
authored
Move point in time to server (#70704) (#70952)
This change moves the implementation of point in time to the server package.
1 parent 6cc059d commit 3d6b985

File tree

28 files changed

+192
-137
lines changed

28 files changed

+192
-137
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,9 @@ public void testApiNamingConventions() throws Exception {
823823
"scripts_painless_execute",
824824
"indices.simulate_template",
825825
"indices.resolve_index",
826-
"indices.add_block"
826+
"indices.add_block",
827+
"open_point_in_time",
828+
"close_point_in_time"
827829
};
828830
//These API are not required for high-level client feature completeness
829831
String[] notRequiredApi = new String[] {

docs/reference/search/point-in-time-api.asciidoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[role="xpack"]
2-
[testenv="basic"]
31
[[point-in-time-api]]
42
=== Point in time API
53
++++

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/search/point_in_time.yml renamed to rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/350_point_in_time.yml

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ setup:
3737
---
3838
"basic":
3939
- skip:
40-
version: " - 7.9.99"
41-
reason: "point in time is introduced in 7.10"
40+
version: " - 7.12.99"
41+
reason: "point in time is introduced in server in 7.13"
4242
- do:
4343
open_point_in_time:
4444
index: test
@@ -47,7 +47,6 @@ setup:
4747

4848
- do:
4949
search:
50-
rest_total_hits_as_int: true
5150
body:
5251
size: 1
5352
query:
@@ -58,7 +57,7 @@ setup:
5857
id: "$point_in_time_id"
5958
keep_alive: 1m
6059

61-
- match: {hits.total: 3 }
60+
- match: {hits.total.value: 3 }
6261
- length: {hits.hits: 1 }
6362
- match: {hits.hits.0._index: test }
6463
- match: {hits.hits.0._id: "172" }
@@ -77,7 +76,6 @@ setup:
7776
# search with a point in time
7877
- do:
7978
search:
80-
rest_total_hits_as_int: true
8179
body:
8280
size: 1
8381
query:
@@ -88,7 +86,7 @@ setup:
8886
pit:
8987
id: "$point_in_time_id"
9088

91-
- match: {hits.total: 3 }
89+
- match: {hits.total.value: 3 }
9290
- length: {hits.hits: 1 }
9391
- match: {hits.hits.0._index: test }
9492
- match: {hits.hits.0._id: "42" }
@@ -97,7 +95,6 @@ setup:
9795

9896
- do:
9997
search:
100-
rest_total_hits_as_int: true
10198
body:
10299
size: 1
103100
query:
@@ -108,7 +105,7 @@ setup:
108105
pit:
109106
id: "$point_in_time_id"
110107

111-
- match: {hits.total: 3}
108+
- match: {hits.total.value: 3}
112109
- length: {hits.hits: 1 }
113110
- match: {hits.hits.0._index: test }
114111
- match: {hits.hits.0._id: "1" }
@@ -117,7 +114,6 @@ setup:
117114

118115
- do:
119116
search:
120-
rest_total_hits_as_int: true
121117
body:
122118
size: 1
123119
query:
@@ -129,7 +125,7 @@ setup:
129125
id: "$point_in_time_id"
130126
keep_alive: 1m
131127

132-
- match: {hits.total: 3}
128+
- match: {hits.total.value: 3}
133129
- length: {hits.hits: 0 }
134130

135131
- do:
@@ -150,7 +146,6 @@ setup:
150146

151147
- do:
152148
search:
153-
rest_total_hits_as_int: true
154149
body:
155150
size: 2
156151
query:
@@ -161,7 +156,7 @@ setup:
161156
id: "$point_in_time_id"
162157
keep_alive: 1m
163158

164-
- match: {hits.total: 4 }
159+
- match: {hits.total.value: 4 }
165160
- length: {hits.hits: 2 }
166161
- match: {hits.hits.0._index: test }
167162
- match: {hits.hits.0._id: "172" }
@@ -172,3 +167,41 @@ setup:
172167
close_point_in_time:
173168
body:
174169
id: "$point_in_time_id"
170+
171+
---
172+
"msearch":
173+
- skip:
174+
version: " - 7.99.99"
175+
reason: "After backport: 7.9.99 => point in time is introduced in 7.10"
176+
- do:
177+
open_point_in_time:
178+
index: "t*"
179+
keep_alive: 5m
180+
- set: {id: point_in_time_id}
181+
182+
- do:
183+
msearch:
184+
body:
185+
- {}
186+
- { query: { match: { _index: test }}, pit: { id: "$point_in_time_id" }}
187+
- {}
188+
- { query: { match_all: {}}, pit: { id: "$point_in_time_id" }}
189+
190+
- match: { responses.0.hits.total.value: 3 }
191+
- match: { responses.0.hits.total.relation: eq }
192+
- match: { responses.1.hits.total.value: 4 }
193+
- match: { responses.1.hits.total.relation: eq }
194+
195+
- do:
196+
catch: bad_request
197+
msearch:
198+
body:
199+
- index: index
200+
- { query: { match: { foo: bar }}, pit: { id: "$point_in_time_id" }}
201+
- index: index2
202+
- { query: { match_all: {}}, pit: { id: "$point_in_time_id" }}
203+
204+
- do:
205+
close_point_in_time:
206+
body:
207+
id: "$point_in_time_id"
Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
33
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
67
*/
78

8-
package org.elasticsearch.xpack.core.search;
9+
package org.elasticsearch.action.search;
910

10-
import org.elasticsearch.action.search.SearchResponse;
1111
import org.elasticsearch.client.Client;
1212
import org.elasticsearch.common.unit.TimeValue;
1313
import org.elasticsearch.index.query.MatchAllQueryBuilder;
14-
import org.elasticsearch.plugins.Plugin;
1514
import org.elasticsearch.search.builder.PointInTimeBuilder;
1615
import org.elasticsearch.test.AbstractMultiClustersTestCase;
17-
import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin;
18-
import org.elasticsearch.xpack.core.search.action.ClosePointInTimeAction;
19-
import org.elasticsearch.xpack.core.search.action.ClosePointInTimeRequest;
20-
import org.elasticsearch.xpack.core.search.action.OpenPointInTimeAction;
21-
import org.elasticsearch.xpack.core.search.action.OpenPointInTimeRequest;
22-
import org.elasticsearch.xpack.core.search.action.OpenPointInTimeResponse;
2316

2417
import java.util.ArrayList;
2518
import java.util.Collection;
@@ -37,12 +30,6 @@ protected Collection<String> remoteClusterAlias() {
3730
return Collections.singletonList("remote_cluster");
3831
}
3932

40-
@Override
41-
protected Collection<Class<? extends Plugin>> nodePlugins(String clusterAlias) {
42-
final List<Class<? extends Plugin>> plugins = new ArrayList<>(super.nodePlugins(clusterAlias));
43-
plugins.add(LocalStateCompositeXPackPlugin.class);
44-
return plugins;
45-
}
4633

4734
void indexDocs(Client client, String index, int numDocs) {
4835
for (int i = 0; i < numDocs; i++) {
Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
33
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
67
*/
78

8-
package org.elasticsearch.xpack.core.search;
9+
package org.elasticsearch.action.search;
910

1011
import org.elasticsearch.ExceptionsHelper;
1112
import org.elasticsearch.action.admin.indices.stats.CommonStats;
12-
import org.elasticsearch.common.util.CollectionUtils;
13-
import org.elasticsearch.plugins.Plugin;
14-
import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin;
15-
import org.elasticsearch.xpack.core.XPackClientPlugin;
16-
import org.elasticsearch.xpack.core.XPackSettings;
17-
import org.elasticsearch.xpack.core.search.action.ClosePointInTimeAction;
18-
import org.elasticsearch.xpack.core.search.action.ClosePointInTimeRequest;
19-
import org.elasticsearch.action.search.SearchPhaseExecutionException;
20-
import org.elasticsearch.action.search.SearchRequest;
21-
import org.elasticsearch.action.search.SearchRequestBuilder;
22-
import org.elasticsearch.action.search.SearchResponse;
23-
import org.elasticsearch.action.search.SearchType;
24-
import org.elasticsearch.action.search.ShardSearchFailure;
2513
import org.elasticsearch.cluster.metadata.IndexMetadata;
2614
import org.elasticsearch.cluster.routing.ShardRouting;
2715
import org.elasticsearch.common.settings.Settings;
@@ -41,12 +29,7 @@
4129
import org.elasticsearch.search.sort.SortBuilders;
4230
import org.elasticsearch.search.sort.SortOrder;
4331
import org.elasticsearch.test.ESIntegTestCase;
44-
import org.elasticsearch.xpack.core.search.action.OpenPointInTimeAction;
45-
import org.elasticsearch.xpack.core.search.action.OpenPointInTimeRequest;
46-
import org.elasticsearch.xpack.core.search.action.OpenPointInTimeResponse;
4732

48-
import java.util.Collection;
49-
import java.util.Collections;
5033
import java.util.HashSet;
5134
import java.util.List;
5235
import java.util.Set;
@@ -75,22 +58,6 @@ protected Settings nodeSettings(int nodeOrdinal) {
7558
.build();
7659
}
7760

78-
@Override
79-
protected Collection<Class<? extends Plugin>> nodePlugins() {
80-
return Collections.singleton(LocalStateCompositeXPackPlugin.class);
81-
}
82-
83-
@Override
84-
public Settings transportClientSettings() {
85-
return Settings.builder().put(super.transportClientSettings())
86-
.put(XPackSettings.SECURITY_ENABLED.getKey(), false).build();
87-
}
88-
89-
@Override
90-
protected Collection<Class<? extends Plugin>> transportClientPlugins() {
91-
return CollectionUtils.appendToCopy(super.transportClientPlugins(), XPackClientPlugin.class);
92-
}
93-
9461
public void testBasic() {
9562
createIndex("test");
9663
int numDocs = randomIntBetween(10, 50);

server/src/main/java/org/elasticsearch/action/ActionModule.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,17 @@
214214
import org.elasticsearch.action.main.MainAction;
215215
import org.elasticsearch.action.main.TransportMainAction;
216216
import org.elasticsearch.action.search.ClearScrollAction;
217+
import org.elasticsearch.action.search.ClosePointInTimeAction;
217218
import org.elasticsearch.action.search.MultiSearchAction;
219+
import org.elasticsearch.action.search.OpenPointInTimeAction;
220+
import org.elasticsearch.action.search.RestClosePointInTimeAction;
221+
import org.elasticsearch.action.search.RestOpenPointInTimeAction;
218222
import org.elasticsearch.action.search.SearchAction;
219223
import org.elasticsearch.action.search.SearchScrollAction;
220224
import org.elasticsearch.action.search.TransportClearScrollAction;
225+
import org.elasticsearch.action.search.TransportClosePointInTimeAction;
221226
import org.elasticsearch.action.search.TransportMultiSearchAction;
227+
import org.elasticsearch.action.search.TransportOpenPointInTimeAction;
222228
import org.elasticsearch.action.search.TransportSearchAction;
223229
import org.elasticsearch.action.search.TransportSearchScrollAction;
224230
import org.elasticsearch.action.support.ActionFilters;
@@ -591,6 +597,8 @@ public <Request extends ActionRequest, Response extends ActionResponse> void reg
591597
TransportShardBulkAction.class);
592598
actions.register(SearchAction.INSTANCE, TransportSearchAction.class);
593599
actions.register(SearchScrollAction.INSTANCE, TransportSearchScrollAction.class);
600+
actions.register(OpenPointInTimeAction.INSTANCE, TransportOpenPointInTimeAction.class);
601+
actions.register(ClosePointInTimeAction.INSTANCE, TransportClosePointInTimeAction.class);
594602
actions.register(MultiSearchAction.INSTANCE, TransportMultiSearchAction.class);
595603
actions.register(ExplainAction.INSTANCE, TransportExplainAction.class);
596604
actions.register(ClearScrollAction.INSTANCE, TransportClearScrollAction.class);
@@ -742,6 +750,8 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster) {
742750
registerHandler.accept(new RestSearchAction());
743751
registerHandler.accept(new RestSearchScrollAction());
744752
registerHandler.accept(new RestClearScrollAction());
753+
registerHandler.accept(new RestOpenPointInTimeAction());
754+
registerHandler.accept(new RestClosePointInTimeAction());
745755
registerHandler.accept(new RestMultiSearchAction(settings));
746756

747757
registerHandler.accept(new RestValidateQueryAction());
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
19
/*
210
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
311
* or more contributor license agreements. Licensed under the Elastic License
412
* 2.0; you may not use this file except in compliance with the Elastic License
513
* 2.0.
614
*/
715

8-
package org.elasticsearch.xpack.core.search.action;
16+
package org.elasticsearch.action.search;
917

1018
import org.elasticsearch.action.ActionType;
1119

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
19
/*
210
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
311
* or more contributor license agreements. Licensed under the Elastic License
412
* 2.0; you may not use this file except in compliance with the Elastic License
513
* 2.0.
614
*/
715

8-
package org.elasticsearch.xpack.core.search.action;
16+
package org.elasticsearch.action.search;
917

1018
import org.elasticsearch.action.ActionRequest;
1119
import org.elasticsearch.action.ActionRequestValidationException;
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
19
/*
210
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
311
* or more contributor license agreements. Licensed under the Elastic License
412
* 2.0; you may not use this file except in compliance with the Elastic License
513
* 2.0.
614
*/
715

8-
package org.elasticsearch.xpack.core.search.action;
16+
package org.elasticsearch.action.search;
917

1018
import org.elasticsearch.action.search.ClearScrollResponse;
1119
import org.elasticsearch.common.io.stream.StreamInput;
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
19
/*
210
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
311
* or more contributor license agreements. Licensed under the Elastic License
412
* 2.0; you may not use this file except in compliance with the Elastic License
513
* 2.0.
614
*/
715

8-
package org.elasticsearch.xpack.core.search.action;
16+
package org.elasticsearch.action.search;
917

1018
import org.elasticsearch.action.ActionType;
1119

0 commit comments

Comments
 (0)