Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit b53ef55

Browse files
committed
Prepare for es 7.x.x (not compiling due to elastic/elasticsearch#38944)
1 parent 03507b3 commit b53ef55

File tree

5 files changed

+30
-53
lines changed

5 files changed

+30
-53
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
// This plugin's version (typically must match that of ES).
3-
version = '6.6.2'
3+
version = '7.0.0-beta1'
44
group = 'org.carrot2'
55

66
buildscript {
77
ext {
88
// ES version we depend upon/ compile against.
9-
version_es = '6.6.2'
9+
version_es = '7.0.0-beta1'
1010
}
1111

1212
repositories {

src/main/java/org/carrot2/elasticsearch/ClusteringAction.java

+10-24
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
8080
import org.elasticsearch.search.internal.InternalSearchResponse;
8181
import org.elasticsearch.search.profile.SearchProfileShardResults;
82+
import org.elasticsearch.tasks.Task;
8283
import org.elasticsearch.threadpool.ThreadPool;
8384
import org.elasticsearch.transport.TransportChannel;
8485
import org.elasticsearch.transport.TransportRequestHandler;
@@ -88,9 +89,7 @@
8889
* Perform clustering of search results.
8990
*/
9091
public class ClusteringAction
91-
extends Action<ClusteringAction.ClusteringActionRequest,
92-
ClusteringAction.ClusteringActionResponse,
93-
ClusteringAction.ClusteringActionRequestBuilder> {
92+
extends Action<ClusteringAction.ClusteringActionResponse> {
9493
/* Action name. */
9594
public static final String NAME = "indices:data/read/cluster";
9695

@@ -106,11 +105,6 @@ public ClusteringActionResponse newResponse() {
106105
return new ClusteringActionResponse();
107106
}
108107

109-
@Override
110-
public ClusteringActionRequestBuilder newRequestBuilder(ElasticsearchClient client) {
111-
return new ClusteringActionRequestBuilder(client);
112-
}
113-
114108
/**
115109
* An {@link ActionRequest} for {@link ClusteringAction}.
116110
*/
@@ -500,9 +494,7 @@ public IndicesOptions indicesOptions() {
500494
* An {@link ActionRequestBuilder} for {@link ClusteringAction}.
501495
*/
502496
public static class ClusteringActionRequestBuilder
503-
extends ActionRequestBuilder<ClusteringActionRequest,
504-
ClusteringActionResponse,
505-
ClusteringActionRequestBuilder> {
497+
extends ActionRequestBuilder<ClusteringActionRequest, ClusteringActionResponse> {
506498

507499
public ClusteringActionRequestBuilder(ElasticsearchClient client) {
508500
super(client, ClusteringAction.INSTANCE, new ClusteringActionRequest());
@@ -746,27 +738,20 @@ public String toString() {
746738
* A {@link TransportAction} for {@link ClusteringAction}.
747739
*/
748740
public static class TransportClusteringAction
749-
extends TransportAction<ClusteringAction.ClusteringActionRequest,
750-
ClusteringAction.ClusteringActionResponse> {
741+
extends TransportAction<ClusteringAction.ClusteringActionRequest, ClusteringAction.ClusteringActionResponse> {
751742
private final Set<String> langCodeWarnings = new CopyOnWriteArraySet<>();
752743

753744
private final TransportSearchAction searchAction;
754745
private final ControllerSingleton controllerSingleton;
755746

756747
@Inject
757-
public TransportClusteringAction(Settings settings,
758-
ThreadPool threadPool,
759-
TransportService transportService,
748+
public TransportClusteringAction(TransportService transportService,
760749
TransportSearchAction searchAction,
761750
ControllerSingleton controllerSingleton,
762751
ActionFilters actionFilters,
763-
IndexNameExpressionResolver indexNameExpressionResolver,
764-
NamedXContentRegistry xContentRegistry) {
765-
super(settings,
766-
ClusteringAction.NAME,
767-
threadPool,
752+
IndexNameExpressionResolver indexNameExpressionResolver) {
753+
super(ClusteringAction.NAME,
768754
actionFilters,
769-
indexNameExpressionResolver,
770755
transportService.getTaskManager());
771756

772757
this.searchAction = searchAction;
@@ -779,7 +764,8 @@ public TransportClusteringAction(Settings settings,
779764
}
780765

781766
@Override
782-
protected void doExecute(final ClusteringActionRequest clusteringRequest,
767+
protected void doExecute(Task task,
768+
final ClusteringActionRequest clusteringRequest,
783769
final ActionListener<ClusteringActionResponse> listener) {
784770
final long tsSearchStart = System.nanoTime();
785771
searchAction.execute(clusteringRequest.getSearchRequest(), new ActionListener<SearchResponse>() {
@@ -1142,7 +1128,7 @@ static String join(List<?> list) {
11421128

11431129
private final class TransportHandler implements TransportRequestHandler<ClusteringActionRequest> {
11441130
@Override
1145-
public void messageReceived(final ClusteringActionRequest request, final TransportChannel channel) throws Exception {
1131+
public void messageReceived(final ClusteringActionRequest request, final TransportChannel channel, Task task) throws Exception {
11461132
execute(request, new ActionListener<ClusteringActionResponse>() {
11471133
@Override
11481134
public void onResponse(ClusteringActionResponse response) {

src/main/java/org/carrot2/elasticsearch/ControllerSingleton.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public class ControllerSingleton extends AbstractLifecycleComponent {
5151
private Logger logger;
5252

5353
@Inject
54-
public ControllerSingleton(Settings settings, Environment environment) {
55-
super(settings);
54+
public ControllerSingleton(Environment environment) {
5655
this.environment = environment;
5756
this.logger = LogManager.getLogger("plugin.carrot2");
5857
}

src/main/java/org/carrot2/elasticsearch/ListAlgorithmsAction.java

+11-23
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.elasticsearch.action.support.TransportAction;
1111
import org.elasticsearch.client.ElasticsearchClient;
1212
import org.elasticsearch.client.node.NodeClient;
13-
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
1413
import org.elasticsearch.common.inject.Inject;
1514
import org.elasticsearch.common.io.stream.StreamInput;
1615
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -23,6 +22,7 @@
2322
import org.elasticsearch.rest.RestRequest;
2423
import org.elasticsearch.rest.RestRequest.Method;
2524
import org.elasticsearch.rest.RestStatus;
25+
import org.elasticsearch.tasks.Task;
2626
import org.elasticsearch.threadpool.ThreadPool;
2727
import org.elasticsearch.transport.TransportChannel;
2828
import org.elasticsearch.transport.TransportRequestHandler;
@@ -38,9 +38,7 @@
3838
/**
3939
* List all available clustering algorithms.
4040
*/
41-
public class ListAlgorithmsAction extends Action<ListAlgorithmsAction.ListAlgorithmsActionRequest,
42-
ListAlgorithmsAction.ListAlgorithmsActionResponse,
43-
ListAlgorithmsAction.ListAlgorithmsActionRequestBuilder> {
41+
public class ListAlgorithmsAction extends Action<ListAlgorithmsAction.ListAlgorithmsActionResponse> {
4442
/* Action name. */
4543
public static final String NAME = "cluster:monitor/carrot2/algorithms";
4644

@@ -56,11 +54,6 @@ public ListAlgorithmsActionResponse newResponse() {
5654
return new ListAlgorithmsActionResponse();
5755
}
5856

59-
@Override
60-
public ListAlgorithmsActionRequestBuilder newRequestBuilder(ElasticsearchClient client) {
61-
return new ListAlgorithmsActionRequestBuilder(client);
62-
}
63-
6457
/**
6558
* An {@link ActionRequest} for {@link ListAlgorithmsAction}.
6659
*/
@@ -77,8 +70,7 @@ public ActionRequestValidationException validate() {
7770
*/
7871
public static class ListAlgorithmsActionRequestBuilder
7972
extends ActionRequestBuilder<ListAlgorithmsActionRequest,
80-
ListAlgorithmsActionResponse,
81-
ListAlgorithmsActionRequestBuilder> {
73+
ListAlgorithmsActionResponse> {
8274
public ListAlgorithmsActionRequestBuilder(ElasticsearchClient client) {
8375
super(client, ListAlgorithmsAction.INSTANCE, new ListAlgorithmsActionRequest());
8476
}
@@ -144,22 +136,16 @@ public String toString() {
144136
* {@link ListAlgorithmsActionResponse}.
145137
*/
146138
public static class TransportListAlgorithmsAction
147-
extends TransportAction<ListAlgorithmsActionRequest,
148-
ListAlgorithmsActionResponse> {
139+
extends TransportAction<ListAlgorithmsActionRequest, ListAlgorithmsActionResponse> {
149140

150141
private final ControllerSingleton controllerSingleton;
151142

152143
@Inject
153-
public TransportListAlgorithmsAction(Settings settings, ThreadPool threadPool,
154-
TransportService transportService,
144+
public TransportListAlgorithmsAction(TransportService transportService,
155145
ControllerSingleton controllerSingleton,
156-
ActionFilters actionFilters,
157-
IndexNameExpressionResolver indexNameExpressionResolver) {
158-
super(settings,
159-
ListAlgorithmsAction.NAME,
160-
threadPool,
146+
ActionFilters actionFilters) {
147+
super(ListAlgorithmsAction.NAME,
161148
actionFilters,
162-
indexNameExpressionResolver,
163149
transportService.getTaskManager());
164150
this.controllerSingleton = controllerSingleton;
165151
transportService.registerRequestHandler(
@@ -170,15 +156,17 @@ public TransportListAlgorithmsAction(Settings settings, ThreadPool threadPool,
170156
}
171157

172158
@Override
173-
protected void doExecute(ListAlgorithmsActionRequest request,
159+
protected void doExecute(Task task,
160+
ListAlgorithmsActionRequest request,
174161
ActionListener<ListAlgorithmsActionResponse> listener) {
175162
listener.onResponse(new ListAlgorithmsActionResponse(controllerSingleton.getAlgorithms()));
176163
}
177164

178165
private final class TransportHandler implements TransportRequestHandler<ListAlgorithmsActionRequest> {
179166
@Override
180167
public void messageReceived(final ListAlgorithmsActionRequest request,
181-
final TransportChannel channel) throws Exception {
168+
final TransportChannel channel,
169+
Task task) throws Exception {
182170
execute(request, new ActionListener<ListAlgorithmsActionResponse>() {
183171
@Override
184172
public void onResponse(ListAlgorithmsActionResponse response) {

src/test/java/org/carrot2/elasticsearch/SampleIndexTestCase.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ public abstract class SampleIndexTestCase extends ESIntegTestCase {
5555
protected Settings nodeSettings(int nodeOrdinal) {
5656
return Settings.builder()
5757
.put(super.nodeSettings(nodeOrdinal))
58-
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
5958
.build();
6059
}
61-
60+
61+
@Override
62+
protected boolean addMockHttpTransport() {
63+
return false;
64+
}
65+
6266
@Override
6367
protected Collection<Class<? extends Plugin>> nodePlugins() {
6468
return Collections.singletonList(ClusteringPlugin.class);

0 commit comments

Comments
 (0)