Skip to content

Commit 1bd44b1

Browse files
committed
wip
1 parent f18f4ee commit 1bd44b1

File tree

7 files changed

+159
-8
lines changed

7 files changed

+159
-8
lines changed

server/src/main/java/org/elasticsearch/TransportVersion.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@
3333
* Each transport version constant has an id number, which for versions prior to 8.9.0 is the same as the release version for backwards
3434
* compatibility. In 8.9.0 this is changed to an incrementing number, disconnected from the release version.
3535
* <p>
36-
* Each version constant has a unique id string. This is not actually used in the binary protocol, but is there to ensure each protocol
37-
* version is only added to the source file once. This string needs to be unique (normally a UUID, but can be any other unique nonempty
38-
* string). If two concurrent PRs add the same transport version, the different unique ids cause a git conflict, ensuring that the second PR
39-
* to be merged must be updated with the next free version first. Without the unique id string, git will happily merge the two versions
40-
* together, resulting in the same transport version being used across multiple commits, causing problems when you try to upgrade between
41-
* those two merged commits.
42-
*
4336
* <h2>Version compatibility</h2>
4437
* The earliest compatible version is hardcoded in the {@link TransportVersions#MINIMUM_COMPATIBLE} field. Previously, this was dynamically
4538
* calculated from the major/minor versions of {@link Version}, but {@code TransportVersion} does not have separate major/minor version
@@ -150,7 +143,7 @@ public static TransportVersion fromString(String str) {
150143
/**
151144
* Returns {@code true} if this version is a patch version at or after {@code version}.
152145
* <p>
153-
* This should not be used normally. It is used for matching patch versions of the same base version,
146+
* This should not normally be used. It is used for matching patch versions of the same major and minor version,
154147
* using the standard version number format specified in {@link TransportVersions}.
155148
* When a patch version of an existing transport version is created, {@code transportVersion.isPatchFrom(patchVersion)}
156149
* will match any transport version at or above {@code patchVersion} that is also of the same base version.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@
209209
import org.elasticsearch.action.termvectors.TransportMultiTermVectorsAction;
210210
import org.elasticsearch.action.termvectors.TransportShardMultiTermsVectorAction;
211211
import org.elasticsearch.action.termvectors.TransportTermVectorsAction;
212+
import org.elasticsearch.action.tvbackport.RestTVBackportAction;
213+
import org.elasticsearch.action.tvbackport.TVBackportAction;
214+
import org.elasticsearch.action.tvbackport.TransportTVBackportAction;
212215
import org.elasticsearch.action.update.TransportUpdateAction;
213216
import org.elasticsearch.client.internal.node.NodeClient;
214217
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
@@ -806,6 +809,9 @@ public <Request extends ActionRequest, Response extends ActionResponse> void reg
806809
actions.register(GetSynonymRuleAction.INSTANCE, TransportGetSynonymRuleAction.class);
807810
actions.register(DeleteSynonymRuleAction.INSTANCE, TransportDeleteSynonymRuleAction.class);
808811

812+
// Transport Version Backport Testing
813+
actions.register(TVBackportAction.INSTANCE, TransportTVBackportAction.class);
814+
809815
return unmodifiableMap(actions.getRegistry());
810816
}
811817

@@ -1032,6 +1038,9 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster, Predicate<
10321038
registerHandler.accept(new RestPutSynonymRuleAction());
10331039
registerHandler.accept(new RestGetSynonymRuleAction());
10341040
registerHandler.accept(new RestDeleteSynonymRuleAction());
1041+
1042+
// Transport Version Backport Testing
1043+
registerHandler.accept(new RestTVBackportAction());
10351044
}
10361045

10371046
@Override
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.action.tvbackport;
11+
12+
import org.elasticsearch.client.internal.node.NodeClient;
13+
import org.elasticsearch.rest.BaseRestHandler;
14+
import org.elasticsearch.rest.RestRequest;
15+
import org.elasticsearch.rest.action.RestToXContentListener;
16+
17+
import java.io.IOException;
18+
import java.util.List;
19+
20+
public class RestTVBackportAction extends BaseRestHandler {
21+
@Override
22+
public String getName() {
23+
return "_tv_backport_action";
24+
}
25+
26+
@Override
27+
public List<Route> routes() {
28+
return List.of(new Route(RestRequest.Method.GET, "/_tv_backport"));
29+
}
30+
31+
@Override
32+
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
33+
TVBackportRequest tvBackportRequest = new TVBackportRequest();
34+
// Here you can set any parameters from the request to the tvBackportRequest if needed
35+
return channel -> client.execute(TVBackportAction.INSTANCE, tvBackportRequest, new RestToXContentListener<>(channel));
36+
}
37+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.action.tvbackport;
11+
12+
import org.elasticsearch.action.ActionType;
13+
14+
public class TVBackportAction extends ActionType<TVBackportResponse> {
15+
public static final TVBackportAction INSTANCE = new TVBackportAction();
16+
public static final String NAME = "indices:data/read/tvbackport";
17+
18+
private TVBackportAction() {
19+
super(NAME);
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.action.tvbackport;
11+
12+
import org.elasticsearch.action.ActionRequest;
13+
import org.elasticsearch.action.ActionRequestValidationException;
14+
15+
public class TVBackportRequest extends ActionRequest {
16+
17+
@Override
18+
public ActionRequestValidationException validate() {
19+
return null;
20+
}
21+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.action.tvbackport;
11+
12+
import org.elasticsearch.action.ActionResponse;
13+
import org.elasticsearch.common.io.stream.StreamOutput;
14+
import org.elasticsearch.xcontent.ToXContentObject;
15+
import org.elasticsearch.xcontent.XContentBuilder;
16+
17+
import java.io.IOException;
18+
19+
public class TVBackportResponse extends ActionResponse implements ToXContentObject {
20+
@Override
21+
public void writeTo(StreamOutput out) throws IOException {
22+
// TODO: Implement the serialization logic for the response
23+
}
24+
25+
@Override
26+
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
27+
// TODO: Implement the logic to convert the response to XContent format
28+
return null;
29+
}
30+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.action.tvbackport;
11+
12+
import org.apache.logging.log4j.LogManager;
13+
import org.apache.logging.log4j.Logger;
14+
import org.elasticsearch.action.ActionListener;
15+
import org.elasticsearch.action.support.ActionFilters;
16+
import org.elasticsearch.action.support.TransportAction;
17+
import org.elasticsearch.injection.guice.Inject;
18+
import org.elasticsearch.tasks.Task;
19+
import org.elasticsearch.tasks.TaskManager;
20+
21+
import java.util.concurrent.Executor;
22+
23+
public class TransportTVBackportAction extends TransportAction<TVBackportRequest, TVBackportResponse> {
24+
private static final Logger logger = LogManager.getLogger(TransportTVBackportAction.class);
25+
26+
@Inject
27+
public TransportTVBackportAction(
28+
ActionFilters actionFilters,
29+
TaskManager taskManager,
30+
Executor executor
31+
) {
32+
super(TVBackportAction.NAME, actionFilters, taskManager, executor);
33+
}
34+
35+
@Override
36+
protected void doExecute(Task task, TVBackportRequest request, ActionListener<TVBackportResponse> listener) {
37+
logger.info("Executing TVBackportAction for request");
38+
listener.onResponse(new TVBackportResponse());
39+
}
40+
}

0 commit comments

Comments
 (0)